656 def query(expr): |
656 def query(expr): |
657 m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo)) |
657 m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo)) |
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)') |
675 def rstdoc(context, mapping, args): |
677 def rstdoc(context, mapping, args): |
676 """Format reStructuredText.""" |
678 """Format reStructuredText.""" |