[英]Perforce P4API.NET Repository.GetDepotFiles() returns deleted files
我使用Perforce Repository.GetDepotFiles()并注意到该函数返回与搜索模式匹配的文件,但也返回Perforce Depot中已删除的文件。 如何过滤搜索以排除已删除的文件?
我在Depot中进行文件搜索的代码:
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);
使用命令行p4.exe,您可以获得未删除文件的列表,如下所示:
p4 files -e //depot/....cpp
命令p4 files
支持几个不同的标志,如'-a'和'-A'。 这些是由p4api.net.dll支持的:
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的解决方法:
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);
我正在使用p4net.api.dll版本2013.3.78.1524。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.