diff mercurial/filemerge.py @ 26070:e15966216aec

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.
author Erik Huelsmann <ehuels@gmail.com>
date Sun, 16 Aug 2015 00:24:29 +0200
parents 80aba76e29c1
children ff12a6c63c3d
line wrap: on
line diff
--- a/mercurial/filemerge.py	Sun Aug 16 00:00:34 2015 +0200
+++ b/mercurial/filemerge.py	Sun Aug 16 00:24:29 2015 +0200
@@ -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 _merge(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 _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+                  files, labels, 'merge')
+
 @internaltool('merge3', True,
               _("merging %s incomplete! "
                 "(edit conflicts, then use 'hg resolve --mark')\n"))