Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perforce pending changelist diff script

Does someone have such a script to share?

  • takes a pending changelist number as input
  • outputs a unified diff (including files open for add)

I know from experience many people who work with perforce all day have these kicking around. I could really use help with the whole issue of "file(s) not in client view" when diffing newly added files via "p4 diff".

like image 406
user675801 Avatar asked Mar 09 '12 00:03

user675801


1 Answers

I didn't have the time to find a proper solution so I used this one liner:

p4 describe $CHANGELIST | sed -ne 's:^\.\.\. \(.*\)#[0-9][0-9]* [a-z][a-z]*$:\1:p' | xargs p4 diff -du

Here is how it works:

Since --

... Pending changelists are indicated as 'pending' and file diffs are not displayed.

p4 describe $CHANGELIST

by itself will not do, but you can use it as a starting point. It gets (among other things) a list of the files that was changed in your $CHANGELIST.

sed -ne 's:^\.\.\. \(.*\)#[0-9][0-9]* [a-z][a-z]*$:\1:p'

Prints the <depot-file> part of only the lines of the form ... <depot-file>#<revision> <action>

xargs p4 diff -du

Takes the list of depot files and run p4 diff -du on it. The -d flag passes u (unified format) to your $P4DIFF program (that should be diff).

like image 148
Chen Levy Avatar answered Oct 20 '22 12:10

Chen Levy