Mercurial > hg > mercurial-source
changeset 10912:3d7c20986027
merge with stable
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Wed, 14 Apr 2010 19:49:06 +0200 |
parents | 4327409c1303 (current diff) 29a83fb8c067 (diff) |
children | c9543bc6be16 |
files | mercurial/localrepo.py |
diffstat | 3 files changed, 102 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1519,13 +1519,14 @@ update, updated_heads = self.findoutgoing(remote, common, remote_heads) msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) - def checkbranch(lheads, rheads, branchname=None): + def checkbranch(lheads, rheads, lheadcnt, branchname=None): ''' check whether there are more local heads than remote heads on a specific branch. lheads: local branch heads rheads: remote branch heads + lheadcnt: total number of local branch heads ''' warn = 0 @@ -1560,7 +1561,7 @@ else: msg = _("abort: push creates new remote heads!\n") self.ui.warn(msg) - if len(lheads) > len(rheads): + if lheadcnt > len(rheads): self.ui.status(_("(did you forget to merge?" " use push -f to force)\n")) else: @@ -1586,12 +1587,16 @@ if remote.capable('branchmap'): remotebrheads = remote.branchmap() + lbrmap = self.branchmap() + localbrheads = {} if not revs: - localbrheads = self.branchmap() + for br, hds in lbrmap.iteritems(): + localbrheads[br] = (len(hds), hds) else: - localbrheads = {} ctxgen = (self[n] for n in msng_cl) self._updatebranchcache(localbrheads, ctxgen) + for br, hds in localbrheads.iteritems(): + localbrheads[br] = (len(lbrmap[br]), hds) newbranches = list(set(localbrheads) - set(remotebrheads)) if newbranches: # new branch requires --force @@ -1602,13 +1607,14 @@ # propose 'push -b .' in the msg too? self.ui.status(_("(use 'hg push -f' to force)\n")) return None, 0 - for branch, lheads in localbrheads.iteritems(): + for branch, x in localbrheads.iteritems(): if branch in remotebrheads: + headcnt, lheads = x rheads = remotebrheads[branch] - if not checkbranch(lheads, rheads, branch): + if not checkbranch(lheads, rheads, headcnt, branch): return None, 0 else: - if not checkbranch(heads, remote_heads): + if not checkbranch(heads, remote_heads, len(heads)): return None, 0 if inc:
--- a/tests/test-push-warn +++ b/tests/test-push-warn @@ -56,15 +56,15 @@ hg push -r 3 -r 4 ../c; echo $? hg push -f -r 3 -r 4 ../c; echo $? hg push -r 5 ../c; echo $? +hg in ../c -# issue 450 +echo % issue 450 hg init ../e hg push -r 0 ../e ; echo $? hg push -r 1 ../e ; echo $? cd .. -# issue 736 echo % issue 736 hg init f cd f @@ -264,4 +264,40 @@ hg push inner cd .. +echo % check prepush with new branch head and new child of former branch head +echo % but child is on different branch +hg init p +cd p +hg branch A +echo a0 >a +hg ci -Ama0 +echo a1 >a +hg ci -ma1 +hg up null +hg branch B +echo b0 >b +hg ci -Amb0 +echo b1 >b +hg ci -mb1 + +hg clone . inner + +hg up A +hg branch -f B +echo a3 >a +hg ci -ma3 +hg up 3 +hg branch -f A +echo b3 >b +hg ci -mb3 + +echo %% glog of local +hg glog --template "{rev}: {branches} {desc}\n" +echo %% glog of remote +hg glog -R inner --template "{rev}: {branches} {desc}\n" +echo %% outgoing +hg out inner --template "{rev}: {branches} {desc}\n" +hg push inner +cd .. + exit 0
--- a/tests/test-push-warn.out +++ b/tests/test-push-warn.out @@ -45,7 +45,7 @@ pushing to ../c searching for changes abort: push creates new remote heads on branch 'default'! -(you should pull and merge or use push -f to force) +(did you forget to merge? use push -f to force) 1 pushing to ../c searching for changes @@ -66,6 +66,10 @@ adding file changes added 1 changesets with 1 changes to 1 files (-1 heads) 0 +comparing with ../c +searching for changes +no changes found +% issue 450 pushing to ../e searching for changes adding changesets @@ -107,7 +111,7 @@ pushing to ../f 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) 1 % push replacement head on existing branches pushing to ../f @@ -254,3 +258,48 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files +% check prepush with new branch head and new child of former branch head +% but child is on different branch +marked working directory as branch A +adding a +0 files updated, 0 files merged, 1 files removed, 0 files unresolved +marked working directory as branch B +adding b +created new head +updating to branch B +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 1 files removed, 0 files unresolved +marked working directory as branch B +1 files updated, 0 files merged, 1 files removed, 0 files unresolved +marked working directory as branch A +%% glog of local +@ 5: A b3 +| +| o 4: B a3 +| | +o | 3: B b1 +| | +o | 2: B b0 + / +o 1: A a1 +| +o 0: A a0 + +%% glog of remote +@ 3: B b1 +| +o 2: B b0 + +o 1: A a1 +| +o 0: A a0 + +%% outgoing +comparing with inner +searching for changes +4: B a3 +5: A b3 +pushing to inner +searching for changes +abort: push creates new remote heads on branch 'A'! +(did you forget to merge? use push -f to force)