comparison mercurial/filemerge.py @ 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
comparison
equal deleted inserted replaced
22025:5f22975d320d 22026:6966542768ff
310 '{ifeq(branch, "default", "", "{branch} ")}' + 310 '{ifeq(branch, "default", "", "{branch} ")}' +
311 '- {author|user}: {desc|firstline}') 311 '- {author|user}: {desc|firstline}')
312 312
313 _defaultconflictlabels = ['local', 'other'] 313 _defaultconflictlabels = ['local', 'other']
314 314
315 def _formatlabels(repo, fcd, fco, labels): 315 def _formatlabels(repo, fcd, fco, fca, labels):
316 """Formats the given labels using the conflict marker template. 316 """Formats the given labels using the conflict marker template.
317 317
318 Returns a list of formatted labels. 318 Returns a list of formatted labels.
319 """ 319 """
320 cd = fcd.changectx() 320 cd = fcd.changectx()
321 co = fco.changectx() 321 co = fco.changectx()
322 ca = fca.changectx()
322 323
323 ui = repo.ui 324 ui = repo.ui
324 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) 325 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker)
325 template = templater.parsestring(template, quoted=False) 326 template = templater.parsestring(template, quoted=False)
326 tmpl = templater.templater(None, cache={'conflictmarker': template}) 327 tmpl = templater.templater(None, cache={'conflictmarker': template})
327 328
328 pad = max(len(labels[0]), len(labels[1])) 329 pad = max(len(l) for l in labels)
329 330
330 return [_formatconflictmarker(repo, cd, tmpl, labels[0], pad), 331 newlabels = [_formatconflictmarker(repo, cd, tmpl, labels[0], pad),
331 _formatconflictmarker(repo, co, tmpl, labels[1], pad)] 332 _formatconflictmarker(repo, co, tmpl, labels[1], pad)]
333 if len(labels) > 2:
334 newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad))
335 return newlabels
332 336
333 def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None): 337 def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
334 """perform a 3-way merge in the working directory 338 """perform a 3-way merge in the working directory
335 339
336 mynode = parent node before merge 340 mynode = parent node before merge
389 393
390 markerstyle = ui.config('ui', 'mergemarkers', 'basic') 394 markerstyle = ui.config('ui', 'mergemarkers', 'basic')
391 if not labels: 395 if not labels:
392 labels = _defaultconflictlabels 396 labels = _defaultconflictlabels
393 if markerstyle != 'basic': 397 if markerstyle != 'basic':
394 labels = _formatlabels(repo, fcd, fco, labels) 398 labels = _formatlabels(repo, fcd, fco, fca, labels)
395 399
396 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, 400 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
397 (a, b, c, back), labels=labels) 401 (a, b, c, back), labels=labels)
398 if not needcheck: 402 if not needcheck:
399 if r: 403 if r: