diff mercurial/templatekw.py @ 37074:2891079fb0c0

templater: factor out function to create mapping dict for nested evaluation overlaymap() is the hook point to drop mapping items conflicting with the default keywords which have to be re-evaluated with new 'ctx' resource.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 15 Mar 2018 21:22:52 +0900
parents d3f7930a9563
children f0b6fbea00cf
line wrap: on
line diff
--- a/mercurial/templatekw.py	Thu Mar 15 20:43:39 2018 +0900
+++ b/mercurial/templatekw.py	Thu Mar 15 21:22:52 2018 +0900
@@ -449,8 +449,8 @@
 @templatekeyword('changessincelatesttag', requires={'repo', 'ctx', 'cache'})
 def showchangessincelatesttag(context, mapping):
     """Integer. All ancestors not in the latest tag."""
-    mapping = mapping.copy()
-    mapping['tag'] = getlatesttags(context, mapping)[2][0]
+    tag = getlatesttags(context, mapping)[2][0]
+    mapping = context.overlaymap(mapping, {'tag': tag})
     return _showchangessincetag(context, mapping)
 
 def _showchangessincetag(context, mapping):
@@ -480,8 +480,7 @@
         return
     mrev = repo.manifestlog._revlog.rev(mnode)
     mhex = hex(mnode)
-    mapping = mapping.copy()
-    mapping.update({'rev': mrev, 'node': mhex})
+    mapping = context.overlaymap(mapping, {'rev': mrev, 'node': mhex})
     f = context.process('manifest', mapping)
     # TODO: perhaps 'ctx' should be dropped from mapping because manifest
     # rev and node are completely different from changeset's.