Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 32858:57c13c0d1cde
formatter: put topic in templatespec tuple
This will allow us to change the initial template reference depending on how
the template is looked up. For example,
-Tdefault => (ref='changeset', tmpl=None, mapfile='map-cmdline.default')
-T'{rev}' => (ref='', tmpl='{rev}', mapfile=None)
A literal template given by -T option will be stored as an unnamed template,
which will free up the template namespace so that we can load named templates
from [templates] section of user config.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Apr 2017 19:07:00 +0900 |
parents | b425ec7fb7f6 |
children | 97a4d09f5140 |
comparison
equal
deleted
inserted
replaced
32857:b425ec7fb7f6 | 32858:57c13c0d1cde |
---|---|
1578 class changeset_templater(changeset_printer): | 1578 class changeset_templater(changeset_printer): |
1579 '''format changeset information.''' | 1579 '''format changeset information.''' |
1580 | 1580 |
1581 def __init__(self, ui, repo, tmplspec, matchfn, diffopts, buffered): | 1581 def __init__(self, ui, repo, tmplspec, matchfn, diffopts, buffered): |
1582 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) | 1582 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) |
1583 self.t = formatter.loadtemplater(ui, 'changeset', tmplspec, | 1583 self.t = formatter.loadtemplater(ui, tmplspec, |
1584 cache=templatekw.defaulttempl) | 1584 cache=templatekw.defaulttempl) |
1585 self._counter = itertools.count() | 1585 self._counter = itertools.count() |
1586 self.cache = {} | 1586 self.cache = {} |
1587 | 1587 |
1588 # find correct templates for current mode | 1588 # find correct templates for current mode |
1644 if self._parts['footer']: | 1644 if self._parts['footer']: |
1645 if not self.footer: | 1645 if not self.footer: |
1646 self.footer = templater.stringify( | 1646 self.footer = templater.stringify( |
1647 self.t(self._parts['footer'], **props)) | 1647 self.t(self._parts['footer'], **props)) |
1648 | 1648 |
1649 logtemplatespec = formatter.templatespec | 1649 def logtemplatespec(tmpl, mapfile): |
1650 return formatter.templatespec('changeset', tmpl, mapfile) | |
1650 | 1651 |
1651 def _lookuplogtemplate(ui, tmpl, style): | 1652 def _lookuplogtemplate(ui, tmpl, style): |
1652 """Find the template matching the given template spec or style | 1653 """Find the template matching the given template spec or style |
1653 | 1654 |
1654 See formatter.lookuptemplate() for details. | 1655 See formatter.lookuptemplate() for details. |