Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 32873:2ecce24dfcd3
templater: add simple interface for unnamed template (API)
This provides a simpler API for callers which don't need full templating
stack. Instead of storing the given template as the name specified by topic,
use '' as the default template to be rendered.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Apr 2017 19:56:47 +0900 |
parents | 264b86cf2092 |
children | 851825214aa3 |
comparison
equal
deleted
inserted
replaced
32872:9fcb6df413c9 | 32873:2ecce24dfcd3 |
---|---|
532 | 532 |
533 props = templatekw.keywords.copy() | 533 props = templatekw.keywords.copy() |
534 props['templ'] = template | 534 props['templ'] = template |
535 props['ctx'] = ctx | 535 props['ctx'] = ctx |
536 props['repo'] = repo | 536 props['repo'] = repo |
537 templateresult = template('conflictmarker', **props) | 537 templateresult = template.render(props) |
538 | 538 |
539 label = ('%s:' % label).ljust(pad + 1) | 539 label = ('%s:' % label).ljust(pad + 1) |
540 mark = '%s %s' % (label, templater.stringify(templateresult)) | 540 mark = '%s %s' % (label, templateresult) |
541 | 541 |
542 if mark: | 542 if mark: |
543 mark = mark.splitlines()[0] # split for safety | 543 mark = mark.splitlines()[0] # split for safety |
544 | 544 |
545 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') | 545 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') |
564 ca = fca.changectx() | 564 ca = fca.changectx() |
565 | 565 |
566 ui = repo.ui | 566 ui = repo.ui |
567 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) | 567 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) |
568 template = templater.unquotestring(template) | 568 template = templater.unquotestring(template) |
569 tmpl = formatter.maketemplater(ui, 'conflictmarker', template) | 569 tmpl = formatter.maketemplater(ui, template) |
570 | 570 |
571 pad = max(len(l) for l in labels) | 571 pad = max(len(l) for l in labels) |
572 | 572 |
573 newlabels = [_formatconflictmarker(repo, cd, tmpl, labels[0], pad), | 573 newlabels = [_formatconflictmarker(repo, cd, tmpl, labels[0], pad), |
574 _formatconflictmarker(repo, co, tmpl, labels[1], pad)] | 574 _formatconflictmarker(repo, co, tmpl, labels[1], pad)] |