alu avatar alu committed cb516e7

bookmarks: fixes bug where a deleted bookmark may still be treated as current when track.current option is set

Comments (0)

Files changed (3)

hgext/bookmarks.py

     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:
             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

tests/test-bookmarks-current

 
 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
+

tests/test-bookmarks-current.out

 % 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.