5faf9b0ae984

bookmarks: check if bookmark is actually current

Mercurial doesn't remove the bookmarks.current file when updating away
from a bookmark, and repo._bookmarkcurrent() doesn't check whether the
bookmark read from bookmarks.current is actually current.

This patch prevents hg-prompt from reporting a current bookmark when the
bookmark in bookmarks.current isn't actually the working directory's
first parent. This matches the behavior of the `hg bookmarks` command.
[view raw] [browse files]
author Kevin Bullock <kbullock@umn.edu>
date Tue, 05 Jul 2011 14:19:52 -0500
parents c4095c3519d6
children 661dbd42f386
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Wed Mar 23 15:42:04 2011 -0400
+++ b/prompt.py	Tue Jul 05 14:19:52 2011 -0500
@@ -103,7 +103,12 @@
             book = getattr(repo, '_bookmarkcurrent', None)
         except KeyError:
             book = getattr(repo, '_bookmarkcurrent', None)
-        return _with_groups(m.groups(), book) if book else ''
+        if book:
+            cur = repo['.'].node()
+            if repo._bookmarks[book] == cur:
+                return _with_groups(m.groups(), book)
+        else:
+            return ''
 
     def _branch(m):
         g = m.groups()