[PATCH 2 of 4] templatekw: introduce active subkeyword from bookmarks keyword

Ryan McElroy rmcelroy at fb.com
Fri May 29 12:22:51 CDT 2015


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1432868622 25200
#      Thu May 28 20:03:42 2015 -0700
# Node ID d3f11c27efe7c16820bef650f7cef6cd0dfd72ef
# Parent  a02a25350ccfb544f48a554ad60bee91263771f4
templatekw: introduce active subkeyword from bookmarks keyword

Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.

diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt
--- a/mercurial/help/templates.txt
+++ b/mercurial/help/templates.txt
@@ -90,9 +90,9 @@ Some sample command line templates:
 
    $ hg log -r 0 --template "{join(extras, '\n')}\n"
 
-- Mark the current bookmark with '*'::
+- Mark the active bookmark with '*'::
 
-   $ hg log --template "{bookmarks % '{bookmark}{ifeq(bookmark, current, \"*\")} '}\n"
+   $ hg log --template "{bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n"
 
 - Mark the working copy parent with '@'::
 
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -206,12 +206,12 @@ def showbranches(**args):
 
 def showbookmarks(**args):
     """:bookmarks: List of strings. Any bookmarks associated with the
-    changeset.
+    changeset. Also sets 'active', the name of the active bookmark.
     """
     repo = args['ctx']._repo
     bookmarks = args['ctx'].bookmarks()
-    current = repo._activebookmark
-    makemap = lambda v: {'bookmark': v, 'current': current}
+    active = repo._activebookmark
+    makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
     f = _showlist('bookmark', bookmarks, **args)
     return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark'])
 
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -3086,7 +3086,7 @@ Test current bookmark templating
 
   $ hg book foo
   $ hg book bar
-  $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, current, \"*\")} '}\n"
+  $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n"
   2 bar* foo 
   1 
   0 


More information about the Mercurial-devel mailing list