首页 > 解决方案 > 如何将文件签出到默认更改列表?

问题描述

这是我想将文件签出到默认更改列表的代码。

但我不知道我的默认 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#perforcep4api.net

解决方案


无需使事情过于复杂——它被称为“默认值”,因为当您不指定更改列表时,它实际上是默认值。“默认变更列表”并不是真正的变更列表;它只是在您的客户端上打开的不属于编号更改列表的文件的集合。

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'.

推荐阅读