Perforce pending changelist diff script

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).