Patchwork [8,of,8] templater: add revbookmarks function

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

Comments

timeless@mozdev.org - Sept. 11, 2015, 3:36 a.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1441936419 14400
#      Thu Sep 10 21:53:39 2015 -0400
# Node ID 3f997e4c4948a327aca7155171417f6678189988
# Parent  7bd8bbb310c63c64c0b51187d095f867b6930ebd
templater: add revbookmarks function

revbookmarks takes a revision and returns its bookmarks

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

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -597,6 +597,13 @@ 
     ctx, repo = ctxrepo('revbranches', context, mapping, args)
     return ctx.branch()
 
+def revbookmarks(context, mapping, args):
+    """:revbookmarks(rev): Show bookmarks
+    See :hg:`help templates.bookmarks`."""
+    ctx, repo = ctxrepo('revbookmarks', context, mapping, args)
+    bookmarks = ctx.bookmarks()
+    return bookmarks
+
 def revset(context, mapping, args):
     """:revset(query[, formatargs...]): Execute a revision set query. See
     :hg:`help revset`."""
@@ -794,6 +801,7 @@ 
     "pad": pad,
     "revauthor": revauthor,
     "revbisect": revbisect,
+    "revbookmarks": revbookmarks,
     "revbranches": revbranches,
     "revdesc": revdesc,
     "revfiles": revfiles,
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -2122,6 +2122,10 @@ 
   $ hg log -r 0 --template '{revset("0::0") % "branch:\t{revision|revbranches}\n\n"}'
   branch:	default
   
+  $ hg bookmark mark -r 1
+  $ hg log -r 0 --template '{revset("1::1") % "bookmarks:\t{revision|revbookmarks}\n"}\n'
+  bookmarks:	mark
+  
   $ hg log -r . --template '{revdesc()}'
   hg: parse error: revdesc expects one argument
   [255]