Reputation: 2417
Here is my code I want to check out file to default changelist.
But I don't know my default changlist ID. How can I get it?
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();
Upvotes: 1
Views: 1375
Reputation: 71517
No need to overcomplicate things -- it's called the "default" because it's literally the default when you don't specify a changelist. The "default changelist" isn't really a changelist; it's just a collection of files open on your client that don't belong to a numbered changelist yet.
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)
I think in terms of your code this is:
cmd = new P4Command(p4, "edit", true, f);
rslt = cmd.Run();
Just leave off the "-c" (which stands for "changelist") and the changelist number.
If you need to move a file out of a numbered change and into the default change you can use the reopen
command as described in 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'.
Upvotes: 2
Reputation: 2417
I think I found answer. dont input changeId , just input keyword : "default" like this.
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);
Upvotes: 0