Merge and Graft: Two Twins That Need to Grow Apart

Software developers are familiar with merge, e.g., pulling together changes from one branch into another in a version control system. Graft is a more selective process, pulling changes from selected commits onto another branch. These two processes are often implemented in the same way, but there are important differences between the two that needs addressing.

Understanding differences between those so similar

Git and Mercurial have different ways to determine the correct ancestor when performing a merge operation. Graft operations use yet another way to determine the ancestor. In the built-in line-based algorithm, the underlying diff3 process is then used. This diff3 algorithm accepts non-conflicting changes and relies on the user to resolve conflicts. We will examine the details of this process and suggest that the symmetrical treatment that diff3 uses is appropriate for merge but not necessarily optimal for the graft operation.

In this paper we look at examples of tree-based structures such as XML and JSON to show how different approaches are appropriate for merge and graft.

Download this conference paper to:

  • Understand the fundamental differences between merge and graft.
  • Understand how results can differ when finding change depending on the method you’re using.
  • Review the advantages of XML for rule-based conflict resolution.

Merge tools are, usually, line-based tools that treat the files as a sequence of lines but they have no understanding of any syntactic structure that may be present.

Related Media

DeltaXML and DeltaJSON products look within the structure of your data to identify relevant differences, so you can diagnose, debug and process data efficiently.

Merging XML documents is a particularly tricky operation but is often required to consolidate or synchronise two or more independent edit paths or versions. As XML tools become more powerful, the possibility of achieving an intelligent merge of XML data sets become reality.

It’s common to have data in two files that we need to merge together, two different people or two different processes have made changes. Does it matter who or what has made this change? This question might help to decide whether you need a 2-way or 3-way merge.

A new approach to representing change in CALS tables

Our new CALS tables algorithm means complex change isn’t complicated to understand.