Patchwork [3,of,8] templater: add revfiles function

login
register
mail settings
Submitter timeless@mozdev.org
Date Sept. 11, 2015, 3:36 a.m.
Message ID <227e1da16f2910dc058c.1441942601@waste.org>
Download mbox | patch
Permalink /patch/10480/
State Rejected
Headers show

Comments

timeless@mozdev.org - Sept. 11, 2015, 3:36 a.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1441936210 14400
#      Thu Sep 10 21:50:10 2015 -0400
# Node ID 227e1da16f2910dc058c18cb3ddbd69cc16deaa5
# Parent  cc0d4af57610091f9e637dd3a4b11f4ae6b78498
templater: add revfiles function

revfiles takes a revision and returns its files

for use like:
  {revset("...") % "{revision|revfiles}"}

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -560,6 +560,14 @@ 
     ctx, repo = ctxrepo('revdesc', context, mapping, args)
     return ctx.description().strip()
 
+def revfiles(context, mapping, args):
+    """:revfiles(rev): Show files.
+    See :hg:`help templates.files`."""
+    ctx, repo = ctxrepo('revfiles', context, mapping, args)
+    modified, added, removed = repo.status(ctx.p1(), ctx)[:3]
+    files = modified + added + removed
+    return templatekw.showlist("file", files, **mapping)
+
 def revset(context, mapping, args):
     """:revset(query[, formatargs...]): Execute a revision set query. See
     :hg:`help revset`."""
@@ -756,6 +764,7 @@ 
     "localdate": localdate,
     "pad": pad,
     "revdesc": revdesc,
+    "revfiles": revfiles,
     "revset": revset,
     "rstdoc": rstdoc,
     "shortest": shortest,
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -2102,6 +2102,10 @@ 
   $ hg log -r 0 --template '{revset("0::0") % "summary:\t{revision|revdesc|firstline}\n"}\n'
   summary:	A1B1C1
   
+  $ hg log -r 0 --template '{revset("1::1") % "changeset:\t{revision}\nfiles:\t{revision|revfiles}\n\n"}'
+  changeset:	1
+  files:	A B C
+  
   $ hg log -r . --template '{revdesc()}'
   hg: parse error: revdesc expects one argument
   [255]