Patchwork [2,of,3,V3] filemerge: split internal merge into api entry point and internal helper

login
register
mail settings
Submitter Erik Huelsmann
Date Aug. 16, 2015, 8:56 a.m.
Message ID <ef852de2d5f76e1cf6d9.1439715381@lsmb-dev-jessie>
Download mbox | patch
Permalink /patch/10218/
State Accepted
Commit e15966216aecda30c833978af680dde253e44fbd
Delegated to: Matt Mackall
Headers show

Comments

Erik Huelsmann - Aug. 16, 2015, 8:56 a.m.
# HG changeset patch
# User Erik Huelsmann <ehuels@gmail.com>
# Date 1439677469 -7200
#      Sun Aug 16 00:24:29 2015 +0200
# Node ID ef852de2d5f76e1cf6d9ca00b340d4302f6edb3c
# Parent  e764eb7b6562351501a11d58235801e0e06afac5
filemerge: split internal merge into api entry point and internal helper

This is a step toward adding 'union merge' to the internal merge tool.

'union merge' is a merge strategy which adds both left and right hand side
of a conflict region.  Git implements this merge strategy which is very
practical to have for merging to e.g. the Changelog file.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -227,15 +227,12 @@ 
             util.copyfile(back, a) # restore from backup and try again
     return 1 # continue merging
 
-@internaltool('merge', True,
-              _("merging %s incomplete! "
-                "(edit conflicts, then use 'hg resolve --mark')\n"))
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def __imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
     """
     Uses the internal non-interactive simple merge algorithm for merging
     files. It will fail if there are any conflicts and leave markers in
     the partially merged file. Markers will have two sections, one for each side
-    of merge."""
+    of merge, unless mode equals 'union' which suppresses the markers."""
     tool, toolpath, binary, symlink = toolconf
     if symlink:
         repo.ui.warn(_('warning: internal :merge cannot merge symlinks '
@@ -247,10 +244,22 @@ 
 
         ui = repo.ui
 
-        r = simplemerge.simplemerge(ui, a, b, c, label=labels)
+        r = simplemerge.simplemerge(ui, a, b, c, label=labels, mode=mode)
         return True, r
     return False, 0
 
+@internaltool('merge', True,
+              _("merging %s incomplete! "
+                "(edit conflicts, then use 'hg resolve --mark')\n"))
+def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+    """
+    Uses the internal non-interactive simple merge algorithm for merging
+    files. It will fail if there are any conflicts and leave markers in
+    the partially merged file. Markers will have two sections, one for each side
+    of merge."""
+    return __imerge(repo, mynode, orig, fcd, fco, fca, toolconf,
+                    files, labels, 'merge')
+
 @internaltool('merge3', True,
               _("merging %s incomplete! "
                 "(edit conflicts, then use 'hg resolve --mark')\n"))