我的文档和Google-fu在这个问题上严重辜负了我,所以:
如何使用P4API的GetChangelist()函数同步一系列文件(即从@now到@twoDaysAgo的所有文件)?我可以很容易地构造命令行,这样做如下:
p4 changes -s submitted //...@2016/12/01,2016/12/06但是API想让我通过
GetChangelist(Options options, FileSpec[] files)我不得不构造一个选项和Filespecs[]的组合来代替请求,(AFAIK)不能只传递实际的命令行字符串,这让我感到非常疯狂。尤其是因为所有的文档似乎都不存在。
有人能告诉我我要传递什么样的文件参数吗?(我认为这就是我需要用来指定的事实,即我希望在一定时间内获得所有CLs的范围?)谢谢!
(顺便说一句:我很惊讶还没有"P4API“标签,我也无法创建一个标签。)
发布于 2016-12-06 05:12:12
好的,经过几个小时的深入研究,我发现有一种方法可以将实际的命令行参数输入到命令中。您将创建一个DepotSpec,然后类似的内容将限制从服务器检索到的CLs的时间范围:
ChangesCmdOptions changeListOptions = new ChangesCmdOptions(ChangesCmdFlags.FullDescription|ChangesCmdFlags.IncludeTime, null, 0, ChangeListStatus.None, null);
FileSpec[] fileSpecs = new FileSpec[1] { new FileSpec(new DepotPath("//depot/...@2016/12/05 21:57:30,@now"), null, null, null) };
IList<Changelist> changes = m_Repository.GetChangelists(changeListOptions, fileSpecs);对于已经使用API一段时间的人来说,所有这些都可能是“宽容的微笑”。当像本文中提到的两个页面("FileSpec对象文档“、"SyncFiles方法文档”)这样的文档现在离线时,新手会有些困惑:Perforce Api - How to command "get revision [changelist number]"
发布于 2016-12-06 17:37:05
下面是您真正想要使用的非命令行版本,来自Perforce文档(一旦您找到它:)
PathSpec path = new DepotPath("//depot/...");
DateTimeVersion lowerTimeStamp = new DateTimeVersion(new DateTime(2016,12,06));
DateTimeVersion upperTimeStamp = new DateTimeVersion(DateTime.Now);
VersionSpec version = new VersionRange(lowerTimeStamp, upperTimeStamp);
FileSpec[] fileSpecs = { new FileSpec(path, version) };
ChangesCmdOptions changeListOptions = new ChangesCmdOptions(ChangesCmdFlags.FullDescription | ChangesCmdFlags.IncludeTime, null, 0, ChangeListStatus.None, null);
IList<Changelist> changes = m_Repository.GetChangelists(changeListOptions, fileSpecs);https://stackoverflow.com/questions/40986656
复制相似问题