如何使用 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.
摘自以下 link :
根据上面的建议查看 fileSpecs 参数,我发现这个方法对我有用:
List<IFileSpec> fileSpecsSet =
FileSpecBuilder.makeFileSpecList("//path/to/project/...@labelname");
client.sync(fileSpecsSet, true, false, false, false);
我在网上看到了使用 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.
摘自以下 link :
根据上面的建议查看 fileSpecs 参数,我发现这个方法对我有用:
List<IFileSpec> fileSpecsSet =
FileSpecBuilder.makeFileSpecList("//path/to/project/...@labelname");
client.sync(fileSpecsSet, true, false, false, false);