Click or drag to resize

RepositoryTagFiles Method

Tag depot files with the passed-in label.

Namespace:  Perforce.P4
Assembly:  p4api.net (in p4api.net.dll) Version: 2023.2.255.3501
Syntax
public IList<FileSpec> TagFiles(
	IList<FileSpec> filespecs,
	string labelid,
	Options options
)

Parameters

filespecs
Type: System.Collections.GenericIListFileSpec
labelid
Type: SystemString
options
Type: Perforce.P4Options

Return Value

Type: IListFileSpec
Remarks

p4 help tag

tag -- Tag files with a label

p4 tag [-d -g -n -U] -l label file[revRange] ...

Tag associates the named label with the file revisions specified by
the file argument. After file revisions are tagged with a label,
revision specifications of the form '@label' can be used to refer
to them.

If the file argument does not include a revision specification, the
head revisions is tagged. See 'p4 help revisions' for revision
specification options.

If the file argument includes a revision range specification, only
the files with revisions in that range are tagged. Files with more
than one revision in the range are tagged at the highest revision.

The -d deletes the association between the specified files and the
label, regardless of revision.

The -n flag previews the results of the operation.

Tag can be used with an existing label (see 'p4 help labels') or
with a new one. An existing label can be used only by its owner,
and only if it is unlocked. (See 'p4 help label').

The -U flag specifies that the new label should be created with the
'autoreload' option (See 'p4 help label'). It has no effect on an
existing label.

To list the file revisions tagged with a label, use 'p4 files
@label'.

The -g flag is used on an Edge Server to update a global label.
Configuring rpl.labels.global=1 reverses this default and causes this
flag to have the opposite meaning.

Examples
To tag the file //depot/MyCode/README.txt with build_label:
   TagCmdOptions opts =
   new TagCmdOptions(TagFilesCmdFlags.None, null);

FileSpec filespec =
new FileSpec(new DepotPath("//depot/MyCode/README.txt"), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);

   IList<FileSpec> target =
   Repository.TagFiles(filespecs, "build_label", opts);
To remove the association between the file //depot/MyCode/README.txt and build_label:
   TagCmdOptions opts =
   new TagCmdOptions(TagFilesCmdFlags.Delete, null);

FileSpec filespec =
new FileSpec(new DepotPath("//depot/MyCode/README.txt"), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);

   IList<FileSpec> target =
   Repository.TagFiles(filespecs, "build_label", opts);
To get a preview list of the files that would be tagged in path //depot/main/src with build_label:
   TagCmdOptions opts =
   new TagCmdOptions(TagFilesCmdFlags.ListOnly, null);

FileSpec filespec =
new FileSpec(new DepotPath("//depot/main/src/..."), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);

   IList<FileSpec> target =
   Repository.TagFiles(filespecs, "build_label", opts);
See Also