# HG changeset patch # User Mads Kiilerich # Date 2012-12-24 12:26:13 # Node ID 730b769fb6347d8da3c9e0674e7133bdf61d7a36 # Parent 777084ac84167e3bdea45b5c00de1106cca36eef bookmarks: fix head selection for merge with two bookmarked heads A type mismatch caused the search for the other head to fail. The code is fragile, and instead it ended up using the 'first' bookmark head, but the ordering is undefined and it could thus randomly use the wrong bookmarkhead and fail with: $ hg up -q -C e@diverged $ hg merge abort: merging with a working directory ancestor has no effect diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4288,7 +4288,7 @@ def merge(ui, repo, node=None, **opts): if not node and repo._bookmarkcurrent: bmheads = repo.bookmarkheads(repo._bookmarkcurrent) - curhead = repo[repo._bookmarkcurrent] + curhead = repo[repo._bookmarkcurrent].node() if len(bmheads) == 2: if curhead == bmheads[0]: node = bmheads[1] diff --git a/tests/test-bookmarks-merge.t b/tests/test-bookmarks-merge.t --- a/tests/test-bookmarks-merge.t +++ b/tests/test-bookmarks-merge.t @@ -75,9 +75,27 @@ $ echo f > f $ hg commit -Am "f" adding f + $ hg bookmarks -r 4 "e@diverged" + $ hg up -q -C "e@diverged" + $ hg merge + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ hg parents + changeset: 4:a0546fcfe0fb + bookmark: e@diverged + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: d + + changeset: 5:26bee9c5bcf3 + bookmark: e + parent: 3:b8f96cf4688b + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: e + $ hg up -C e - 1 files updated, 0 files merged, 2 files removed, 0 files unresolved - $ hg bookmarks -r 4 "e@diverged" + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg bookmarks b 1:d2ae7f538514 c 3:b8f96cf4688b