Ellié Computing Home Page

Call us at +1 586 62 ELLIE / +1 586 62 35543 Office Closed
sales@elliecomputing.com - Contact us

right arrow

Why 3-way?


Definition of 3-way merge:
Algorithm to combine 3 data sets. One particular set is called 'ancestor', the two others sets have an equivalent role (let's call them set1 and set2). The merge corresponds to a generalized addition operation such as: delta(result, ancestor) = delta(set1, ancestor) + delta(set2, ancestor).

What are the advantages with a 3-way merge with respect to a simple side-by-side merge? why is this definition important?
The main interest in this type of merge is that it can be partially automated. Indeed, the 'plus' and 'delta' operations are well defined and can be computed by a program, without the attention of a programmer generally. Therefore, a precious time gain is realized. The softwares which allow only side-by-side merge cannot realize the 'plus' operation. This operation is complex and can lead to conflicts, i.e. situations where the operation does not have a defined result. This operation cannot be simulated even using rules in side-by-side merge tool: human attention is required. In ECMerge Pro, it is possible to parameterize the merge algorithm 'plus' operation with a security distance and also changes that can be safely ignored.

When should you use a tool that supports 3-way merges? when is side-by-side enough?

2 sources3 sources
Adapted productECMerge Standard et ECMerge ProECMerge Pro
Use type Folders synchronization
Filtered copy, archiving
Comparing versions, searching for differences with a colleague's job
Generating patch changing a version into the other
Integration with a change management tool or source code control
Merging your modifications with respect to open source projects
Merging your modifications with a colleague's modifications

Do I have all what is needed to merge 3-way?
To merge 3-way, you need your own working version, the version of a co-worker (or another of your own working configurations) and the ancestor version, that is, a backup dating from before both modifications or a backup of the last merge. Any SCC / GCL tool registers this ancestor configuration. Of course, you can save this ancestor configuration by yourself as a folder or an archive.
So the absolute necessary: a 3-way merge tool. Recommanded in addition: a SCC / GCL tool.

How much time do I save? what is the Return On Investment?
Take an example, for a project of moderate size (700 source files), Bob and Mary work an different functionalities but some of the modified files are common (headers and classes). Both of them modify 40 files from which 16 are common (40%); each file was modified at approximately 10 places.
Bob and Mary are using a SCC, it handles the common ancestor storage and calls ECMerge Pro thanks to the command line integration: from the 16 files, only 50% have one or more conflicts. Mary merges her source files: it takes her 1 minute for the files with a single or two conflicts (around 80%) and 5 minutes for the others. She just passed 16 minutes for this work.
Bob is responsible for merging 3 times a year the open source project which is the base framework for their application, around 150 files out of 7000 have been modified to adapt some functionalities and to merge some other modifications from sub-projects. The project is delivered as an archive. Bob simply unzip the previously merged archived version (e.g. 2.6.2) and uses it as ancestor, he uses its own version as left and the new version of the open-source project (2.6.3) as right version. ECMerge Pro takes just some minutes to determined the changed files and conflicts: 10 files have conflicts. Bob takes around 3 minutes per files, i.e. half an hour. In order to verify its work, it takes half a day (because only files that he knows very well have been merged). Totalling around 5 hours.
Without 3-way merge, Mary would have had to determine which of the 40 files have been modified by both Bob and she (10 minutes), then each of these files must be compared manually with respect to the common ancestor, then the modification from one side must be cut'n'pasted to the other (with all the risks an erroneous modification implies): 16 files * 5 minutes: 80 minutes. Approximately 90 minutes.
With a side-by-side tool Bob would have to verify 150 files, because most of them evolved, even for just one line, it would take him: 150 * 5 = 750 minutes, plus the time to check the framework because nearly each files was modified by hand, 2 days, totalling around 30 hours.
Bob and Mary cost $US 6000 per month, around $42 / h : a side-by-side tool would provoque a loss of $55 for a SINGLE moderate merge . We can estimate that such a merge happen around twice a month, approximately 25 times per year: $1375 per developper and per year ! For the quarterly merge it would be more than $3000 a year. More than 80 times the price of ECMerge Pro for the whole !

Some advantages of ECMerge Pro :
The algorithm of ECMerge Pro allows for a security distance and takes into account ignored changes. The security distance is the minimal distance between two changes happening in each new version (with respect to their location in the ancestor) for which we consider that merging is safe without the attention of the programmer. Indeed, even if two changes do not modify the same lines, if the modified lines are very near from each others, they are likely to be modified to obtain the real merged result...
It makes a big difference from tools which would let the merge happen without attention because the problems would be seen later when testing the application!
Ignored changes can simplify your life as well because the conflicts between ignored changes are automatically solved to use the version of the file designated in the configuration of the merge, the conflicts between true changes and ignored changes are solved using the true change.
Of course, the ability of ECMerge to modifiy freely the final text of the merge (while merging) and the clear in-line differences presentation will greatly help during the merge. The merge tools coming with SCC/ SCM are generally simplistic, they support only plain text comparison, with no refinement (no colouring, in-line differences, security area, XML pretty-printing...)

If you work in a team, on different versions on your own software or simply using open-source projects: do not hesitate about investing into ECMerge Pro, it is profitable from the FIRST use !