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