tags:

views:

324

answers:

2

Suppose you open a file for branch to another place (without submitting), and then reopen it for add and make some edits. I would like to diff this edited version against its branch source in a script.

p4 diff2 is no good because one of the versions is in the client.

p4 diff is no good because it can only diff against the "corresponding" version of the file in the depot, which a branched unsubmitted file doesn't have yet.

Is there a way, or is the only option to just grab the two files and diff them using a third-party tool?

+4  A: 

Sadly, you're on the money here, you'd need to use a third party diff tool to do this because, as you rightly pointed out, until you've submitted the initial integration to the depot, it doesn't have a copy against which to diff. If you go down this route you'd obviously not be able to access files directly in the depot though, you'd need to have both files on the client PC and specify their paths explicity.

ninesided
Thanks for confirming this... was hoping I missed something obvious, but sadly not in this case.
romkyns
A: 

ninesided is correct that you need to have both files on the client PC.

But there are shortcuts:

If you're using P4V, choose "Diff Against..." from the context or Tools menu. For 1st Path, choose the old location and select "Latest Revision'. For 2nd path, choose the new location and select "Workspace revision on local disk".

The work of selecting the paths can be made easier if you can get both files to appear in the same pane and Ctrl-click to multi-select. e.g. use the Workspace tree pane or open the source file for edit temporarily in order to get it listed in the Pending files pane.

P4V accomplishes this by running 'p4 print -o' on the depot file to create a temporary file on the client PC, then passing that temporary file to the diff application. If you need a textual diff, you can either configure P4V to run a textual diffing application, or run p4 print -o and diff yourself.

Timbo
Thanks for your efforts, but I'm not using P4V - as the question mentions (in the title and body) I need to run this from a script. I've settled on the manual solution of grabbing the two files and calling an external tool - the diffs are slightly different to p4 diffs but this is acceptable.
romkyns