##// END OF EJS Templates
templater: remember cache key of evaluated revset...
Yuya Nishihara -
r45082:1f81f680 default
parent child Browse files
Show More
@@ -658,17 +658,19 b' def revset(context, mapping, args):'
658 return m(repo)
658 return m(repo)
659
659
660 if len(args) > 1:
660 if len(args) > 1:
661 key = None # dynamically-created revs shouldn't be cached
661 formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]]
662 formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]]
662 revs = query(revsetlang.formatspec(raw, *formatargs))
663 revs = query(revsetlang.formatspec(raw, *formatargs))
663 else:
664 else:
664 cache = context.resource(mapping, b'cache')
665 cache = context.resource(mapping, b'cache')
665 revsetcache = cache.setdefault(b"revsetcache", {})
666 revsetcache = cache.setdefault(b"revsetcache", {})
666 if raw in revsetcache:
667 key = raw
667 revs = revsetcache[raw]
668 if key in revsetcache:
669 revs = revsetcache[key]
668 else:
670 else:
669 revs = query(raw)
671 revs = query(raw)
670 revsetcache[raw] = revs
672 revsetcache[key] = revs
671 return templateutil.revslist(repo, revs, name=b'revision')
673 return templateutil.revslist(repo, revs, name=b'revision', cachekey=key)
672
674
673
675
674 @templatefunc(b'rstdoc(text, style)')
676 @templatefunc(b'rstdoc(text, style)')
@@ -414,13 +414,18 b' class revslist(wrapped):'
414
414
415 If name specified, the revs will be rendered with the old-style list
415 If name specified, the revs will be rendered with the old-style list
416 template of the given name by default.
416 template of the given name by default.
417
418 The cachekey provides a hint to cache further computation on this
419 smartset. If the underlying smartset is dynamically created, the cachekey
420 should be None.
417 """
421 """
418
422
419 def __init__(self, repo, revs, name=None):
423 def __init__(self, repo, revs, name=None, cachekey=None):
420 assert isinstance(revs, smartset.abstractsmartset)
424 assert isinstance(revs, smartset.abstractsmartset)
421 self._repo = repo
425 self._repo = repo
422 self._revs = revs
426 self._revs = revs
423 self._name = name
427 self._name = name
428 self.cachekey = cachekey
424
429
425 def contains(self, context, mapping, item):
430 def contains(self, context, mapping, item):
426 rev = unwrapinteger(context, mapping, item)
431 rev = unwrapinteger(context, mapping, item)
General Comments 0
You need to be logged in to leave comments. Login now