Compare base and working files using the Diff tool

The Code Editor includes an integrated Diff tool, which allows you to compare the read-only base copy and working copy of a file.

Specify how the differences are displayed by using these options from the Diff menu:

Normal View
Opens the file in normal editing mode.
Diff View
Displays differences between the base file and working copy in a single pane document. This is also called single pane diff mode. Added and modified lines are highlighted. Deleted lines are identified by location but not displayed.
Diff View with Deleted Blocks
Displays differences between the base file and working copy in a single pane document. Added, modified, and deleted lines are highlighted.
Vertical Dual Diff View
Displays the two files vertically, with the base file in the left pane and the working copy in the right pane. This is also called two pane diff mode.
Horizontal Dual Diff View
Displays the two files horizontally, with the base file in the top pane and the working copy in the bottom pane. This is also called two pane diff mode.

Example: Diff View

This figure shows Diff View. Lines 28-32 are marked with green blocks to indicate newly added lines. The orange block in the gutter of line 24 indicates a modified line (a new comment, highlighted in green, has been added to the existing line). The red line between line 22 and line 23 flag the location of a deleted line/lines.

Figure: Diff View display mode

This figure is a screenshot of the Diff View.

Example: Vertical Dual Diff View

This figure shows Vertical Dual Diff View. Side-by-side comparison of the base file in the left pane and the editable working copy in the right pane give you a before and after record of changes. Red blocks in the gutter of the base file pane show the contents of lines deleted in the working copy.

Figure: Vertical Dual Diff View display mode

This figure is a screen shot of the Vertical Dual Diff View.

Viewing differences between files

The Diff tool flags differences between files with color-coded markups in the Code Editor gutter. The default colors are:

  • Green - added lines
  • Orange - modified lines
  • Red - deleted lines

Locate differences between the files by using the navigation options from the Diff menu: First Difference, Previous Difference, Next Difference, and Last Difference.

Tip:

You can also move through the differences using the diff toolbar arrows (next to Difference 1 of N). If these arrows are not visible, open the Code Editor Preferences and select Show diff options in editor.

To specify display options for the Diff tool, select Tools > Preferences (or, if you are on a Mac, Genero Studio > Preferences), then Code Editor > Diff Preferences.

Selecting the base file

In the Code Editor, the Diff tool automatically selects the base file in this order:
Use Generated File
The default for generated files, this option compares the document with the file generated by the application generator. This is the generated file before POINTs and BLOCKs are injected into the file. This option is made available only if the file has been generated.
Use Repository File
The default for versioned files, this option compares the document with the file in the repository for the current SVN version of the file. This option is enabled only if the file is versioned.
Use File on Disk
Compares the document with the contents of the file as it was on disk when the file was opened. If you select this option again after the file has been opened, the diff data will be refreshed by comparing the document with the actual content of the file on disk.

To change the base file, select Diff > Base File.

Reverting changes in the working file

You can replace any changes in the working copy (also referred to as the user file) with the original values from the base copy.

Tip:

Switch to Vertical Dual Diff View before copying. The arrows in the context menu will then show the direction for copying the content.

Place the cursor in the line of marked code, right-click and select Copy to User File.

Note:

You cannot edit the base file, so Copy to Base File is disabled.

For example, in Figure 3, select Copy to User File to revert the selected change that has been made to the working copy (shown on the right). This will result in the added line (CALL ui.Interface.refresh()) being removed.

Figure: Reverting changes

This figure shows a file with changes in Vertical Dual Diff mode. The context menu is displayed, with Copy to User File highlighted.

To revert all changes, select Diff > Copy All to User File.