# HG changeset patch # User Sean Farley # Date 2013-05-01 02:12:49 # Node ID 6439d78e14fbc6103eeca115af509d23b5b7e17e # Parent 741d94aa92e4562f9ba3ac09a366e1e644ca3d16 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 @@ -818,6 +818,14 @@ def bookmark(ui, repo, mark=None, rev=No 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) diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -611,3 +611,19 @@ test clearing divergent bookmarks of lin 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