如何将文件签出到默认更改列表?

How to Checkout file to Default ChangeList?

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

但我不知道我的默认更改列表 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();

我想我找到了答案。不要输入 changeId ,只需输入关键字: "default" 像这样。

string command = "-c";
cmd = new P4Command(p4, "add", true, command, "default", "-f", f);
cmd = new P4Command(p4, "edit", true, command, "default", f);
cmd = new P4Command(p4, "reopen", true, command, "default", f);

无需使事情过于复杂——它被称为 "default" 因为当您不指定更改列表时它实际上是默认设置。 "default changelist" 并不是真正的变更列表;它只是在您的客户端上打开的一组文件,这些文件还不属于编号的更改列表。

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”(代表 "changelist")和更改列表编号。

如果您需要将文件从编号更改中移出并移到默认更改中,您可以使用 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'.