The Diff Tool

Invoking the Diff Tool

Diff Tab Layout

Difference Section Color-Coding

Navigating in a Diff Tab

Diff Toolbar Navigation Buttons

Difference Map

Editing a File Using the Diff Tool

Diff Toolbar Edit-by-Diff Buttons

Main Menu Commands Available in a Diff Tab

The AccuRev GUI provides many ways to invoke a "Diff" command to compare two versions of a text-file element. By default, the comparison is performed by AccuRev's own Diff tool, which displays the two versions next to each other, using color coding to show the differences and provided convenient navigation controls. You can also configure the GUI to use another file-comparison tool.

Invoking the Diff Tool (or Another File-Comparison Tool)

No matter which tool you've configured to perform file comparisons, you invoke the tool in the same way, as described below. AccuRev's Diff tool opens in a separate tab within the AccuRev GUI window; any other tool opens in its own window.

There are multiple ways to specify the two versions of a file element to be compared:

In a File Browser, each file's context menu includes a Diff Against... item. There are several choices, each of which compares your version (i.e. the file in your workspace) with a version stored in the depot:

In a Stream Browser display, view the elements in a stream's default group The set of elements that are currently active in a particular workspace or stream. by clicking the control below the stream. An element's context menu includes the Diff Against... items described above.

In a Version Browser or Stream Version Browser display for a text-file element, you can compare any two versions: right-click any version, select Diff Against Other Version from the context menu, then left-click any other version.

In a History Browser display for a text-file element, you can compare the versions created in any two transactions. Right-click a transaction in the Summary (upper) pane, select Diff Against Other Version from the context menu, then left-click another transaction in the Summary pane. Similarly, the Diff Against File in the Workspace command enables you to compare the version created in a particular transaction with the file currently in your workspace. (That file might contain changes that you haven't yet preserved with Keep.)

Diff Tab Layout

The Diff tool displays the two versions side-by-side in separate panes, so that corresponding text lines in the versions line up visually. (You can use buttons Horizontal Layout and Vertical Layout at the right side of the toolbar to arrange the panes above-and-below.) We'll call them the "before version" (displayed on the left, or above) and the "after version". The element pathname and the version-IDs are displayed above the versions' contents.

Initially, the two panes are the same width, but you can drag the vertical separator to change the relative widths. To make both panes wider, just increase the size of the overall AccuRev GUI window.

Notes (click to view):

Difference Section Color-Coding

Through color-coding, the Diff tool partitions the text into the following kinds of "difference sections":

If a text block has been moved from one location in the file to another, the Diff tool indicates this as two separate changes: a deleted section at the original location, and an added section at the new location.

Your user preferences include controls for the Diff tool's handling of whitespace-only differences between the versions.

Navigating in a Diff Tab

Most text files are too long to fit on the display screen, and some individual text lines are too wide. Accordingly, the panes in which the versions appear have both vertical and horizontal scroll bars. Scrolling of the panes is synchronized automatically. Line numbers appear at the left edge of each pane.

For a text file that contains hundreds or thousands of lines, there may be only a few difference sections (added, deleted, or revised), separated by large unchanged sections. The Diff tool provides both navigation buttons on its toolbar and a difference map for direct access to a particular difference section.

Diff Toolbar Navigation Buttons

Whenever you use one of these buttons to jump to a particular difference section, the Diff tool remembers it as the current difference The currently highlighted difference section (Diff tool) or change section (Merge tool). and highlights the lines numbers in both panes. A "difference N of M" window in the toolbar indicates which difference section is current.

First Diff

(Keyboard shortcut: Ctrl-F) Go to the first difference section.

Last Diff

(Keyboard shortcut: Ctrl-L) Go to the last difference section.

Center Diff

Using the scroll bars or the difference map, you can make the current difference The currently highlighted difference section (Diff tool) or change section (Merge tool). scroll offscreen. Click this button to bring it back onscreen.

Previous Diff

(Keyboard shortcut: Ctrl-P) Go to the previous difference section.

Next Diff

(Keyboard shortcut: Ctrl-N) Go to the next difference section.

Search

(Keyboard shortcut: Ctrl-S) Search for a text string, in either of the versions being compared. A dialog appears, in which you define the search.

This command is also available on the GUI window's main menu: File > Search.

After you've defined a search, you can perform it again, using the command File > Search Again on the GUI window's main menu, or its keyboard shortcut: function key F3.

 

 

 

 

 

 

 

 

Additional buttons on the toolbar support edit-by-diff operations.

Difference Maps

To the right of each pane, there's a difference map that shows the relative locations and sizes of all the difference sections. The maps use the same color-coding as the difference sections themselves. Click on any colored area within a map to scroll both panes directly to the corresponding difference section. [note Actually, you can click anywhere in the difference map; the panes will scroll to that location, even if the files are identical there.]

Using a difference map merely scrolls the panes; it does not affect which difference is the current difference. After you jump to a particular location, click the difference section in either pane to make it the current difference.

If you use a difference map, but then want to scroll back to where you were before, click the Center Diff toolbar button.

Editing a File Using the Diff Tool

In addition to comparing two versions of a file, the Diff tool can help you to edit the contents of the version in your workspace. This "edit-by-diff" capability is available only when you're comparing your workspace version with another version; it's not available when you invoke the Diff tool from the Version Browser or History Browser.

Here's a procedure for using this capability (there's a toolbar button summary below):

  1. Invoke the Diff tool in a File Browser, to compare your workspace version with some other ("before") version of the same file.

  2. Click the Show result of edits button in the Diff toolbar. This opens a third pane (the Edit pane), which initially contains the same text as your workspace version.

  1. As you browse through the difference sections, you can:

You can then modify the combined text manually.

  1. Finish your work in either of these ways:

Notes (click to view):

Diff Toolbar Edit-by-Diff Buttons

Revert my change

Use the "before" version's section at this point. If the button is currently highlighted, you can hold down the Ctrl key and press to append the "before" section to the workspace version's section.

Restore my change

Use the workspace version's section at this point. If the button is currently highlighted, you can hold down the Ctrl key and press to append the workspace version's section to the "before" section.

Revert all my changes

Make the Edit pane the same as the "before" version.

Restore all my changes

Make the Edit pane the same as the "after" version.

Save edits and close

Store the current contents of the Edit pane in the workspace's file, without performing a Keep The operation (keep command) that creates a new version of a file element in a workspace, permanently recording in the AccuRev repository a change to the contents of the file. operation.

Main Menu Commands Available in a Diff Tab

Several of the commands in the Edit submenu of GUI window's main menu are enabled when you're working in a Diff tab:

Cut

(Keyboard shortcut: Ctrl-X) Cut the selected text to the window system's clipboard.

Copy

(Keyboard shortcut: Ctrl-C) Copy the selected text to the window system's clipboard.

Paste

(Keyboard shortcut: Ctrl-V) Paste the contents of the window system's clipboard.

Select All

(Keyboard shortcut: Ctrl-A) Select the entire contents of the current pane.

Search

(Keyboard shortcut: Ctrl-S) See the Search description above.

Search Again

(Keyboard shortcut: F3) See the Search description above.