--- a/mercurial/formatter.py Thu Mar 15 21:49:33 2018 +0900
+++ b/mercurial/formatter.py Thu Mar 15 21:52:47 2018 +0900
@@ -394,14 +394,7 @@
if part not in self._parts:
return
ref = self._parts[part]
-
- props = {}
- # explicitly-defined fields precede templatekw
- props.update(item)
- if 'ctx' in item or 'fctx' in item:
- # but template resources must be always available
- props['revcache'] = {}
- self._out.write(self._t.render(ref, props))
+ self._out.write(self._t.render(ref, item))
def end(self):
baseformatter.end(self)
@@ -518,7 +511,10 @@
return get(self, context, mapping, key)
def populatemap(self, context, origmapping, newmapping):
- return {}
+ mapping = {}
+ if self._hasctx(newmapping):
+ mapping['revcache'] = {} # per-ctx cache
+ return mapping
def _getsome(self, context, mapping, key):
v = mapping.get(key)
@@ -526,6 +522,9 @@
return v
return self._resmap.get(key)
+ def _hasctx(self, mapping):
+ return 'ctx' in mapping or 'fctx' in mapping
+
def _getctx(self, context, mapping, key):
ctx = mapping.get('ctx')
if ctx is not None:
@@ -545,7 +544,7 @@
'ctx': _getctx,
'fctx': _getsome,
'repo': _getrepo,
- 'revcache': _getsome, # per-ctx cache; set later
+ 'revcache': _getsome,
'ui': _getsome,
}
_knownkeys = set(_gettermap.keys())