# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1520770322 -32400 # Sun Mar 11 21:12:02 2018 +0900 # Node ID 5d94efb75658163ab7db01acbefeb6469bc97739 # Parent 5def08d8870b1a9b4f0d88a80ac8f4696a199ea6 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. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel