# HG changeset patch # User Pierre-Yves David # Date 1407277058 25200 # Node ID 6966542768ff38ad864315d598aebc6ef65e5da8 # Parent 5f22975d320dc0ea2974c30e6b7dcab15fd1b2e3 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. diff -r 5f22975d320d -r 6966542768ff mercurial/filemerge.py --- 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)