PrestoSoft Blog :: Home

Monday, January 09, 2012

Three-Way Merge Coming in ExamDiff Pro 6.0

Here at PrestoSoft we've been hard at work on one of the biggest and most requested features we've ever done for ExamDiff Pro: three-way file merge. In three-way merge, three files are compared - a base file and two revision files ("yours" and "theirs") that are both modifications of the base - and the goal is to reconcile the changes made in the revision files into an output file.

Merge operations are started through the new Merge Files tab in the Compare dialog. In addition to the left ("theirs"), center ("base"), and right ("yours") files, an optional output file can be specified to store the results of the merge operation. If no output file is specified, the output (bottom) pane will be populated with merge results that can be saved to a file.


After clicking Merge, the main window is opened with the automatic merge results:


Note the three comparison panes and the output pane underneath. Each comparison pane has a color associated with it (shown in the pane header), and the diff blocks in the output pane are colored according to which file they were taken from. During the merge operation, ExamDiff Pro both separates the files into blocks and selects the appropriate block to choose for the output pane. Some blocks cannot be automatically reconciled (because all three files differ): these are denoted as "conflict" blocks and their diff bar is colored red. Conflicts must be manually reconciled, as explained below.

Instead of Added, Deleted, and Changed blocks (as in file comparison), there are now Matching, Non-Matching, and Conflict blocks.
  • In a Matching block, the left and right files both differ from the center file, but are themselves equal. In other words, the same change from base was made in "theirs" and "yours". ExamDiff Pro selects the right ("yours") file in this case.
  • In a Non-Matching block, either the left or right file differs from the center file, but not both. In other words, the change was only made in one file. ExamDiff Pro selects the file in which the change was made.
  • In a Conflict block, the left and right files both differ from the center files and are not equal to one other. In other words, different changes from base were made in "theirs" and "yours". ExamDiff Pro selects the center ("base") file and marks the block as a conflict. Conflicts must be manually resolved by the user (by selecting which of the three files to choose).

In our case, most of the blocks have been reconciled automatically, but there are still a few conflicts that I have to manually resolve. To resolve a conflict, I choose the file that I wish to use for the given block and press the diamond button on its diff bar. Alternatively, I can use the Merge | Select Left File, Merge | Select Center File, or Merge | Select Right File commands (or their corresponding toolbar buttons). When a conflict has been resolved, its diff bar color is changed from red to green. These commands can also be used for Matching and Non-Matching blocks, if I wish to override ExamDiff Pro's automatic merge.

There are two new options pages: Options | Merge and Options | Merge | Colors


In the Options | Merge page, you can specify which Ignore options are used in merge. These options are a subset of the Ignore options in Options | Compare. Note that when Ignore options are enabled, it's possible for the the contents of left and right files to differ within a Matching block (i.e. if they have different whitespace), but ExamDiff Pro will always automatically select the right ("yours") file in this case.


In the Options | Merge | Colors page, you can specify the colors and effects used in the comparison panes and the output panes, similarly to the Options | Display | Colors page. The colors associated with the left, center, and right files in the output pane are also used for the headers of the comparison panes.

Labels: ,