--- a/mercurial/templater.py Tue Feb 11 21:10:00 2014 -0800
+++ b/mercurial/templater.py Tue Feb 11 21:04:12 2014 -0800
@@ -7,7 +7,7 @@
from i18n import _
import sys, os, re
-import util, config, templatefilters, parser, error
+import util, config, templatefilters, templatekw, parser, error
import types
import minirst
@@ -356,6 +356,32 @@
# ignore args[0] (the label string) since this is supposed to be a a no-op
yield _evalifliteral(args[1], context, mapping)
+def revset(context, mapping, args):
+ """usage: revset(query[, formatargs...])
+ """
+ if not len(args) > 0:
+ # i18n: "revset" is a keyword
+ raise error.ParseError(_("revset expects one or more arguments"))
+
+ raw = args[0][1]
+ ctx = mapping['ctx']
+ repo = ctx._repo
+
+ if len(args) > 1:
+ formatargs = list([a[0](context, mapping, a[1]) for a in args[1:]])
+ revs = repo.revs(raw, *formatargs)
+ revs = list([str(r) for r in revs])
+ else:
+ revsetcache = mapping['cache'].setdefault("revsetcache", {})
+ if raw in revsetcache:
+ revs = revsetcache[raw]
+ else:
+ revs = repo.revs(raw)
+ revs = list([str(r) for r in revs])
+ revsetcache[raw] = revs
+
+ return templatekw.showlist("revision", revs, **mapping)
+
def rstdoc(context, mapping, args):
if len(args) != 2:
# i18n: "rstdoc" is a keyword
@@ -454,6 +480,7 @@
"join": join,
"label": label,
"pad": pad,
+ "revset": revset,
"rstdoc": rstdoc,
"shortest": shortest,
"strip": strip,