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.
--- a/mercurial/commands.py Wed May 01 15:34:45 2013 -0500
+++ b/mercurial/commands.py Tue Apr 30 21:12:49 2013 -0500
@@ -818,6 +818,14 @@
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)
--- a/tests/test-bookmarks.t Wed May 01 15:34:45 2013 -0500
+++ b/tests/test-bookmarks.t Tue Apr 30 21:12:49 2013 -0500
@@ -611,3 +611,19 @@
Z@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@1 -r 0
+ $ hg book foo@2 -r 2
+ $ hg book foo@3 -r 3
+ $ hg book foo -r foo@3
+ $ hg book
+ Z 3:9ba5f110a0b3
+ Z@1 1:925d80f479bb
+ * foo 3:9ba5f110a0b3
+ foo@1 0:f7b1eb17ad24
+ foo@2 2:db815d6d32e6
+ four 3:9ba5f110a0b3
+ should-end-on-two 2:db815d6d32e6