comparison mercurial/cmdutil.py @ 32875:c8f2cf18b82e

formatter: load templates section like a map file Since a map file has another level to select a template (spec -> mapfile -> topic), this isn't exactly the same as how a map file works. But I believe most users would expect the new behavior. A literal template is stored as an unnamed template so that it will never conflict with the templates defined in [templates] section.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 20:14:55 +0900
parents 2ecce24dfcd3
children 388e1242ed9e
comparison
equal deleted inserted replaced
32874:dddba6f3e59c 32875:c8f2cf18b82e
1647 if not self.footer: 1647 if not self.footer:
1648 self.footer = templater.stringify( 1648 self.footer = templater.stringify(
1649 self.t(self._parts['footer'], **props)) 1649 self.t(self._parts['footer'], **props))
1650 1650
1651 def logtemplatespec(tmpl, mapfile): 1651 def logtemplatespec(tmpl, mapfile):
1652 return formatter.templatespec('changeset', tmpl, mapfile) 1652 if mapfile:
1653 return formatter.templatespec('changeset', tmpl, mapfile)
1654 else:
1655 return formatter.templatespec('', tmpl, None)
1653 1656
1654 def _lookuplogtemplate(ui, tmpl, style): 1657 def _lookuplogtemplate(ui, tmpl, style):
1655 """Find the template matching the given template spec or style 1658 """Find the template matching the given template spec or style
1656 1659
1657 See formatter.lookuptemplate() for details. 1660 See formatter.lookuptemplate() for details.
1704 if opts.get('template') == 'json': 1707 if opts.get('template') == 'json':
1705 return jsonchangeset(ui, repo, matchfn, opts, buffered) 1708 return jsonchangeset(ui, repo, matchfn, opts, buffered)
1706 1709
1707 spec = _lookuplogtemplate(ui, opts.get('template'), opts.get('style')) 1710 spec = _lookuplogtemplate(ui, opts.get('template'), opts.get('style'))
1708 1711
1709 if not spec.tmpl and not spec.mapfile: 1712 if not spec.ref and not spec.tmpl and not spec.mapfile:
1710 return changeset_printer(ui, repo, matchfn, opts, buffered) 1713 return changeset_printer(ui, repo, matchfn, opts, buffered)
1711 1714
1712 return changeset_templater(ui, repo, spec, matchfn, opts, buffered) 1715 return changeset_templater(ui, repo, spec, matchfn, opts, buffered)
1713 1716
1714 def showmarker(fm, marker, index=None): 1717 def showmarker(fm, marker, index=None):