Click or drag to resize

RepositoryGetLabels Method

Get a list of labels from the repository

Namespace:  Perforce.P4
Assembly:  p4api.net (in p4api.net.dll) Version: 2023.2.258.5793
Syntax
public IList<Label> GetLabels(
	Options options,
	params FileSpec[] files
)

Parameters

options
Type: Perforce.P4Options
files
Type: Perforce.P4FileSpec

Return Value

Type: IListLabel
A list containing the matching labels
Remarks

p4 help labels

labels -- Display list of defined labels

p4 labels [-t] [-u user] [[-e|-E] nameFilter -m max] [file[revrange]]
p4 labels [-t] [-u user] [[-e|-E] nameFilter -m max] [-a|-s serverID]
p4 labels -U

Lists labels defined in the server.

If files are specified, 'p4 labels' lists the labels that contain
those files. If you include a file specification, automatic labels
and labels with the 'autoreload' option set are omitted from the list.
If the file specification includes a revision range, 'p4 labels'
lists labels that contain the specified revisions.

See 'p4 help revisions' for details about specifying revisions.

The -t flag displays the time as well as the date.

The -u user flag lists labels owned by the specified user.

The -e nameFilter flag lists labels with a name that matches
the nameFilter pattern, for example: -e 'svr-dev-rel*'. The -e flag
uses the server's normal case-sensitivity rules. The -E flag makes
the matching case-insensitive, even on a case-sensitive server.

The -m max flag limits output to the first 'max' number of labels.

The -U flag lists unloaded labels (see 'p4 help unload').

The -a and -s flags are useful in a distributed server installation
(see 'p4 help distributed') in order to see the names of local labels
stored on other Edge Servers. These flags are not allowed if the
command includes a file specification.

The -a flag specifies that all labels should be displayed, not just
those that are bound to this server.

The -s serverID flag specifies that only those labels bound to the
specified serverID should be displayed.

On an Edge Server, if neither -s nor -a is specified, only those
local labels bound to this Edge Server are displayed. Labels created
on the Commit Server are global, and are also included in the output.

Examples
To get 50 labels on a distributed server installation:
LabelsCmdOptions opts = new LabelsCmdOptions(LabelsCmdFlags.All,
    null, null, 50, null, null);
IList<Label> labels = rep.GetLabels(opts);
To get labels which contain files with the path //depot/Modifiers/...:
FileSpec path = new FileSpec(new DepotPath("//depot/Modifiers/..."), null);
Options ops = new Options();
IList<Label> l = rep.GetLabels(ops, path);
See Also