[PATCH 4 of 5 STABLE V2] bookmarks: fix bug that activated a bookmark even with -r passed

Sean Farley sean.michael.farley at gmail.com
Wed May 1 16:05:01 CDT 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1367439861 18000
#      Wed May 01 15:24:21 2013 -0500
# Branch stable
# Node ID 1d0fc3f943c59b8cc170d3d6dcd9c7429fc3b6bd
# Parent  55c8b8426c80f44de13ab35d02f0a4bf1d9c642f
bookmarks: fix bug that activated a bookmark even with -r passed

If the current revision was the target revision of -r, then the bookmark would
be active. Test cases have been updated accordingly.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -878,11 +878,11 @@
         tgt = cur
         if rev:
             tgt = scmutil.revsingle(repo, rev).node()
         checkconflict(repo, mark, force, tgt)
         marks[mark] = tgt
-        if not inactive and cur == marks[mark]:
+        if not inactive and cur == marks[mark] and not rev:
             bookmarks.setcurrent(repo, mark)
         elif cur != tgt and mark == repo._bookmarkcurrent:
             bookmarks.setcurrent(repo, None)
         marks.write()
 
diff --git a/tests/test-bookmarks-current.t b/tests/test-bookmarks-current.t
--- a/tests/test-bookmarks-current.t
+++ b/tests/test-bookmarks-current.t
@@ -89,18 +89,23 @@
 update to tip
 
   $ hg update tip
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-set bookmark Y using -r .
+set bookmark Y using -r . but make sure that the active
+bookmark is not activated
 
   $ hg bookmark -r . Y
 
-list bookmarks
+list bookmarks, Y should not be active
 
   $ hg bookmark
-   * Y                         0:719295282060
+     Y                         0:719295282060
+
+now, activate Y
+
+  $ hg up -q Y
 
 set bookmark Z using -i
 
   $ hg bookmark -r . -i Z
   $ hg bookmarks
diff --git a/tests/test-bookmarks-rebase.t b/tests/test-bookmarks-rebase.t
--- a/tests/test-bookmarks-rebase.t
+++ b/tests/test-bookmarks-rebase.t
@@ -24,10 +24,11 @@
   $ hg ci -A -m "3"
   adding d
 
   $ hg bookmark -r 1 one
   $ hg bookmark -r 3 two
+  $ hg up -q two
 
 bookmark list
 
   $ hg bookmark
      one                       1:925d80f479bb
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -155,10 +155,11 @@
      Z                         0:f7b1eb17ad24
 
 bookmarks from a revset
   $ hg bookmark -r '.^1' REVSET
   $ hg bookmark -r ':tip' TIP
+  $ hg up -q TIP
   $ hg bookmarks
      REVSET                    0:f7b1eb17ad24
    * TIP                       2:db815d6d32e6
      X2                        1:925d80f479bb
      Y                         2:db815d6d32e6
@@ -599,12 +600,12 @@
   $ hg bookmark Z at 3 -r 3
   $ hg book
      Z                         0:f7b1eb17ad24
      Z at 1                       1:925d80f479bb
      Z at 2                       2:db815d6d32e6
-   * Z at 3                       3:9ba5f110a0b3
-     four                      3:9ba5f110a0b3
+     Z at 3                       3:9ba5f110a0b3
+   * four                      3:9ba5f110a0b3
      should-end-on-two         2:db815d6d32e6
   $ hg bookmark Z
   moving bookmark 'Z' forward from f7b1eb17ad24
   $ hg book
    * Z                         3:9ba5f110a0b3
@@ -618,12 +619,12 @@
   $ hg book foo at 1 -r 0
   $ hg book foo at 2 -r 2
   $ hg book foo at 3 -r 3
   $ hg book foo -r foo at 3
   $ hg book
-     Z                         3:9ba5f110a0b3
+   * Z                         3:9ba5f110a0b3
      Z at 1                       1:925d80f479bb
-   * foo                       3:9ba5f110a0b3
+     foo                       3:9ba5f110a0b3
      foo at 1                     0:f7b1eb17ad24
      foo at 2                     2:db815d6d32e6
      four                      3:9ba5f110a0b3
      should-end-on-two         2:db815d6d32e6


More information about the Mercurial-devel mailing list