changeset 37104:7db3c28dfdfd

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 17 Mar 2018 17:41:07 +0900
parents be3f33f5e232
children e7bc0667c521
files mercurial/formatter.py mercurial/templateutil.py
diffstat 2 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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'