Perforce p4还原文件不使用-使用p4api.net方法的选项
尝试使用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”下Perforce p4还原文件不使用-使用p4api.net方法的选项,perforce,p4v,p4api.net,Perforce,P4v,P4api.net,尝试使用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
// 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;
}
}
//以特定文件格式在特定位置打开给定变更列表中的文件进行编辑
公共IList EditChangeList(字符串clNumber、字符串文件格式、字符串destinationPath)
{
尝试
{
var rep=Connect();
var opts=新选项(ChangeCmdFlags.None、ChangeListType.None);
opts[“-c”]=clNumber;
var fs=new FileSpec(新的DepotPath(destinationPath+“/…”+fileFormat));
IList editedFileSpec=rep.Connection.Client.EditFiles(新列表{fs},opts);
返回editedFileSpec;
}
捕获(异常exc)
{
Logger.LogError(exc.Message);
投
}
}
//使用-a选项还原更改列表中未更改的文件
公共IList RevertChangeList(字符串clNumber,字符串destinationPath)
{
尝试
{
var rep=Connect();
var opts=新选项(ChangeCmdFlags.None、ChangeListType.None);
opts[“-a”]=clNumber;
var fs=new FileSpec(新的DepotPath(destinationPath+“/…”);
IList revertedFiles=rep.Connection.Client.RevertFiles(新列表{fs},opts);
返回还原文件;
}
捕获(异常exc)
{
Logger.LogError(exc.Message);
投
}
}
revert命令采用几种不同类型的标志和参数:
- 像-a、-n和-w这样的标志,它们没有任何值,但只是标志
- -c标志,它将变更列表编号作为标志的值
- 要还原的文件,在所有标志之后指定为参数(可以指定多个文件参数)
p4 revert -a 19402547 d:\p4\sw\dev\gpu_drv\chips_a\diag\mods\sim\resources/...
由于-a标志不接受值,revert命令将其视为:
- 国旗
- 文件参数:19402547
- 文件参数:d:\p4\sw\dev\gpu\u drv\chips\u a\diag\mods\sim\resources/
p4 revert -a d:\p4\sw\dev\gpu_drv\chips_a\diag\mods\sim\resources/...
及
是合理的命令,选择正确的命令取决于您想要的行为。destinationPath的值是多少?是否为“d:\cftt\Dev\source\BRF\BRF.Business.Test\bin\Debug\19402547”?@Bryan否,目标路径的值是性能工作区位置,即“d:\\p4\\sw\\Dev\\gpu\drv\\chips\u a\\diag\\mods\\sim\\resources”它在revertedFiles行出现异常,即路径“d:\cftt\Dev\source\BRF\BRF.Business.Test\bin\Debug\19402547”不在客户端的根目录“d:\p4”下。d:\cftt\Dev\source\BRF\BRF.Business.Test\bin\Debug->这是从我开始单元测试到测试端到端流的测试项目位置。不知道为什么它会在测试项目位置追加变更列表号,理想情况下它应该追加到perforce workspace位置。我只想还原给定变更列表中sim/resources目录中仍然不变的文件。这就是为什么我使用-一个标志,它对我来说很有效,比如说15-20天以前,它具有相同的功能。使用-a的原因是我需要发送/使用变更列表,其中只包含实际更新的文件,并放弃在该变更列表中保持不变的“打开以编辑文件”。在这种情况下,请同时指定-a和-c,并将变更列表编号作为-c标志的值提供,而不是作为-a标志的值提供(正如我上面解释的,-a标志没有关联的值。)非常感谢,Bryan.Awesome,它起作用了。opts[“-a”]=”;var fs=new FileSpec(new DepotPath(destinationPath+“/…”);IList revertedFiles=rep.Connection.Client.RevertFiles(new List{fs},opts);另外,我注意到我的项目中p4api.net dll中有一个更新,p4api.net的早期版本可以与opts[“-a”]=clNumber配合使用,而它与最新版本的p4api.net(opts[“-a”]=clNumber;)不配合使用。因此,根据您的建议,对于最新版本的p4api.net,我必须尝试使用opts[“-a”]=;没有标记-a的值,它工作了。为什么行为会发生变化?这是故意从p4api.net执行的还是错误?抱歉,我不知道为什么行为会发生变化。
p4 revert -a -c 19402547 d:\p4\sw\dev\gpu_drv\chips_a\diag\mods\sim\resources/...