Diffing files and folders

To diff two files or file versions:

  1. In the depot pane, select the two files you want to diff.

    You can also select just one of the files, right-click it, and choose Diff against…​ to open the Diff dialog, where you can specify the file or file version you want to diff against.

  2. Right-click and choose Diff…​.

    The Diff dialog is displayed.

  3. Specify the revisions of the files you want to diff and click Diff.

    P4V launches P4Merge, displaying the differences between the files at the specified revision.

    Shortcut: drag the first file to the second file and drop it.

To diff two folders:

  1. In the depot pane, select the two folders you want to diff.
  2. Right-click and choose Diff…​.

    The Diff dialog is displayed

  3. Specify the revisions of the folders you want to diff and click Diff.

    P4V launches the Folder Diff Utility, displaying the differences between the folders at the specified revision.

    The resulting display is based on your current client view. In the case of added and deleted files, the folder diff utility displays the location where the files would reside if they existed.

    Alternative: you can right-click one folder, select Diff Against…​, and select the folder you want to diff against in the Diff dialog.

To diff two folder revisions:

  1. Right-click the folder and choose Folder History.
  2. In the Folder History pane, click and drag one revision to the other.

    P4V launches the Folder Diff Utility.

    Alternative: you can right-click the folder, select Diff Against…​, and select the folder revisions you want to diff in the Diff dialog.

To diff two labels:

  1. In the depot pane, select the topmost meaningful path.
  2. Right-click and choose Diff…​. The Diff dialog is displayed.
  3. For each of the two Path fields, click Specify revision and specify the labels you want to diff.
  4. Click Diff. The folder diff utility displays the differences between the labels.

    Shortcut: To launch a diff from the Labels pane, drag onelabel to another.

Diff dialog options

  • Path: the two folders or 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 Helix Server control) are displayed by using local syntax. To display only files under Helix 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.

Check workspace consistency

If you need to reconcile your workspace after working offline, see Reconciling offline work.

To detect common inconsistencies between the files in your workspace and those in the depot, you can diff your workspace with the depot by selecting the folders of interest.

When diffing folders, the folder diff utility enables you to detect problems such as:

  • Files that need to be added to or deleted from the depot (files you have created or deleted in the workspace)
  • Files in the depot that need to be retrieved to your workspace (files that changed in the depot after you retrieved them)
  • Files you have edited but not submitted.
  • Local files that you changed without first opening them for edit or without setting write permission (for example, using :w!< in vi.)

The folder diff utility also detects client view mapping disparities such as:

  • Unmapped or remapped files and directories
  • Files and directories that were retrieved to the workspace and subsequently removed from the client view
  • Files and directories that exist in the local workspace but are not in the current client view

To prevent or correct disparities that arise from changes to your client view, retrieve the affected files (choose Get Latest Revision).

View the state of the depot at a specified point in time

When you choose Specify revision, the corresponding pane displays the state of the depot at the specified date, changelist number, or label. This feature enables you to view the depot structure at that time without retrieving files, similar to P4Web’s Back in Time Browsing.

Diff large files

To ensure correct results when comparing files that exceed 50,000 lines, you need to set the diff.sthresh configurable to be greater than the number of lines being diffed. By default, this configurable has a value of 50,000.

To set the diff.sthresh configurable using the P4ENVIRO environment setting:

  1. Set P4ENVIRO.

    • On Windows platforms, set P4ENVIRO as a Windows environment variable (Advanced system settings > Environment Variables):

      P4ENVIRO=%USERPROFILE%\p4enviro.txt
    • On Linux platforms:

      export P4ENVIRO=~/.p4enviro
  2. Depending on your platform, create the file %USERPROFILE%\p4enviro.txt or ~/.p4enviro containing the following line:

    diff.sthresh=100000

    This example is set to 100,000, but the actual value you choose should be greater than the average number of lines in the two files being compared.

For more information on the environment setting, see P4ENVIRO in Helix Core Command-Line (P4) Reference.