我使用了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);发布于 2014-02-08 21:40:16
使用命令行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);我使用的是2013.3.78.1524版的p4net.api.dll。
https://stackoverflow.com/questions/13149481
复制相似问题