Patchwork [7,of,8] templater: add revbranches function

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

Comments

timeless@mozdev.org - Sept. 11, 2015, 3:36 a.m.
# 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}"}

Patch

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]