[PATCH] bookmarks: clear active bookmark on non-linear update

Matt Mackall mpm at selenic.com
Tue Jul 14 18:51:10 CDT 2015


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1436917820 18000
#      Tue Jul 14 18:50:20 2015 -0500
# Node ID ed0cdd90ad5dabd0b77ead559e9ab12f150407cc
# Parent  f42a8b87a88a7a9abea28b96abdaea4a033f2031
bookmarks: clear active bookmark on non-linear update

diff -r f42a8b87a88a -r ed0cdd90ad5d mercurial/commands.py
--- 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)
diff -r f42a8b87a88a -r ed0cdd90ad5d tests/test-bookmarks.t
--- 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
 


More information about the Mercurial-devel mailing list