首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Perforce P4API.NET Repository.GetDepotFiles()返回已删除的文件

Perforce P4API.NET Repository.GetDepotFiles()返回已删除的文件
EN

Stack Overflow用户
提问于 2012-10-31 08:16:31
回答 1查看 1.9K关注 0票数 3

我使用了Perforce Repository.GetDepotFiles(),并注意到该函数返回匹配搜索模式的文件,但也返回已在Perforce Depot中删除的文件。如何过滤搜索以排除已删除的文件?

我在Depot中执行文件搜索的代码:

代码语言:javascript
复制
IList<FileSpec> filesToFind = new List<FileSpec>();
FileSpec fileToFind = new FileSpec(new DepotPath("//depot/....cpp"), null, null, VersionSpec.Head);
filesToFind.Add(fileToFind);
IList<FileSpec> filesFound = pRep.GetDepotFiles(filesToFind, null);
EN

回答 1

Stack Overflow用户

发布于 2014-02-08 21:40:16

使用命令行p4.exe,您可以获得未删除文件的列表,如下所示:

代码语言:javascript
复制
  p4 files -e //depot/....cpp

命令p4 files支持两个不同的标志,比如'-A‘和'-a’。以下是p4api.net.dll支持的:

代码语言:javascript
复制
  Options options = new FilesCmdOptions(FilesCmdFlags.AllRevisions, maxItems: 10);
  IList<FileSpec> filesFound = rep.GetDepotFiles(filesToFind, options);

FilesCmdFlags.AllRevisions对应于'-a‘标志( FilesCmdFlags.IncludeArchives是'-A')。不幸的是,p4api.net.dll似乎不支持'-e‘。

但是,使用P4Command有一种变通方法:

代码语言:javascript
复制
  var cmd = new P4Command(rep, "files", true);
  StringList args = new StringList(new[] { "-e", "//depot/....cpp" });
  P4CommandResult result = cmd.Run(args);

  IEnumerable<FileSpec> foundFiles =
    result.TaggedOutput.Select(o => 
      new FileSpec(new DepotPath(o["depotFile"]),
                   null,
                   null,
                   VersionSpec.None));

  foreach (FileSpec file in foundFiles)
    Console.WriteLine("Found {0}", file.DepotPath);

我使用的是2013.3.78.1524版的p4net.api.dll。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13149481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档