mercurial/templater.py
changeset 30008 e83f89d3b1f7
parent 29848 b1f69dbdd76b
child 30049 f18cc848b48e
--- a/mercurial/templater.py	Sat Sep 17 17:02:56 2016 +1000
+++ b/mercurial/templater.py	Fri Sep 23 08:15:05 2016 +0000
@@ -480,6 +480,20 @@
 
     return ''.join(chunks)
 
+@templatefunc('files(pattern)')
+def files(context, mapping, args):
+    """All files of the current changeset matching the pattern. See
+    :hg:`help patterns`."""
+    if not len(args) == 1:
+        # i18n: "files" is a keyword
+        raise error.ParseError(_("files expects one argument"))
+
+    raw = evalstring(context, mapping, args[0])
+    ctx = mapping['ctx']
+    m = ctx.match([raw])
+    files = list(ctx.matches(m))
+    return templatekw.showlist("file", files, **mapping)
+
 @templatefunc('fill(text[, width[, initialident[, hangindent]]])')
 def fill(context, mapping, args):
     """Fill many