bookmarks: clear active bookmark on non-linear update
authorMatt Mackall <mpm@selenic.com>
Tue, 14 Jul 2015 18:50:20 -0500
changeset 25789 95dc4b009f60
parent 25788 a36fd0993522
child 25790 db5b6a1c064d
bookmarks: clear active bookmark on non-linear update
mercurial/commands.py
tests/test-bookmarks.t
--- a/mercurial/commands.py	Tue Jul 14 16:23:57 2015 +0100
+++ b/mercurial/commands.py	Tue Jul 14 18:50:20 2015 -0500
@@ -6483,6 +6483,11 @@
     if not ret and movemarkfrom:
         if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
             ui.status(_("updating bookmark %s\n") % repo._activebookmark)
+        else:
+            # this can happen with a non-linear update
+            ui.status(_("(leaving bookmark %s)\n") %
+                      repo._activebookmark)
+            bookmarks.deactivate(repo)
     elif brev in repo._bookmarks:
         bookmarks.activate(repo, brev)
         ui.status(_("(activating bookmark %s)\n") % brev)
--- a/tests/test-bookmarks.t	Tue Jul 14 16:23:57 2015 +0100
+++ b/tests/test-bookmarks.t	Tue Jul 14 18:50:20 2015 -0500
@@ -673,6 +673,31 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     0
   
+test non-linear update not clearing active bookmark
+
+  $ hg up 1
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  (leaving bookmark four)
+  $ hg book drop
+  $ hg up -C
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (leaving bookmark drop)
+  $ hg sum
+  parent: 2:db815d6d32e6 
+   2
+  branch: default
+  bookmarks: should-end-on-two
+  commit: 2 unknown (clean)
+  update: 1 new changesets, 2 branch heads (merge)
+  phases: 4 draft
+  $ hg book
+     drop                      1:925d80f479bb
+     four                      3:9ba5f110a0b3
+     should-end-on-two         2:db815d6d32e6
+  $ hg book -d drop
+  $ hg up four
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark four)
 
 test clearing divergent bookmarks of linear ancestors