# HG changeset patch # User Sune Foldager # Date 2010-03-26 16:02:36 # Node ID 01f097c4ae665a7c14af0aa7706cffa6dccfd4f6 # Parent fe39f0160c74315b70d02f3b423f86c39f4342b7 push: fix bug in prepush logic and its tests diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1575,9 +1575,8 @@ class localrepository(repo.repository): 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 --git a/tests/test-push-warn b/tests/test-push-warn --- a/tests/test-push-warn +++ b/tests/test-push-warn @@ -166,4 +166,32 @@ hg -R k ci -m merge 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 --git a/tests/test-push-warn.out b/tests/test-push-warn.out --- a/tests/test-push-warn.out +++ b/tests/test-push-warn.out @@ -100,7 +100,7 @@ abort: push creates new remote branches: 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 @@ 1 files updated, 0 files merged, 0 files (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)