Three-Way File Comparison and Merging

Regular Three-Way Comparison

Code Compare provides the functionality of three-way comparison and merge. It allows you to compare and merge three files side-by-side. All the comparison, editing and merging features of two-way file comparison apply to three-way comparison too.

In case of a three-way comparison, the latest version of a file is considered to be the result and is displayed in the middle comparison pane. Besides, during a regular three-way comparison (without the base file), at first the left pane is compared with the middle pane, and then the right pane is compared with the middle pane.

To compare three files at the same time, you can call Code Compare using Windows Explorer (right-click on a file and choose Compare with Code Compare). Another way of file selection is a dragging files to Code Compare.

Conflicts

Conflicts are cases when it is unclear whose change should be merged, e.g. if the same block of code was changed by two users, and thus they require more thorough analysis. Conflicts occur only in three-way comparisons.

In the document area conflicts are displayed framed and linked in red.

To navigate between conflicts, in the Changes menu select the Next/Previous Conflict options, or use the corresponding buttons on the toolbar.

Layout

By default, during three-way comparison files are displayed in three panes aligned side-by-side vertically. The default display of comparison panes can be changed: you can either display panes horizontally or hide one of them. This can be done using the Layout menu or toolbar options. For more information on layout commands, see the Layout Commands topic.

Integration with Version Control Systems

Three-way file merging allows you to merge two derived files to a result or a base file.

When integrated with a version control system, Code Compare gains more features in terms of three-way comparison. In case of VCS integration not three, but four files can be compared, then the middle pane displays either the result, or the base file depending on revision selected using the Base/Result buttons.

Revision Name Icon Description
Mine Just edited revision
Theirs Revision edited by another user
Result New revision that contains changes from ‘Mine’, ‘Theirs’, and ‘Base’ revisions
Base Original version of document. You can switch to this version using a special button on the Code Compare toolbar.

This merge is the most reliable and has performed well in practice. It has also required the least amount of user intervention, and in many cases, requiring no intervention at all (depending upon the complexity of the merge) making the process eligible for task automation.

The revision version is placed on the top-left corner of the comparison pane.

Three way merge

For details on VCS integration, refer to the Version Control Systems Integration section.

Note

This functionality is available only in Code Compare Pro.

Manipulating Code Merging

To manipulate code merging, use the Code Merging toolbar shown below.

Code merging toolbar

Command Name Icon Description
Accept Result Accept merge result.
Theirs as Result Regard Theirs revision as a result.
Mine as Result Regard Mine revision as a result.
Base as Result Regard Base revision as a result.
Next Conflict Go to next conflict.
Previous Conflict Go to previous conflict.
Show Base File Show Base file instead of Result file.