Patchwork [1,of,4] bookmarks: fix handling of multiple bookmarks with one to be deactivated

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 9, 2019, 4:51 a.m.
Message ID <a5d3b2b0f3ddcb858e5d.1573275097@mimosa>
Download mbox | patch
Permalink /patch/43015/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 9, 2019, 4:51 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1573268990 -32400
#      Sat Nov 09 12:09:50 2019 +0900
# Node ID a5d3b2b0f3ddcb858e5d6416d571fa0e8870a6dd
# Parent  67e15214213b46f483bb2827a522d46b3142e61f
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.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -965,7 +965,7 @@  def addbookmarks(repo, tr, names, rev=No
             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 @@  def addbookmarks(repo, tr, names, rev=No
             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)
 
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -608,6 +608,17 @@  activate bookmark on working dir parent 
   $ 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 @