Patchwork [5,of,8] templater: add revauthor function

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

Comments

timeless@mozdev.org - Sept. 11, 2015, 3:36 a.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1441936294 14400
#      Thu Sep 10 21:51:34 2015 -0400
# Node ID 92c2c986bd73dc949ab8e94cd319254973c4ba2c
# Parent  17cd87686306199b0f78748f5180602a56acd4a2
templater: add revauthor function

revauthor takes a revision and returns its author

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

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -577,6 +577,12 @@ 
     names = ns.names(repo, ctx.node())
     return names
 
+def revauthor(context, mapping, args):
+    """:revauthor(rev): Show author.
+    See :hg:`help templates.author`."""
+    ctx, repo = ctxrepo('revauthor', context, mapping, args)
+    return ctx.user()
+
 def revset(context, mapping, args):
     """:revset(query[, formatargs...]): Execute a revision set query. See
     :hg:`help revset`."""
@@ -772,6 +778,7 @@ 
     "label": label,
     "localdate": localdate,
     "pad": pad,
+    "revauthor": revauthor,
     "revdesc": revdesc,
     "revfiles": revfiles,
     "revset": revset,
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -2109,6 +2109,9 @@ 
   $ hg log -r 0 --template '{revset("2::2") % "tag:\t\t{revision|revtags}\n"}\n'
   tag:		tip
   
+  $ hg log -r 0 --template '{revset("0::0") % "user:\t{revision|revauthor}\n\n"}'
+  user:	test
+  
   $ hg log -r . --template '{revdesc()}'
   hg: parse error: revdesc expects one argument
   [255]