Mercurial > public > mercurial-scm > hg
diff mercurial/templatekw.py @ 25387:390a10b7843b
templatekw: display active bookmark more consistently (issue4552) (BC)
Previously, the template keyword '{activebookmark}' would only display the
active bookmark if it was also pointing to the working directory's parent.
Meanwhile, the '{active}' subkeyword of the '{bookmarks}' keyword displays
the active bookmark regardless of whether it also points to the working
directory's parent. This is confusing.
Consider the output of these two templates:
$ hg log -T '{activebookmark}\n' -r indent
$ hg log -T '{bookmarks % "{bookmark}"}\n' -r indent
indent
This is the current behavior that can arise after, eg, a pull moves a bookmark
out from under you. After this patch, the first template will also return the
active bookmark that points to a revision, even if it is not the current
parent of the working directory. A test has been added to show the new behavior.
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Wed, 15 Apr 2015 09:07:54 -0700 |
parents | f26efa4f0eff |
children | eb52de500d2a |
line wrap: on
line diff
--- a/mercurial/templatekw.py Sun May 24 18:30:27 2015 +0900 +++ b/mercurial/templatekw.py Wed Apr 15 09:07:54 2015 -0700 @@ -230,12 +230,9 @@ def showactivebookmark(**args): """:activetbookmark: String. The active bookmark, if it is associated with the changeset""" - import bookmarks as bookmarks # to avoid circular import issues - repo = args['repo'] - if bookmarks.isactivewdirparent(repo): - active = repo._activebookmark - if active in args['ctx'].bookmarks(): - return active + active = args['repo']._activebookmark + if active and active in args['ctx'].bookmarks(): + return active return '' def showdate(repo, ctx, templ, **args):