diff mercurial/simplemerge.py @ 22024:372ae2745acf

simplemerge: support three labels when merging If a third label is provided it will be used for the "base" content: <<<<<<< local content from local ||||||| base former common ======= other conflicting >>>>>>> other
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 05 Aug 2014 15:10:50 -0700
parents f18830651811
children 83df50a8d61c
line wrap: on
line diff
--- a/mercurial/simplemerge.py	Tue Aug 05 14:56:25 2014 -0700
+++ b/mercurial/simplemerge.py	Tue Aug 05 15:10:50 2014 -0700
@@ -379,13 +379,16 @@
 
     name_a = local
     name_b = other
+    name_base = None
     labels = opts.get('label', [])
     if len(labels) > 0:
         name_a = labels[0]
     if len(labels) > 1:
         name_b = labels[1]
     if len(labels) > 2:
-        raise util.Abort(_("can only specify two labels."))
+        name_base = labels[2]
+    if len(labels) > 3:
+        raise util.Abort(_("can only specify three labels."))
 
     try:
         localtext = readfile(local)
@@ -402,7 +405,11 @@
         out = sys.stdout
 
     m3 = Merge3Text(basetext, localtext, othertext)
-    for line in m3.merge_lines(name_a=name_a, name_b=name_b):
+    extrakwargs = {}
+    if name_base is not None:
+        extrakwargs['base_marker'] = '|||||||'
+        extrakwargs['name_base'] = name_base
+    for line in m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs):
         out.write(line)
 
     if not opts.get('print'):