我将通过 perforce API 同步 perforce 文件。我期望每个文件操作的输出。类似于我们看到的 p4 cmd 的输出:
- //depot/file.txt#1 -更新X:\file.txt
- //depot/file.txt#2 -删除为X:\file.txt
这是我用于同步文件的 perforce api 代码:
var repository = new P4.Repository(new P4.Server(new P4.ServerAddress("server:111111")));
repository.Connection.UserName = "me";
repository.Connection.Connect(new P4.Options());
repository.Connection.Login("password");
repository.Connection.Client = repository.GetClient("client");
var syncFlags = new P4.Options(P4.SyncFilesCmdFlags.Force, 100);
var clientPath = new P4.ClientPath(@"X:\File.txt");
IList<P4.FileSpec> results = repository.Connection.Client.SyncFiles(syncFlags, new[] { new P4.FileSpec(clientPath, new P4.Revision(1)) });
P4.VersionSpec downloadedVersion = results.First().Version; // This is #1 as expected
results = repository.Connection.Client.SyncFiles(syncFlags, new[] { new P4.FileSpec(clientPath, new P4.Revision(2)) });
downloadedVersion = results.First().Version; // This is #2 as expected
results = repository.Connection.Client.SyncFiles(syncFlags, new[] { new P4.FileSpec(clientPath, new P4.Revision(0)) });
downloadedVersion = results.First().Version; // File is really deleted and I hoped for #0, but it's #2!
如何获取文件被删除的信息?我尝试为此使用 SyncFiles 输出,但已删除文件的信息不正确。还有其他方法吗?