From patchwork Fri Sep 11 03:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,8] templater: add revbranches function From: timeless@mozdev.org X-Patchwork-Id: 10484 Message-Id: <7bd8bbb310c63c64c0b5.1441942605@waste.org> To: mercurial-devel@selenic.com Date: Thu, 10 Sep 2015 22:36:45 -0500 # HG changeset patch # User timeless@mozdev.org # Date 1441936391 14400 # Thu Sep 10 21:53:11 2015 -0400 # Node ID 7bd8bbb310c63c64c0b51187d095f867b6930ebd # Parent 9cc5be267d6ffe26daf24049c71eb5d5ab3bf1a3 templater: add revbranches function revbranches takes a revision and returns its branches for use like: {revset("...") % "{revision|revbranches}"} diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -591,6 +591,12 @@ ctx, repo = ctxrepo('revbisect', context, mapping, args) return hbisect.label(repo, ctx.node()) +def revbranches(context, mapping, args): + """:revbranches(rev): Show branches. + See :hg:`help templates.branch`.""" + ctx, repo = ctxrepo('revbranches', context, mapping, args) + return ctx.branch() + def revset(context, mapping, args): """:revset(query[, formatargs...]): Execute a revision set query. See :hg:`help revset`.""" @@ -788,6 +794,7 @@ "pad": pad, "revauthor": revauthor, "revbisect": revbisect, + "revbranches": revbranches, "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 @@ -2119,6 +2119,9 @@ bisect: bisect: good + $ hg log -r 0 --template '{revset("0::0") % "branch:\t{revision|revbranches}\n\n"}' + branch: default + $ hg log -r . --template '{revdesc()}' hg: parse error: revdesc expects one argument [255]