如何使用p4java同步到标签

时间:2015-12-03 23:25:36

标签: perforce p4java

我在网上看到了使用Perforce的p4java api将客户端工作区与最新文件同步的示例。例如:

public List<IFileSpec> sync(List<IFileSpec> fileSpecs,
                        boolean forceUpdate,
                        boolean noUpdate,
                        boolean clientBypass,
                        boolean serverBypass)

但是如何指定它同步到特定标签?例如,在命令行中等效于此:

p4 sync @labelname

是否可能通过使用SyncOptions的备用方法?

public List<IFileSpec> sync(List<IFileSpec> fileSpecs,
                        SyncOptions syncOpts)

我查看了SyncOptions,但没有看到任何方法在那里指定标签。

2 个答案:

答案 0 :(得分:1)

作为IFileSpec实现的FileSpec有一个label字段:

protected  String   label

和以下方法:

 void   setLabel(String label)
      Set the label associated with this file spec.

取自以下链接:

https://www.perforce.com/perforce/r15.1/manuals/p4java-javadoc/com/perforce/p4java/impl/generic/core/file/FileSpec.html

答案 1 :(得分:1)

在上面的建议中查看fileSpecs参数后,我发现这个方法对我有用:

List<IFileSpec> fileSpecsSet = 
    FileSpecBuilder.makeFileSpecList("//path/to/project/...@labelname");
client.sync(fileSpecsSet, true, false, false, false);
相关问题