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.
--- a/mercurial/formatter.py Thu Mar 15 21:52:47 2018 +0900
+++ b/mercurial/formatter.py Sat Mar 17 17:41:07 2018 +0900
@@ -514,6 +514,8 @@
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):
--- a/mercurial/templateutil.py Thu Mar 15 21:52:47 2018 +0900
+++ b/mercurial/templateutil.py Sat Mar 17 17:41:07 2018 +0900
@@ -406,7 +406,6 @@
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'