Compare files using diff
You can compare file revisions using the diff tool associated with P4 for Visual Studio. The default diff tool is P4 Merge, which is included with P4V. To associate a different diff tool, go to Tools > Options > Source Control > P4 - Diff/Merge. To learn more, see Set P4 for Visual Studio preferences.
To diff two files or file revisions:
-
In the Solution Explorer, Submitted tool window, Submit Changelist dialog, Submitted Changelist dialog, Pending tool window, or Pending Changelists dialog, right-click the file whose revisions you want to diff.
You can also diff two file revisions from the File History tool window by dragging one revision row onto another.
-
Select one of the following:
- Diff > Diff Against…​: compare any two files or revisions of a file.
- Diff > Diff Against Have Revision: compare the file version in your workspace against the depot revision that you retrieved most recently. This selection opens P4 Merge (or your preferred diff tool, if it is not P4 Merge) without first opening the Diff dialog.
- Diff Against Previous Revision (from Submitted tool window only): compare the revision you selected against the version in the previous changelist. This selection opens P4 Merge (or your preferred diff tool, if it is not P4 Merge) without first opening the Diff dialog.
-
In the Diff dialog, specify the revisions of the files you want to diff:
- Path: the two files you want to diff. If you choose Workspace version on local disk, you can ensure that all files in the workspace (including files within the client mapping that are not under P4 Server control) are displayed by using local syntax. To display only files under P4 Server control, use depot syntax
- Workspace version on local disk: the file revision in your client workspace, including any changes you made after retrieving it from the depot and editing it.
- Latest revision: the revision that was most recently submitted to the depot (the head revision).
- Have revision: the revision you most recently retrieved. Does not include any edits you made after retrieving it from the depot.
- Specify revision: enables you to designate the desired revision using a revision number, changelist number, date, label, or workspace.
- Click Diff. P4 for Visual Studio launches P4 Merge (or your preferred diff tool, if it is not P4 Merge), displaying the differences between the files at the specified revision.
To learn more about diffing files with P4 Merge, see the P4 Merge help.