# HG changeset patch # User Sune Foldager # Date 2012-06-26 21:05:25 # Node ID 6f89c3f0192ddb7b8e6529dfdb2d3f68442f6211 # Parent cd7db8e05c657fb08b51903fa2ef8c2246de1c4b fix push of moved bookmark when creating new branch heads The problem occured when pushing a changeset that at the same time creates a new named branch head and moves a bookmark. The code invoked methods that only exist on localrepo instances, so it failed for any other type of remote. The test suite only tested against local remotes. diff --git a/mercurial/discovery.py b/mercurial/discovery.py --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -225,7 +225,6 @@ def checkheads(repo, remote, outgoing, r # If there are more heads after the push than before, a suitable # error message, depending on unsynced status, is displayed. error = None - remotebookmarks = remote.listkeys('bookmarks') localbookmarks = repo._bookmarks for branch in branches: @@ -234,9 +233,14 @@ def checkheads(repo, remote, outgoing, r dhs = None if len(newhs) > len(oldhs): # strip updates to existing remote heads from the new heads list - bookmarkedheads = set([repo[bm].node() for bm in localbookmarks - if bm in remotebookmarks and - remote[bm] == repo[bm].ancestor(remote[bm])]) + remotebookmarks = remote.listkeys('bookmarks') + bookmarkedheads = set() + for bm in localbookmarks: + rnode = remotebookmarks.get(bm) + if rnode and rnode in repo: + lctx, rctx = repo[bm], repo[rnode] + if rctx == lctx.ancestor(rctx): + bookmarkedheads.add(lctx.node()) dhs = list(newhs - bookmarkedheads - oldhs) if dhs: if error is None: diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -177,8 +177,18 @@ diverging a remote bookmark fails adding f2 created new head $ hg book -f Y - $ hg push ../a - pushing to ../a + + $ cat < ../a/.hg/hgrc + > [web] + > push_ssl = false + > allow_push = * + > EOF + + $ hg -R ../a serve -p $HGPORT2 -d --pid-file=../hg2.pid + $ cat ../hg2.pid >> $DAEMON_PIDS + + $ hg push http://localhost:$HGPORT2/ + pushing to http://localhost:$HGPORT2/ searching for changes abort: push creates new remote head 4efff6d98829! (did you forget to merge? use push -f to force)