{X} This page is proposed for deletion. See our wiki cleanup plan for more information.

Merge Program

A merge program combines two different versions of a file into a merged file.

Usually, the program tries to do so automatically, by combining all the non-overlapping changes that occurred separately in the two different evolutions of the same initial base file. Furthermore, some interactive merge programs make it easier to manually resolve conflicting merges, either in a graphical way, or by inserting some conflict markers.

By default, Mercurial will attempt to do a classic 3-way merge on text files internally before trying to use an external tool.

How Mercurial decides which merge program to use

However: after selecting a merge program, Mercurial will usually attempt to merge the files using a simple merge algorithm first, to see if they can be merged without conflicts. Only if there are conflicting changes will hg actually execute the merge program. (If the file to be merged is binary or a symlink, then hg doesn't bother with the simple merge algorithm. If the selected merge tool is internal:fail, internal:local, or internal:other, then hg skips the simple merge algorithm, as the user has specifically requested that no merging take place.)

Before Mercurial 1.0, a script named hgmerge was installed by default. As of Mercurial 1.0, hgmerge is no longer installed (and it should not be distributed with Mercurial), but hg still uses it, if it's present on the system and no other merge tools are configured (see hgmerge)

Choosing a merge program

Some merge programs include:

1. Linux merging and diffing tools

2. Windows merging and diffing tools

3. OS X merging and diffing tools

4. Custom merging tools

Configuring a merge program

If you have a preferred merge program, you can set the merge entry in the ui section of your hgrc file.

1. Kdiff3

[ui]
merge = your-merge-program

In Mercurial 1.0 and later you can also specify the merge program's arguments in .hgrc. For example, to specify the arguments to kdiff3, add the following:

[merge-tools]
kdiff3.args = $base $local $other -o $output

(see the external diff extension to configure the diffing aspect of the tool.)

2. Meld

[ui]
merge = meld

In Mercurial 1.0 and later you can also specify the merge program's arguments in .hgrc. For example, to specify the arguments to kdiff3, add the following:

[merge-tools]
meld.args = $local $base $other $output


CategoryGlossary

MergeProgram (last edited 2012-05-08 16:22:50 by mpm)