comparison 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
comparison
equal deleted inserted replaced
37073:44757e6dad93 37074:2891079fb0c0
611 self._defaults = defaults 611 self._defaults = defaults
612 self._resources = resources 612 self._resources = resources
613 self._aliasmap = _aliasrules.buildmap(aliases) 613 self._aliasmap = _aliasrules.buildmap(aliases)
614 self._cache = {} # key: (func, data) 614 self._cache = {} # key: (func, data)
615 615
616 def overlaymap(self, origmapping, newmapping):
617 """Create combined mapping from the original mapping and partial
618 mapping to override the original"""
619 mapping = origmapping.copy()
620 mapping.update(newmapping)
621 return mapping
622
616 def symbol(self, mapping, key): 623 def symbol(self, mapping, key):
617 """Resolve symbol to value or function; None if nothing found""" 624 """Resolve symbol to value or function; None if nothing found"""
618 v = None 625 v = None
619 if key not in self._resources.knownkeys(): 626 if key not in self._resources.knownkeys():
620 v = mapping.get(key) 627 v = mapping.get(key)