changeset 43598:2a8cd7edf409

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Nov 2019 12:09:50 +0900
parents 0ad5d6c4bfad
children 1c91576b88bb
files mercurial/bookmarks.py tests/test-bookmarks.t
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 @