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?
views:
208answers:
3I 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
)