Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatefuncs.py @ 44599:1f81f680912f
templater: remember cache key of evaluated revset
This provides a hint for caching further computation result of the given
revset. See the next patch for example.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 15 Mar 2020 16:00:45 +0900 |
parents | fc1fa3a07af6 |
children | 7cd5c0968139 |
line wrap: on
line diff
--- a/mercurial/templatefuncs.py Sun Mar 15 22:01:38 2020 +0900 +++ b/mercurial/templatefuncs.py Sun Mar 15 16:00:45 2020 +0900 @@ -658,17 +658,19 @@ return m(repo) if len(args) > 1: + key = None # dynamically-created revs shouldn't be cached formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]] revs = query(revsetlang.formatspec(raw, *formatargs)) else: cache = context.resource(mapping, b'cache') revsetcache = cache.setdefault(b"revsetcache", {}) - if raw in revsetcache: - revs = revsetcache[raw] + key = raw + if key in revsetcache: + revs = revsetcache[key] else: revs = query(raw) - revsetcache[raw] = revs - return templateutil.revslist(repo, revs, name=b'revision') + revsetcache[key] = revs + return templateutil.revslist(repo, revs, name=b'revision', cachekey=key) @templatefunc(b'rstdoc(text, style)')