Merge Integration with Mercurial

Merge Integration with Mercurial

Merge can be configured as a merge tool for Mercurial (Hg), replacing Mercurial's built-in merge for XML files.

Configuration

Step 1: Add the merge tool to .hgrc

Edit your global Mercurial configuration (~/.hgrc on Unix or mercurial.ini on Windows):

[merge-tools]
deltanova-merge.executable = java
deltanova-merge.args = -jar /path/to/deltanova-x.y.z.jar merge concurrent \
                      ancestor $base local $local remote $other result.xml && \
                      cp result.xml $local
deltanova-merge.checkchanged = True
deltanova-merge.binary = False

Step 2: Associate file patterns with the merge tool

[merge-patterns]
**.xml = deltanova-merge
**.dita = deltanova-merge
**.ditamap = deltanova-merge

Mercurial Merge Variables

Variable

Description

$base

Path to the common ancestor version

$local

Path to the local (current branch) version

$other

Path to the other (merging) version

How It Works

When Mercurial merges an XML file:

  1. Mercurial calls the configured merge tool with the ancestor, local, and other versions.

  2. Merge performs a concurrent merge.

  3. The result is written back to $local.

  4. Mercurial checks the exit code; a non-zero exit indicates a conflict.

Notes

  • Ensure the path to the Merge JAR is absolute in the configuration.

  • The checkchanged = True setting tells Mercurial to check whether the merge tool modified the file, which is required for correct conflict detection.