views:

688

answers:

5

I wish to submit a changelist with multiple filespecs, e.g. ...this... ...file.h ...theother.... Perforce won't let me. I could create a changelist from a file but I do want a chance to review the files and enter the comment. This is for a command-line solution.

+2  A: 

You can create a pending changelist, then move all the files you want into that, before submitting it. Even from the command-line, although I find p4V easier to use for this functionality.

http://www.perforce.com/perforce/doc.current/manuals/cmdref/change.html#1040665

p4 change

to create a pending changelist.

p4 reopen

to move files into the pending changelist.

Douglas Leeder
Unfortunately p4 change opens up the editor.
Brian Carlton
`p4 change -o` and `p4 change -i` would be required in order to avoid using an editor -
Douglas Leeder
A: 

Type

p4 submit

If your P4EDITOR is vim, then you will get a vim edit window. Goto command mode and select all the lines after the line "Files:" by typing

v followed by PgDown until you're done selecting all the files

Then do

:g!/.*pattern1.*#/d

If you have multiple patterns like this,

:g!/.*pattern1.*#\|.*pattern2.*#\|.*pattern3.*#/d etc...

Hope this helps!

Viswanadh
I am looking for a command line implementation for use in scripts.
Brian Carlton
+2  A: 

This is an endlessly frustrating problem. You should be able to create a p4 changelist from the Windows command line without invoking the editor by doing:

p4 change -o | findstr /C:Description: /C:Change: /C:Client: /C:User: /C:Status: | p4 change -i

The return string will be something like "Change 1500 created." which you can parse for the changelist. You could then add individual filespecs by doing:

p4 edit -c 1500 //depot/base/...files.c

Or something along those line. The relatively significant problem with this solution is the inability to modify the description. Alternatively, you can create a temp file with the requisite Description, Change, Client, etc strings and create the changelist via:

p4 change -i < tempfile.txt

This seems somewhat sloppier but may be the best alternative for scripting solutions.

Michael Gilbert
+1  A: 

Based on Michael Gilbert's answer, you can edit the description in powershell like so:

$newCLFormat = p4 change -o | select-string -pattern change, client, status
$newCLFormat += "Description: " + $myDescription
$newCLFormat | p4 change -i

To pull out the new changelist number:

$newCLFormat | p4 change -i | select-string "\b(\d)+" | %{$_.matches[0].value}

Now there's got to be a quicker, neater way to pull out that number?

edit: refactored findstr to select-string

tenpn
+2  A: 

If you're looking for a UNIX/*NIX command line solution, this will give you a new, clean changelist and keep the number in $cl:

export cl=`p4 change -o | grep '^\(Change\|Client\|User\|Description\)' | p4 change -i | cut -d ' ' -f 2`
Martin Probst