[PATCH 3 of 5 STABLE V2] bookmarks: resolve divergent bookmark when moving across a branch

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


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1367374369 18000
#      Tue Apr 30 21:12:49 2013 -0500
# Branch stable
# Node ID 55c8b8426c80f44de13ab35d02f0a4bf1d9c642f
# Parent  e8ae72454bd511afa4cf6b4112c0bbcd51e98823
bookmarks: resolve divergent bookmark when moving across a branch

This patch resolves a single divergent bookmark if a divergent bookmark exists
in the target revision and it current bookmark is not an ancestor of the target
revision, else it would already be handled by the previous patch in this
series.

Test coverage is added.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -816,10 +816,18 @@
                     return
                 anc = repo.changelog.ancestors([repo[target].rev()])
                 bmctx = repo[marks[mark]]
                 divs = [repo[b].node() for b in marks
                         if b.split('@', 1)[0] == mark.split('@', 1)[0]]
+
+                # allow resolving a single divergent bookmark even if moving
+                # the bookmark across branches when a revision is specified
+                # that contains a divergent bookmark
+                if bmctx.rev() not in anc and target in divs:
+                    bookmarks.deletedivergent(repo, [target], mark)
+                    return
+
                 deletefrom = [b for b in divs
                               if repo[b].rev() in anc or b == target]
                 bookmarks.deletedivergent(repo, deletefrom, mark)
                 if bmctx.rev() in anc:
                     ui.status(_("moving bookmark '%s' forward from %s\n") %
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -609,5 +609,21 @@
   $ hg book
    * Z                         3:9ba5f110a0b3
      Z at 1                       1:925d80f479bb
      four                      3:9ba5f110a0b3
      should-end-on-two         2:db815d6d32e6
+
+test clearing only a single divergent bookmark across branches
+
+  $ hg book foo -r 1
+  $ 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 at 1                       1:925d80f479bb
+   * 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