changeset 38538:2f7104984857

bookmarks: add support for log-like template keywords and functions This is basically the same as 5d9b765dbe15 "tags: unblock log-like template keywords and functions."
author Yuya Nishihara <yuya@tcha.org>
date Sun, 01 Jul 2018 22:22:07 +0900
parents a3be09e277e9
children b1bbff1dd99a
files mercurial/bookmarks.py tests/test-bookmarks.t
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Tue Jun 26 16:29:55 2018 -0700
+++ b/mercurial/bookmarks.py	Sun Jul 01 22:22:07 2018 +0900
@@ -923,11 +923,14 @@
     """
     opts = pycompat.byteskwargs(opts)
     fm = ui.formatter('bookmarks', opts)
+    contexthint = fm.contexthint('bookmark rev node active')
     hexfn = fm.hexfunc
     if len(bmarks) == 0 and fm.isplain():
         ui.status(_("no bookmarks set\n"))
     for bmark, (n, prefix, label) in sorted(bmarks.iteritems()):
         fm.startitem()
+        if 'ctx' in contexthint:
+            fm.context(ctx=repo[n])
         if not ui.quiet:
             fm.plain(' %s ' % prefix, label=label)
         fm.write('bookmark', '%s', bmark, label=label)
--- a/tests/test-bookmarks.t	Tue Jun 26 16:29:55 2018 -0700
+++ b/tests/test-bookmarks.t	Sun Jul 01 22:22:07 2018 +0900
@@ -77,6 +77,11 @@
   $ hg commit -m 1 --config "$TESTHOOK"
   test-hook-bookmark: X2:  f7b1eb17ad24730a1651fccd46c43826d1bbc2ac -> 925d80f479bb026b0fb3deb27503780b13f74123
 
+  $ hg bookmarks -T '{rev}:{node|shortest} {bookmark} {desc|firstline}\n'
+  0:f7b1 X 0
+  1:925d X2 1
+  -1:0000 Y 
+
   $ hg bookmarks -Tjson
   [
    {