尝试使用 p4api.net 方法中的 -a 选项还原更改列表中的文件。它曾经对我有用,但现在出现以下消息异常。
p4 edit 和 p4 revert with -c 选项也可以正常工作,但 p4 revert with -a 选项会引发以下异常。我不知道为什么它在 p4 工作区位置的测试项目位置下方选择。
例外:
路径 'd:\cftt\Dev\source\BRF\BRF.Business.Test\bin\Debug\19402547' 不在客户端的根目录 'D:\p4' 下。
// to open files for edit in a given changelist at certain loc with particular file format
public IList<FileSpec> EditChangeList(string clNumber, string fileFormat, string destinationPath)
{
try
{
var rep = Connect();
var opts = new Options(ChangeCmdFlags.None, ChangeListType.None);
opts["-c"] = clNumber;
var fs = new FileSpec(new DepotPath(destinationPath + "/..." + fileFormat));
IList<FileSpec> editedFileSpec = rep.Connection.Client.EditFiles(new List<FileSpec> {fs}, opts);
return editedFileSpec;
}
catch (Exception exc)
{
Logger.LogError(exc.Message);
throw;
}
}
// to revert files in a changelist that are unchanged using -a option
public IList<FileSpec> RevertChangeList(string clNumber, string destinationPath)
{
try
{
var rep = Connect();
var opts = new Options(ChangeCmdFlags.None, ChangeListType.None);
opts["-a"] = clNumber;
var fs = new FileSpec(new DepotPath(destinationPath + "/..."));
IList<FileSpec> revertedFiles = rep.Connection.Client.RevertFiles(new List<FileSpec> {fs}, opts);
return revertedFiles;
}
catch (Exception exc)
{
Logger.LogError(exc.Message);
throw;
}
}