c# - 如何将文件签出到默认更改列表?
问题描述
这是我想将文件签出到默认更改列表的代码。
但我不知道我的默认 changlist ID。我怎么才能得到它?
string command = "-c";
string f = filePath;
cmd = new P4Command(p4, "add", true, command, changelist.Id.ToString(), "-f", f);
rslt = cmd.Run();
f = filePath.Replace("@", "%40");
cmd = new P4Command(p4, "edit", true, command, changelist.Id.ToString(), f);
rslt = cmd.Run();
cmd = new P4Command(p4, "reopen", true, command, changelist.Id.ToString(), f);
rslt = cmd.Run();
解决方案
无需使事情过于复杂——它被称为“默认值”,因为当您不指定更改列表时,它实际上是默认值。“默认变更列表”并不是真正的变更列表;它只是在您的客户端上打开的不属于编号更改列表的文件的集合。
C:\Perforce\test>p4 edit foo
//stream/main/foo#4 - opened for edit
C:\Perforce\test>p4 opened
//stream/main/foo#4 - edit default change (text)
我认为就您的代码而言,这是:
cmd = new P4Command(p4, "edit", true, f);
rslt = cmd.Run();
只需去掉“-c”(代表“更改列表”)和更改列表编号即可。
如果您需要将文件从编号更改中移出并进入默认更改,您可以使用reopen
如下所述的命令p4 help reopen
:
reopen -- Change the filetype of an open file or move it to
another changelist
p4 reopen [-c changelist#] [-t filetype] file ...
...
The target changelist must exist; you cannot create a changelist by
reopening a file. To move a file to the default changelist, use
'p4 reopen -c default'.
推荐阅读
- reactjs - 你可能需要一个合适的加载器来处理这种文件类型,使用 Webpack
- python-3.x - 如何使用高级布尔索引在 numpy 中分配值?
- python - 几个基本的python日志问题
- python - 显示多张图片
- docker - CMD java -version &> /staf-logs/output.log 和 docker 中的 CMD ["java -version &> /staf-logs/output.log"] 有什么区别
- java - Android Studio - 自定义 Listview EditText 值不存储
- go - type 关键字在 go 中(确切地)做了什么?
- javascript - 提供给`Calendar`的`String`类型的无效道具`selected`,预期的`Date`实例?
- android - Firebase - 排除一些屏幕进行跟踪
- vbscript - 如何单击 webtable 单元格中的按钮