[PATCH 5 of 8] templater: add revauthor function
timeless at mozdev.org
timeless at mozdev.org
Thu Sep 10 22:36:43 CDT 2015
# HG changeset patch
# User timeless at 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}"}
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]
More information about the Mercurial-devel
mailing list