formatter: port handling of 'originalnode' to populatemap() hook
authorYuya Nishihara <yuya@tcha.org>
Sat, 17 Mar 2018 17:41:07 +0900
changeset 37107 7db3c28dfdfd
parent 37106 be3f33f5e232
child 37108 e7bc0667c521
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.
mercurial/formatter.py
mercurial/templateutil.py
--- 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'