changeset 22026:6966542768ff

filemerge: allow the formatting of three labels instead of two When a third label is provided (to included the base content) it is properly processed as the two others. Nothing changes if only two labels are provided.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 05 Aug 2014 15:17:38 -0700
parents 5f22975d320d
children b98e5c7afc70
files mercurial/filemerge.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filemerge.py	Tue Aug 05 15:12:22 2014 -0700
+++ b/mercurial/filemerge.py	Tue Aug 05 15:17:38 2014 -0700
@@ -312,23 +312,27 @@
 
 _defaultconflictlabels = ['local', 'other']
 
-def _formatlabels(repo, fcd, fco, labels):
+def _formatlabels(repo, fcd, fco, fca, labels):
     """Formats the given labels using the conflict marker template.
 
     Returns a list of formatted labels.
     """
     cd = fcd.changectx()
     co = fco.changectx()
+    ca = fca.changectx()
 
     ui = repo.ui
     template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker)
     template = templater.parsestring(template, quoted=False)
     tmpl = templater.templater(None, cache={'conflictmarker': template})
 
-    pad = max(len(labels[0]), len(labels[1]))
+    pad = max(len(l) for l in labels)
 
-    return [_formatconflictmarker(repo, cd, tmpl, labels[0], pad),
-            _formatconflictmarker(repo, co, tmpl, labels[1], pad)]
+    newlabels = [_formatconflictmarker(repo, cd, tmpl, labels[0], pad),
+                 _formatconflictmarker(repo, co, tmpl, labels[1], pad)]
+    if len(labels) > 2:
+        newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad))
+    return newlabels
 
 def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
     """perform a 3-way merge in the working directory
@@ -391,7 +395,7 @@
     if not labels:
         labels = _defaultconflictlabels
     if markerstyle != 'basic':
-        labels = _formatlabels(repo, fcd, fco, labels)
+        labels = _formatlabels(repo, fcd, fco, fca, labels)
 
     needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
                         (a, b, c, back), labels=labels)