Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filemerge.py @ 35486:c240657febb7
templater: drop unneeded resources from conflict-marker data
Follow-up for 32c278eb876f and f1c54d003327.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 22 Dec 2017 21:22:49 +0900 |
parents | f1c54d003327 |
children | 817a3d20dd01 |
comparison
equal
deleted
inserted
replaced
35485:964510dcdc2a | 35486:c240657febb7 |
---|---|
541 return True, r, False | 541 return True, r, False |
542 finally: | 542 finally: |
543 util.unlink(b) | 543 util.unlink(b) |
544 util.unlink(c) | 544 util.unlink(c) |
545 | 545 |
546 def _formatconflictmarker(repo, ctx, template, label, pad): | 546 def _formatconflictmarker(ctx, template, label, pad): |
547 """Applies the given template to the ctx, prefixed by the label. | 547 """Applies the given template to the ctx, prefixed by the label. |
548 | 548 |
549 Pad is the minimum width of the label prefix, so that multiple markers | 549 Pad is the minimum width of the label prefix, so that multiple markers |
550 can have aligned templated parts. | 550 can have aligned templated parts. |
551 """ | 551 """ |
552 if ctx.node() is None: | 552 if ctx.node() is None: |
553 ctx = ctx.p1() | 553 ctx = ctx.p1() |
554 | 554 |
555 props = templatekw.keywords.copy() | 555 props = templatekw.keywords.copy() |
556 props['templ'] = template | |
557 props['ctx'] = ctx | 556 props['ctx'] = ctx |
558 props['repo'] = repo | |
559 templateresult = template.render(props) | 557 templateresult = template.render(props) |
560 | 558 |
561 label = ('%s:' % label).ljust(pad + 1) | 559 label = ('%s:' % label).ljust(pad + 1) |
562 mark = '%s %s' % (label, templateresult) | 560 mark = '%s %s' % (label, templateresult) |
563 | 561 |
584 tres = formatter.templateresources(ui, repo) | 582 tres = formatter.templateresources(ui, repo) |
585 tmpl = formatter.maketemplater(ui, template, resources=tres) | 583 tmpl = formatter.maketemplater(ui, template, resources=tres) |
586 | 584 |
587 pad = max(len(l) for l in labels) | 585 pad = max(len(l) for l in labels) |
588 | 586 |
589 newlabels = [_formatconflictmarker(repo, cd, tmpl, labels[0], pad), | 587 newlabels = [_formatconflictmarker(cd, tmpl, labels[0], pad), |
590 _formatconflictmarker(repo, co, tmpl, labels[1], pad)] | 588 _formatconflictmarker(co, tmpl, labels[1], pad)] |
591 if len(labels) > 2: | 589 if len(labels) > 2: |
592 newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad)) | 590 newlabels.append(_formatconflictmarker(ca, tmpl, labels[2], pad)) |
593 return newlabels | 591 return newlabels |
594 | 592 |
595 def partextras(labels): | 593 def partextras(labels): |
596 """Return a dictionary of extra labels for use in prompts to the user | 594 """Return a dictionary of extra labels for use in prompts to the user |
597 | 595 |