diff mercurial/templater.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 44757e6dad93
children 46859b437697
line wrap: on
line diff
--- a/mercurial/templater.py	Thu Mar 15 20:43:39 2018 +0900
+++ b/mercurial/templater.py	Thu Mar 15 21:22:52 2018 +0900
@@ -613,6 +613,13 @@
         self._aliasmap = _aliasrules.buildmap(aliases)
         self._cache = {}  # key: (func, data)
 
+    def overlaymap(self, origmapping, newmapping):
+        """Create combined mapping from the original mapping and partial
+        mapping to override the original"""
+        mapping = origmapping.copy()
+        mapping.update(newmapping)
+        return mapping
+
     def symbol(self, mapping, key):
         """Resolve symbol to value or function; None if nothing found"""
         v = None