diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py --- a/hgext/bookmarks.py +++ b/hgext/bookmarks.py @@ -100,7 +100,7 @@ def setcurrent(repo, mark): refs = parse(repo) # do not update if we do update to a rev equal to the current bookmark - if (mark not in refs and + if (mark and mark not in refs and current(repo) and refs[current(repo)] == repo.changectx('.').node()): return if mark not in refs: @@ -146,6 +146,8 @@ def bookmark(ui, repo, mark=None, rev=No raise util.Abort(_("bookmark name required")) if mark not in marks: raise util.Abort(_("a bookmark of this name does not exist")) + if mark == current(repo): + setcurrent(repo, None) del marks[mark] write(repo, marks) return diff --git a/tests/test-bookmarks-current b/tests/test-bookmarks-current --- a/tests/test-bookmarks-current +++ b/tests/test-bookmarks-current @@ -42,3 +42,14 @@ hg commit -m'test' echo % list bookmarks hg bookmark + +echo % delete bookmarks +hg bookmark -d Y +hg bookmark -d Z + +echo % list bookmarks +hg bookmark + +echo % update to tip +hg update tip + diff --git a/tests/test-bookmarks-current.out b/tests/test-bookmarks-current.out --- a/tests/test-bookmarks-current.out +++ b/tests/test-bookmarks-current.out @@ -18,3 +18,8 @@ 0 files updated, 0 files merged, 0 files % list bookmarks * Y 0:719295282060 Z -1:000000000000 +% delete bookmarks +% list bookmarks +no bookmarks set +% update to tip +0 files updated, 0 files merged, 0 files removed, 0 files unresolved