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.
--- a/mercurial/help/templates.txt Thu Apr 16 15:18:59 2015 -0700
+++ b/mercurial/help/templates.txt Thu May 28 20:03:42 2015 -0700
@@ -90,9 +90,9 @@
$ 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 '@'::
--- a/mercurial/templatekw.py Thu Apr 16 15:18:59 2015 -0700
+++ b/mercurial/templatekw.py Thu May 28 20:03:42 2015 -0700
@@ -206,12 +206,12 @@
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'])
--- a/tests/test-command-template.t Thu Apr 16 15:18:59 2015 -0700
+++ b/tests/test-command-template.t Thu May 28 20:03:42 2015 -0700
@@ -3086,7 +3086,7 @@
$ 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