bookmarks: fix handling of multiple bookmarks with one to be deactivated
authorYuya Nishihara <yuya@tcha.org>
Sat, 09 Nov 2019 12:09:50 +0900
changeset 43598 2a8cd7edf409
parent 43596 0ad5d6c4bfad
child 43599 1c91576b88bb
bookmarks: fix handling of multiple bookmarks with one to be deactivated Before, "hg bookmark --inactive Z Y" would ignore "Y" if "Z" were currently active. I'm pretty sure it is a bug.
mercurial/bookmarks.py
tests/test-bookmarks.t
--- a/mercurial/bookmarks.py	Mon Nov 11 22:10:26 2019 +0900
+++ b/mercurial/bookmarks.py	Sat Nov 09 12:09:50 2019 +0900
@@ -965,7 +965,7 @@
             newact = mark
         if inactive and mark == repo._activebookmark:
             deactivate(repo)
-            return
+            continue
         tgt = cur
         if rev:
             ctx = scmutil.revsingle(repo, rev)
@@ -976,6 +976,10 @@
             changes.append((bm, None))
         changes.append((mark, tgt))
 
+    # nothing changed but for the one deactivated above
+    if not changes:
+        return
+
     if hiddenrev:
         repo.ui.warn(_(b"bookmarking hidden changeset %s\n") % hiddenrev)
 
--- a/tests/test-bookmarks.t	Mon Nov 11 22:10:26 2019 +0900
+++ b/tests/test-bookmarks.t	Sat Nov 09 12:09:50 2019 +0900
@@ -608,6 +608,17 @@
   $ hg bookmark --inactive Z
   $ hg bookmark Z
 
+deactivate current 'Z', but also add 'Y'
+
+  $ hg bookmark -d Y
+  $ hg bookmark --inactive Z Y
+  $ hg bookmark -l
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+     Z                         2:db815d6d32e6
+     x  y                      2:db815d6d32e6
+  $ hg bookmark Z
+
 test clone
 
   $ hg bookmark -r 2 -i @