[英]Perforce P4API.NET Repository.GetDepotFiles() returns deleted files
I used the Perforce Repository.GetDepotFiles() and noticed that the function returns files that match the search pattern but also returns files that have been deleted in the Perforce Depot. 我使用Perforce Repository.GetDepotFiles()并注意到该函数返回与搜索模式匹配的文件,但也返回Perforce Depot中已删除的文件。 How do I filter out the search to exclude deleted files?
如何过滤搜索以排除已删除的文件?
My code to do file search in 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);
Using the command-line p4.exe you can get a list of non-deleted files like this: 使用命令行p4.exe,您可以获得未删除文件的列表,如下所示:
p4 files -e //depot/....cpp
The command p4 files
supports a couple of different flags, like '-a' and '-A'. 命令
p4 files
支持几个不同的标志,如'-a'和'-A'。 These are supported by p4api.net.dll: 这些是由p4api.net.dll支持的:
Options options = new FilesCmdOptions(FilesCmdFlags.AllRevisions, maxItems: 10);
IList<FileSpec> filesFound = rep.GetDepotFiles(filesToFind, options);
FilesCmdFlags.AllRevisions
corresponds to the '-a' flag (and FilesCmdFlags.IncludeArchives
is '-A'). FilesCmdFlags.AllRevisions
对应于'-a'标志(而FilesCmdFlags.IncludeArchives
是'-A')。 Unfortunately it seems that '-e' is not supported by p4api.net.dll. 不幸的是,似乎p4api.net.dll不支持'-e'。
There is however a workaround using P4Command: 但是有一个使用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);
I'm using p4net.api.dll version 2013.3.78.1524. 我正在使用p4net.api.dll版本2013.3.78.1524。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.