daveg
daveg

Reputation: 1211

How can I compare a file in a perforce workarea to it's unaltered counterpart in the depot?

Server version: P4D/LINUX26X86_64/2018.2/1975995 (2020/06/25)
Proxy version: P4P/LINUX26X86_64/2018.2/1975995 (2020/06/25)
Broker version: P4BROKER/LINUX26X86_64/2010.2/279478

After I sync a perforce workarea to head, I 'p4 edit' a file, then manually edit the file in my workarea using my favorite text editor. Over time, other users submit changes, so I am no longer synched to the head. And I may save and re-edit the file in my workarea. Now, I want to compare my edited version of the file to the version that I synched to (which is no longer head).

I'm OK with doing a 'p4 print' of the file (with, I'm assuming, a version specifier) in the P4 depot, then comparing my edited file with that outside of p4 commands. Using one of the p4 diff commands isn't really what I want to do because the file is an xml file for which I wrote a perl script which will compare content in an order agnostic way.

I think the missing piece here is getting a handle on the P4 version of the file that my WA is synched to so that I can p4 print it out and then compare. Not sure how to do that. I'm also open to other suggestions, but remember the comparison will eventually be done by my perl script which does simple file open commands.

Upvotes: 0

Views: 632

Answers (1)

Samwise
Samwise

Reputation: 71582

Set P4DIFF to point to your perl script (which needs to take the two local files as arguments) and run p4 diff. The p4 diff command does all the work of "printing" the depot file to a local temp file, invoking the diff tool (specified by P4DIFF), and cleaning up the temp file.

Upvotes: 1

Related Questions