簡體   English   中英

如何使用p4java同步到標簽

[英]How to sync to a label with 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,但沒有看到任何在其中指定標簽的方法。

FileSpec是IFileSpec的實現,具有一個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

經過以上建議,研究了fileSpecs參數之后,我發現此方法對我有用:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM