# HG changeset patch # User Yuya Nishihara # Date 2018-03-17 08:41:07 # Node ID 7db3c28dfdfd7c86d4847ca003cd36bebb2c1dbc # Parent be3f33f5e232512a8b128720579feda239191376 formatter: port handling of 'originalnode' to populatemap() hook This isn't a pure templating business, so let's move out of the templater module. Note that this works only in web templates where mapping['node'] is a static value. diff --git a/mercurial/formatter.py b/mercurial/formatter.py --- a/mercurial/formatter.py +++ b/mercurial/formatter.py @@ -514,6 +514,8 @@ class templateresources(templater.resour mapping = {} if self._hasctx(newmapping): mapping['revcache'] = {} # per-ctx cache + if 'node' in origmapping and 'node' in newmapping: + mapping['originalnode'] = origmapping['node'] return mapping def _getsome(self, context, mapping, key): diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -406,7 +406,6 @@ def runmap(context, mapping, data): if isinstance(v, dict): lm = context.overlaymap(mapping, v) lm['index'] = i - lm['originalnode'] = mapping.get('node') yield evalrawexp(context, lm, targ) else: # v is not an iterable of dicts, this happen when 'key'