Mercurial > public > mercurial-scm > hg-stable
diff mercurial/formatter.py @ 39598:28f974d83c0a
templater: remove unused context argument from most resourcemapper functions
While working on demand loading of ctx/fctx objects, I noticed that it's quite
easy to create infinite recursion by carelessly using the template context in
the resource mapper. Let's make that not happen.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 07 Jun 2018 23:27:54 +0900 |
parents | 5b04a0c30f3f |
children | ee1e74ee037c |
line wrap: on
line diff
--- a/mercurial/formatter.py Mon Sep 10 20:57:18 2018 +0900 +++ b/mercurial/formatter.py Thu Jun 07 23:27:54 2018 +0900 @@ -548,18 +548,18 @@ 'ui': ui, } - def availablekeys(self, context, mapping): + def availablekeys(self, mapping): return {k for k, g in self._gettermap.iteritems() - if g(self, context, mapping, k) is not None} + if g(self, mapping, k) is not None} def knownkeys(self): return self._knownkeys - def lookup(self, context, mapping, key): + def lookup(self, mapping, key): get = self._gettermap.get(key) if not get: return None - return get(self, context, mapping, key) + return get(self, mapping, key) def populatemap(self, context, origmapping, newmapping): mapping = {} @@ -571,7 +571,7 @@ mapping['originalnode'] = orignode return mapping - def _getsome(self, context, mapping, key): + def _getsome(self, mapping, key): v = mapping.get(key) if v is not None: return v @@ -580,7 +580,7 @@ def _hasctx(self, mapping): return 'ctx' in mapping or 'fctx' in mapping - def _getctx(self, context, mapping, key): + def _getctx(self, mapping, key): ctx = mapping.get('ctx') if ctx is not None: return ctx @@ -588,11 +588,11 @@ if fctx is not None: return fctx.changectx() - def _getrepo(self, context, mapping, key): - ctx = self._getctx(context, mapping, 'ctx') + def _getrepo(self, mapping, key): + ctx = self._getctx(mapping, 'ctx') if ctx is not None: return ctx.repo() - return self._getsome(context, mapping, key) + return self._getsome(mapping, key) _gettermap = { 'cache': _getsome,