[PATCH 3 of 4] formatter: port handling of 'originalnode' to populatemap() hook

Yuya Nishihara yuya at tcha.org
Thu Mar 22 11:02:43 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1521276067 -32400
#      Sat Mar 17 17:41:07 2018 +0900
# Node ID f55f39a2f6d079703583d27b7e8eb0965e3c8cbb
# Parent  9cb74d4a9abe21e1c9902dc17a145be6ab289173
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'


More information about the Mercurial-devel mailing list