Mercurial > hg
changeset 39585:990a0b071ea5
formatter: factor out function that detects node change and document it
This prepares for demand loading of ctx/fctx objects. With this change,
'revcache' is also recreated if 'node' value changes, which will be needed
to support loading of ctx from (repo, node) pair.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 07 Jun 2018 21:36:13 +0900 |
parents | 109b2c2d9942 |
children | b1239aeef4d9 |
files | mercurial/formatter.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/formatter.py Sat Sep 01 15:06:05 2018 +0900 +++ b/mercurial/formatter.py Thu Jun 07 21:36:13 2018 +0900 @@ -567,10 +567,9 @@ def populatemap(self, context, origmapping, newmapping): mapping = {} - if self._hasctx(newmapping): + if self._hasnodespec(newmapping): mapping['revcache'] = {} # per-ctx cache - if (('node' in origmapping or self._hasctx(origmapping)) - and ('node' in newmapping or self._hasctx(newmapping))): + if self._hasnodespec(origmapping) and self._hasnodespec(newmapping): orignode = templateutil.runsymbol(context, origmapping, 'node') mapping['originalnode'] = orignode return mapping @@ -581,8 +580,9 @@ return v return self._resmap.get(key) - def _hasctx(self, mapping): - return 'ctx' in mapping + def _hasnodespec(self, mapping): + """Test if context revision is set or unset in the given mapping""" + return 'node' in mapping or 'ctx' in mapping def formatter(ui, out, topic, opts): template = opts.get("template", "")