Performing Three-Way Comparison

Three-way comparison is the automated difference analysis between two modified files with respect to a mutually common file, often referred to as their ancestor. This type of comparison often, but not always, involves the use of a revision control system which hosts such an ancestor. The differences and the patters appearing in the changes among the two files and the ancestor are examined and a relationship model is built to enable the merging of the two files with their origin into a new revision of the ancestor.

The need for a three-way file comparison is frequently present in collaborative projects where more than one contributor applies modifications to a local copy of one and the same file at a given point in time.

Three-way comparison evaluates to more than two standalone two-way comparisons between each of the modified files and their common ancestor as it reflects the level of convergence between the two derivative works and their ancestor. A conflicting change is a case in point—it exists only in the context of a three-way comparison, when a block of text has been changed differently in both derivative works.

To open a three-way comparison

A somewhat simplified three-way text file comparison containing one of each possible relationships—deletions, additions, non-conflicting, and conflicting changes—is shown on the following screenshot:

Three-way file comparison image

Putting the comparison to work

The experience with two-way comparison in browsing differences, editing the files being compared and merging them with standard commands easily carries over to three-way comparison. Though three-way comparison introduces a new participant in the analysis—the ancestor file—it's usually sufficient to base editing and merging decisions on examination of the differences in two out of the three files at the time.

Layout of the files in three-way comparison

DeltaWalker understands the importance of the ancestor file as a common reference for the other two file versions and provides three different intuitive layouts emphasizing its role:

Differences in agreement

In a well-planned collaborative software development, more frequently than not, two works sharing a common origin have most of their differences with respect to that origin in separate, unrelated blocks of text.

Frequent artifacts of such scenarios are additions and deletions, relative to the ancestor, present only in one of the files, while the respective blocks from the other file remain unchanged. In these cases, apply your skills from working with two-way comparisons to either accept the modifications in the ancestor or to reject them.

It is not uncommon for the authors of the derivative works to make the same change in their locally modified versions. Since the changes are in agreement, two-way comparison and editing techniques are, again, directly applicable as well.

Conflicting differences

DeltaWalker accurately detects different modifications to the same blocks of original text and brings them to your attention for analysis and resolution. These differences require a manual resolution; by default the areas containing them are outlined in red. To keep your work flowing even in these infrequent cases, DeltaWalker features state-of-the-art text editors which provide you with ample editing power and merging flexibility.

Related topics