# HG changeset patch # User Yuya Nishihara # Date 2018-03-11 12:12:02 # Node ID 036e4483d3a1bce5a2661b3c3f62355d8849ecb0 # Parent 255f635c3204baf09e418655ffe54c88221b170c templater: process mapping dict by resource callables A resource item is a callable, so let's make it look up a resource object by itself. diff --git a/mercurial/formatter.py b/mercurial/formatter.py --- a/mercurial/formatter.py +++ b/mercurial/formatter.py @@ -508,6 +508,9 @@ def templateresources(ui, repo=None): } def getsome(context, mapping, key): + v = mapping.get(key) + if v is not None: + return v return resmap.get(key) return { diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -565,8 +565,6 @@ class engine(object): evaluation""" v = None if key in self._resources: - v = mapping.get(key) - if v is None and key in self._resources: v = self._resources[key](self, mapping, key) if v is None: raise templateutil.ResourceUnavailable( @@ -671,8 +669,7 @@ class templater(object): - ``defaults``: a dict of symbol values/functions; may be overridden by a ``mapping`` dict. - ``resources``: a dict of functions returning internal data - (e.g. cache), inaccessible from user template; may be overridden by - a ``mapping`` dict. + (e.g. cache), inaccessible from user template. - ``cache``: a dict of preloaded template fragments. - ``aliases``: a list of alias (name, replacement) pairs.