Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 35487:817a3d20dd01
templater: register keywords to defaults table
Since the keywords are permanent, there should be no need to pass them
by a temporary mapping.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 22 Dec 2017 21:19:29 +0900 |
parents | f1c54d003327 |
children | a7f7eff4ec08 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Dec 22 21:22:49 2017 +0900 +++ b/mercurial/cmdutil.py Fri Dec 22 21:19:29 2017 +0900 @@ -1844,7 +1844,9 @@ changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) tres = formatter.templateresources(ui, repo) - self.t = formatter.loadtemplater(ui, tmplspec, resources=tres, + self.t = formatter.loadtemplater(ui, tmplspec, + defaults=templatekw.keywords, + resources=tres, cache=templatekw.defaulttempl) self._counter = itertools.count() self.cache = tres['cache'] # shared with _graphnodeformatter() @@ -1886,7 +1888,6 @@ def _show(self, ctx, copies, matchfn, hunksfilterfn, props): '''show a single changeset or file revision''' props = props.copy() - props.update(templatekw.keywords) props['ctx'] = ctx props['index'] = index = next(self._counter) props['revcache'] = {'copies': copies} @@ -2658,12 +2659,10 @@ tres = formatter.templateresources(ui) if isinstance(displayer, changeset_templater): tres['cache'] = displayer.cache # reuse cache of slow templates - templ = formatter.maketemplater(ui, spec, resources=tres) - props = templatekw.keywords.copy() + templ = formatter.maketemplater(ui, spec, defaults=templatekw.keywords, + resources=tres) def formatnode(repo, ctx): - props['ctx'] = ctx - props['repo'] = repo - props['revcache'] = {} + props = {'ctx': ctx, 'repo': repo, 'revcache': {}} return templ.render(props) return formatnode