I would like to know if there is a way to use p4 Submit with comments contained in a comment file.
i.e p4 Submit "Comment File.txt" fileName
Thanks
You can use the -i option to read the changelist spec (including the comment) from a file or stdin. Something like
mumblemumble.pl > changelistspec.txt
p4 submit -i < changelistspec.txt
The format of the changlelistspec.txt is the same as the file that pops up when you run p4 submit interactively. Use
p4 submit -d
to view the changelistspec. Your script or whatever needs to output in that format.
You can load the contents of the comment file into an environment variable and then pass that to the submit command.
set /p p4description=<"Comment File.txt"
p4 submit -d "%p4description%"
::you can then get rid of that environment variable...
set p4description=
Related
I've created CL#100 with some description and shelved some files.
Now I need to edit the description of that CL using a command.
I have tried these 2 ways and both failed (same error msg)
p4 change -u 100 "Description: test description edit"
p4 change -o 100 > myDes.txt >> Edit Description field in myDes.txt >> p4 change -u 100 < myDes.txt
Error:
Execution Failed: "'C:
Program" "C:\Users\iman\AppData\Local\Temp\t26660t63.tmp": The system cannot find the file specified.
Client side operation(s) failed. Command aborted.
Edited File C:\Users\iman\AppData\Local\Temp\t26660t63.tmp kept due to errors.
It sounds like your P4EDITOR is set to "C:\Program", which is making p4 unable to launch an editor. This will cause problems for any command which edits a spec, not just p4 change commands! Do:
p4 set P4EDITOR=notepad
to set your editor to notepad (the default on Windows).
Then you should be able to run:
p4 change 100
The -u flag isn't needed for the update since this is a pending changelist (you can freely edit your pending changelists by default). The description is not specified on the command line; it's part of the spec that you'll edit in the editor.
If for some reason you need to do this without an editor (e.g. you're writing a script), you need to use -o to output to stdout and -i to input from stdin. I recommend using --field to modify the field instead of writing your own script to parse the changelist spec:
p4 --field "Description=test description edit" change -o 100 | p4 change -i
I am new to Perforce. Here's the problem:
$ p4 submit
Change 9 created with 1 open file(s)
Submitting change 9.
Locking 1 files ...
Submit validation failed -- fix problems then use 'p4 submit -c 9'.
The problem is that the description that I entered into the submit form was bad. How do I change it?
I checked the docs for p4 submit, and didn't understand what -i does. Maybe that's what I need.
I tried:
$ p4 submit -i "Better description" -c 9 filename
and got:
Usage: submit [ -i -s -r ] [ -c changelist# ] [file]
Missing/wrong number of arguments
Thanks!
Even if the changelist is already submitted you can change the description with
p4 change -u 9
Since this is a pending changelist, and since it doesn't sound like you need to do this from a script, just do:
p4 change 9
This will bring up the changelist form in an editor so you can edit it. Make the edits, save the file, then exit the editor. Then do:
p4 submit -c 9
You may already know this, but the "validation failed" message means that your Perforce admin has some kind of custom trigger set up that blocked the submit -- the trigger could be doing literally anything, so if it keeps failing you may need to check with your admin to see what you're supposed to be doing (and whether the trigger is behaving correctly).
If you were editing the changelist form from a script you would use the "-i" flag as follows:
p4 change -o 9 | sed -e "s/magic/regex/" | p4 change -i
p4 submit -c 9
but obviously as an end user it's easier to just do "p4 change 9" and use the editor than to write a shell script to edit the description for you.
With a newer Perforce server you can specify the description during submit with:
p4 submit -d "Better description"
but since the "-d" flag isn't listed in your usage message I'm guessing you're using an old version.
in History tab, right click on your entry, "view changelist", then "edit", modify your description and "ok"
The command "p4 change" prompts a editor and needs a form. But I want to do this in command line.
How can I achieve this?
Use the following command:
p4 change -u CL_number
For details, please visit this page.
This command line worked for me:
p4 --field Description="New CL description here" change -o *changelist_number* | p4 change -i
There's always the -i command:
Read a changelist description from standard input. Input must be in the same format used by the p4 change form.
As Bryan points out in his comment the best approach is probably to run change -o, redirect the output to a file, process the file with other shell commands, and then send that file back to the server with change -i.
Source
But you can always change the description when you submit:
p4 submit -d "description"
This only works on the default change list.
Source
I have a p4 client workspace on Linux machine.
I added/edited few files in my client space and then tried to submit those changes to perforce server.
I followed the steps below but could not succeed:
p4 submit -d "test" (the same command works on a Windows machine)
when I tried it with just p4 submit then it opened a p4 submit form and then I replaced [enter description here] token with the proper description and then it works.
But I don't want to edit the p4 submit form for every p4 submit task.
How can I pass this info in from the command prompt?
Answer
-d flag support for p4 submit command was not introduced in
perforce 2006 version. so here is the workaround for this problem:
To modify the description field on pre-2006.2 release Perforce Servers, try
piping the change form in/out of a stream editor. This will create a numbered
changelist, which should then be submitted.
For example, something like:
p4 change -o | sed -e "s/<enter description here>/my desc/" | p4 change -i
Which gives the output, similar to:
Change 102 created with 3 open file(s).
This change (number 102 in this case) can then be submitted, as follows:
p4 submit -c 102
It's not just the description you need to enter, you also can edit the changelist specification which allows you to exclude files from the commit.
If you can do it on windows then perhaps there is a newer client on windows than what you're using on Linux?
From http://www.perforce.com/perforce/downloads/platform.html download the appropriate version of p4 command-line client. Then:
Replace the existing p4 executable with the new one.
Or put the new p4 exe in a directory earlier in your $PATH
Make the chmod 755 <new p4>
hash -r
p4 -V to verify you are running perforce 2009.1 client
p4 help submit
We can md5sum the p4 binary
p4 info and verify the perforce server is 2006.2 or more recent.
Step 5 should produce:
$ p4 -V
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2009 Perforce Software. All rights reserved.
Rev. P4/LINUX26X86/2009.1/205670 (2009/06/29).
Step 6 should produce:
$ p4 help submit
submit -- Submit open files to the depot
p4 submit [ -r -s -f option ]
p4 submit [ -r -s -f option ] files
p4 submit [ -r -f option ] -d description
p4 submit [ -r -f option ] -d description files
p4 submit [ -r -f option ] -c changelist#
p4 submit -i [ -r -s -f option ]
'p4 submit' commits a pending changelist and its files to the depot.
With no argument 'p4 submit' attempts to submit all files in the
'default' changelist. Submit provides the user with a dialog
similar to 'p4 change' so the user can compose a changelist
description. In this dialog the user is presented with the list
of files open in changelist 'default'. Files may be deleted from
this list but they cannot be added. (Use an open command (edit,
add, delete) to add additional files to a changelist.)
If a (single) file pattern is given, only those files in
the 'default' changelist that match the pattern will be submitted.
The -c flag submits the numbered pending changelist that has been
previously created with 'p4 change' or a failed 'p4 submit'.
The -d flag allows a description to be passed into submit rather
than using a numbered changelist or engaging in a change description
dialog. This option is useful when scripting but does not allow for
jobs to be added or the default changelist to be modified.
The -f flag allows a submit option to be passed into submit which
will override the one that is set in the client. See 'p4 help client'
for valid submit options.
The -i flag causes a changelist specification (including files to be
submitted) to be read from the standard input. The user's editor
is not invoked.
The -r flag allows submitted files to remain open (on the client's
default changelist) after the submit has completed.
The -s flag extends the list of jobs to include the fix status
for each job, which becomes the job's status when the changelist
is committed. See 'p4 help change' for more notes on this option.
Before committing a changelist submit locks all associated files not
already locked. If any file cannot be locked, or if the submit
fails for any other reason the files are left open in a newly
created pending changelist.
Submit is guaranteed to be atomic. Either all files will be
updated in the depot as a unit or none will be.
Of which the important bit is:
The -d flag allows a description to be passed into submit rather
than using a numbered changelist or engaging in a change description
dialog. This option is useful when scripting but does not allow for
jobs to be added or the default changelist to be modified.
Step 7:
$ md5sum $(which p4)
bef01f66b8d3964c74a2d8992c0c900c /opt/perforce/bin/p4
Step 8:
The feature was introduced in perforce 2006.2, and it's possible that it requires a sufficiently recent server to support the operation:
#106450 (Bug #258) **
'p4 submit' now sports a '-d description' option. This allows
the user to submit files without the need for a changelist
dialog. See 'p4 help submit'.
I have a list of about 600 jobs that I can't delete from the command line because they are attached to changelists. The only way I know how to detach them is via the GUI, but that would take forever. Does anyone know a better (i.e., faster) way?
I figured it out using the "fix" and "fixes" commands. Here's the procedure:
Dump the output of the "fixes" command to a file
p4 fixes > tmp.txt
The file will contain a bunch of lines like this:
job005519 fixed by change 3177 on 2007/11/06 by raven#raven1 (closed)
job005552 fixed by change 3320 on 2007/12/11 by raven#raven1 (closed)
job005552 fixed by change 3318 on 2007/12/10 by raven#raven1 (closed)
...
Use your trusty text editor (and I'm not talking about Notepad here) to whip up a macro that converts the lines to Perforce commands to detach jobs from changelists, (p4 fix -d):
p4 fix -d -c 3177 job005519
p4 fix -d -c 3320 job005552
p4 fix -d -c 3318 job005552
...
Save the file as a .bat or .cmd file and run it, and bada bing, bada boom... all your jobs are detached from changelists and you can delete them using the GUI, or with a procedure similar to the one I just outlined and the output of the "jobs" command:
p4 jobs > tmp.txt
Perforce's -x argument is very handy; it "instructs p4 to read arguments, one per line, from the named file [or] standard input". Also, I believe "job -d" allows jobs to be deleted even when they are associated with changes. So, to delete all jobs associated with a changelist, do something like this (untested):
p4 fixes -c <changenum> | p4 -x - job -d
You can use the following DOS script to parse the output from p4 fixes and then delete the fixes and jobs:
set users_filename=%1
for /F "tokens=1,5 delims= " %%i in (%users_filename%) do (
p4 fix -d -c %%j %%i
p4 job -d %%i
)