diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -230,12 +230,9 @@ def showcurrentbookmark(**args): 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): diff --git a/tests/test-bookmarks-current.t b/tests/test-bookmarks-current.t --- a/tests/test-bookmarks-current.t +++ b/tests/test-bookmarks-current.t @@ -193,3 +193,12 @@ analogous to hg book -i .hg/bookmarks.current + $ hg log -T '{activebookmark}\n' -r Z + Z + $ hg log -T '{bookmarks % "{active}\n"}' -r Z + Z