# HG changeset patch # User Sune Foldager # Date 1269619356 -3600 # Node ID 01f097c4ae665a7c14af0aa7706cffa6dccfd4f6 # Parent fe39f0160c74315b70d02f3b423f86c39f4342b7 push: fix bug in prepush logic and its tests diff -r fe39f0160c74 -r 01f097c4ae66 mercurial/localrepo.py --- a/mercurial/localrepo.py Fri Mar 26 17:02:23 2010 +0100 +++ b/mercurial/localrepo.py Fri Mar 26 17:02:36 2010 +0100 @@ -1575,9 +1575,8 @@ localbrheads = self.branchmap() else: localbrheads = {} - for n in heads: - branch = self[n].branch() - localbrheads.setdefault(branch, []).append(n) + ctxgen = (self[n] for n in msng_cl) + self._updatebranchcache(localbrheads, ctxgen) newbranches = list(set(localbrheads) - set(remotebrheads)) if newbranches: # new branch requires --force diff -r fe39f0160c74 -r 01f097c4ae66 tests/test-push-warn --- a/tests/test-push-warn Fri Mar 26 17:02:23 2010 +0100 +++ b/tests/test-push-warn Fri Mar 26 17:02:36 2010 +0100 @@ -166,4 +166,32 @@ hg -R k push -r a j echo +echo % prepush -r should not allow you to sneak in new heads +hg init l +cd l +echo a >> foo +hg -q add foo +hg -q branch a +hg -q ci -d '0 0' -ma +hg -q up null +echo a >> foo +hg -q add foo +hg -q branch b +hg -q ci -d '0 0' -mb +cd .. +hg -q clone l m -u a +cd m +hg -q merge b +hg -q ci -d '0 0' -mmb +hg -q up 0 +echo a >> foo +hg -q ci -ma2 +hg -q up 2 +echo a >> foo +hg -q branch -f b +hg -q ci -d '0 0' -mb2 +hg -q merge 3 +hg -q ci -d '0 0' -mma +hg push ../l -b b + exit 0 diff -r fe39f0160c74 -r 01f097c4ae66 tests/test-push-warn.out --- a/tests/test-push-warn.out Fri Mar 26 17:02:23 2010 +0100 +++ b/tests/test-push-warn.out Fri Mar 26 17:02:36 2010 +0100 @@ -100,7 +100,7 @@ 1 pushing to ../f searching for changes -abort: push creates new remote branches: d! +abort: push creates new remote branches: c, d! (use 'hg push -f' to force) 1 % fail on multiple head push @@ -167,6 +167,11 @@ (branch merge, don't forget to commit) pushing to j searching for changes +abort: push creates new remote branches: b! +(use 'hg push -f' to force) + +% prepush -r should not allow you to sneak in new heads +pushing to ../l +searching for changes abort: push creates new remote heads on branch 'a'! -(you should pull and merge or use push -f to force) - +(did you forget to merge? use push -f to force)