From patchwork Fri Sep 11 03:36:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5,of,8] templater: add revauthor function From: timeless@mozdev.org X-Patchwork-Id: 10482 Message-Id: <92c2c986bd73dc949ab8.1441942603@waste.org> To: mercurial-devel@selenic.com Date: Thu, 10 Sep 2015 22:36:43 -0500 # 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}"} 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]