From patchwork Wed May 1 21:05:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 5, STABLE, V2] bookmarks: resolve divergent bookmark when moving across a branch From: Sean Farley X-Patchwork-Id: 1528 Message-Id: <55c8b8426c80f44de13a.1367442300@laptop.local> To: mercurial-devel@selenic.com Date: Wed, 01 May 2013 16:05:00 -0500 # HG changeset patch # User Sean Farley # 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@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