C# 同步到特定日期/时间范围内的所有CLs

C# 同步到特定日期/时间范围内的所有CLs,c#,perforce,C#,Perforce,我的文档和Google fu在这一点上让我非常失望,因此: 如何使用P4API的GetChangelist()函数同步一系列文件(即从@now到@twoDaysAgo的所有文件)?我可以很容易地构造命令行来执行以下操作: p4 changes -s submitted //...@2016/12/01,2016/12/06 但是API希望我通过 GetChangelist(Options options, FileSpec[] files) 我必须构造一个选项和filespec[]的组合来发

我的文档和Google fu在这一点上让我非常失望,因此:

如何使用P4API的GetChangelist()函数同步一系列文件(即从@now到@twoDaysAgo的所有文件)?我可以很容易地构造命令行来执行以下操作:

p4 changes -s submitted //...@2016/12/01,2016/12/06
但是API希望我通过

GetChangelist(Options options, FileSpec[] files)
我必须构造一个选项和filespec[]的组合来发出请求,而且(AFAIK)不能只传递实际的命令行字符串,这让我抓狂。尤其是因为所有文档似乎都不存在

有人能告诉我我必须传递什么类型的filespec参数吗?(我想这就是我需要用来指定的事实,即我希望在特定时间内获得所有CLs的范围?)


(顺便说一句:我很惊讶还没有“P4API”标记,我无法创建一个。)

好吧,经过几个小时的挖掘,我发现有一种方法可以将实际的命令行参数提供给命令。您创建了一个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);
ChangesCmdOptions changeListOptions=新的ChangesCmdOptions(ChangesCmdFlags.FullDescription | ChangesCmdFlags.IncludeTime,null,0,ChangeListStatus.None,null);
FileSpec[]fileSpecs=newfilespec[1]{newfilespec(new-DepotPath(“//depot/…@2016/12/05 21:57:30,@now”),null,null,null)};
IList changes=m_Repository.GetChangelists(changeListOptions,fileSpecs);

所有这些对于使用API一段时间的人来说可能是“放纵的微笑”的老新闻。这篇文章中提到的两个页面(“FileSpec对象文档”、“SyncFiles方法文档”)现在处于脱机状态,这让新手感到有点困惑:

这是performe文档中您真正想要使用的非命令行版本(一旦找到它:)

PathSpec path=new DepotPath(“//depot/…”);
DateTimeVersion lowerTimeStamp=新的DateTimeVersion(新的DateTime(2016,12,06));
DateTimeVersion upperTimeStamp=新的DateTimeVersion(DateTime.Now);
VersionSpec version=新版本范围(lowerTimeStamp,upperTimeStamp);
FileSpec[]FileSpec={newfilespec(路径,版本)};
ChangesCmdOptions changeListOptions=新的ChangesCmdOptions(ChangesCmdFlags.FullDescription | ChangesCmdFlags.IncludeTime,null,0,ChangeListStatus.None,null);
IList changes=m_Repository.GetChangelists(changeListOptions,fileSpecs);

现在还不能将此标记为正确答案。我希望能从真正了解API的人那里得到一些信息。这种方法效果最好,因为在时间范围内你不会遇到任何bug。如果你想要一个更干净的方法,并且不关心时间戳(仅限日期范围),请使用另一种方法。这是官方正确的方法,但是-我无法让它用于时间戳。返回的列表包含指定日期范围内的所有CLs,但忽略时间戳。
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);