Show More
@@ -1503,13 +1503,14 b' class localrepository(repo.repository):' | |||||
1503 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) |
|
1503 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) | |
1504 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) |
|
1504 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) | |
1505 |
|
1505 | |||
1506 | def checkbranch(lheads, rheads, branchname=None): |
|
1506 | def checkbranch(lheads, rheads, lheadcnt, branchname=None): | |
1507 | ''' |
|
1507 | ''' | |
1508 | check whether there are more local heads than remote heads on |
|
1508 | check whether there are more local heads than remote heads on | |
1509 | a specific branch. |
|
1509 | a specific branch. | |
1510 |
|
1510 | |||
1511 | lheads: local branch heads |
|
1511 | lheads: local branch heads | |
1512 | rheads: remote branch heads |
|
1512 | rheads: remote branch heads | |
|
1513 | lheadcnt: total number of local branch heads | |||
1513 | ''' |
|
1514 | ''' | |
1514 |
|
1515 | |||
1515 | warn = 0 |
|
1516 | warn = 0 | |
@@ -1544,7 +1545,7 b' class localrepository(repo.repository):' | |||||
1544 | else: |
|
1545 | else: | |
1545 | msg = _("abort: push creates new remote heads!\n") |
|
1546 | msg = _("abort: push creates new remote heads!\n") | |
1546 | self.ui.warn(msg) |
|
1547 | self.ui.warn(msg) | |
1547 |
if l |
|
1548 | if lheadcnt > len(rheads): | |
1548 | self.ui.status(_("(did you forget to merge?" |
|
1549 | self.ui.status(_("(did you forget to merge?" | |
1549 | " use push -f to force)\n")) |
|
1550 | " use push -f to force)\n")) | |
1550 | else: |
|
1551 | else: | |
@@ -1570,12 +1571,16 b' class localrepository(repo.repository):' | |||||
1570 | if remote.capable('branchmap'): |
|
1571 | if remote.capable('branchmap'): | |
1571 | remotebrheads = remote.branchmap() |
|
1572 | remotebrheads = remote.branchmap() | |
1572 |
|
1573 | |||
|
1574 | lbrmap = self.branchmap() | |||
|
1575 | localbrheads = {} | |||
1573 | if not revs: |
|
1576 | if not revs: | |
1574 | localbrheads = self.branchmap() |
|
1577 | for br, hds in lbrmap.iteritems(): | |
|
1578 | localbrheads[br] = (len(hds), hds) | |||
1575 | else: |
|
1579 | else: | |
1576 | localbrheads = {} |
|
|||
1577 | ctxgen = (self[n] for n in msng_cl) |
|
1580 | ctxgen = (self[n] for n in msng_cl) | |
1578 | self._updatebranchcache(localbrheads, ctxgen) |
|
1581 | self._updatebranchcache(localbrheads, ctxgen) | |
|
1582 | for br, hds in localbrheads.iteritems(): | |||
|
1583 | localbrheads[br] = (len(lbrmap[br]), hds) | |||
1579 |
|
1584 | |||
1580 | newbranches = list(set(localbrheads) - set(remotebrheads)) |
|
1585 | newbranches = list(set(localbrheads) - set(remotebrheads)) | |
1581 | if newbranches: # new branch requires --force |
|
1586 | if newbranches: # new branch requires --force | |
@@ -1586,13 +1591,14 b' class localrepository(repo.repository):' | |||||
1586 | # propose 'push -b .' in the msg too? |
|
1591 | # propose 'push -b .' in the msg too? | |
1587 | self.ui.status(_("(use 'hg push -f' to force)\n")) |
|
1592 | self.ui.status(_("(use 'hg push -f' to force)\n")) | |
1588 | return None, 0 |
|
1593 | return None, 0 | |
1589 |
for branch, |
|
1594 | for branch, x in localbrheads.iteritems(): | |
1590 | if branch in remotebrheads: |
|
1595 | if branch in remotebrheads: | |
|
1596 | headcnt, lheads = x | |||
1591 | rheads = remotebrheads[branch] |
|
1597 | rheads = remotebrheads[branch] | |
1592 | if not checkbranch(lheads, rheads, branch): |
|
1598 | if not checkbranch(lheads, rheads, headcnt, branch): | |
1593 | return None, 0 |
|
1599 | return None, 0 | |
1594 | else: |
|
1600 | else: | |
1595 | if not checkbranch(heads, remote_heads): |
|
1601 | if not checkbranch(heads, remote_heads, len(heads)): | |
1596 | return None, 0 |
|
1602 | return None, 0 | |
1597 |
|
1603 | |||
1598 | if inc: |
|
1604 | if inc: |
@@ -56,15 +56,15 b' hg push -r 3 ../c; echo $?' | |||||
56 | hg push -r 3 -r 4 ../c; echo $? |
|
56 | hg push -r 3 -r 4 ../c; echo $? | |
57 | hg push -f -r 3 -r 4 ../c; echo $? |
|
57 | hg push -f -r 3 -r 4 ../c; echo $? | |
58 | hg push -r 5 ../c; echo $? |
|
58 | hg push -r 5 ../c; echo $? | |
|
59 | hg in ../c | |||
59 |
|
60 | |||
60 |
|
|
61 | echo % issue 450 | |
61 | hg init ../e |
|
62 | hg init ../e | |
62 | hg push -r 0 ../e ; echo $? |
|
63 | hg push -r 0 ../e ; echo $? | |
63 | hg push -r 1 ../e ; echo $? |
|
64 | hg push -r 1 ../e ; echo $? | |
64 |
|
65 | |||
65 | cd .. |
|
66 | cd .. | |
66 |
|
67 | |||
67 | # issue 736 |
|
|||
68 | echo % issue 736 |
|
68 | echo % issue 736 | |
69 | hg init f |
|
69 | hg init f | |
70 | cd f |
|
70 | cd f |
@@ -45,7 +45,7 b' 0' | |||||
45 | pushing to ../c |
|
45 | pushing to ../c | |
46 | searching for changes |
|
46 | searching for changes | |
47 | abort: push creates new remote heads on branch 'default'! |
|
47 | abort: push creates new remote heads on branch 'default'! | |
48 |
( |
|
48 | (did you forget to merge? use push -f to force) | |
49 | 1 |
|
49 | 1 | |
50 | pushing to ../c |
|
50 | pushing to ../c | |
51 | searching for changes |
|
51 | searching for changes | |
@@ -66,6 +66,10 b' adding manifests' | |||||
66 | adding file changes |
|
66 | adding file changes | |
67 | added 1 changesets with 1 changes to 1 files (-1 heads) |
|
67 | added 1 changesets with 1 changes to 1 files (-1 heads) | |
68 | 0 |
|
68 | 0 | |
|
69 | comparing with ../c | |||
|
70 | searching for changes | |||
|
71 | no changes found | |||
|
72 | % issue 450 | |||
69 | pushing to ../e |
|
73 | pushing to ../e | |
70 | searching for changes |
|
74 | searching for changes | |
71 | adding changesets |
|
75 | adding changesets | |
@@ -107,7 +111,7 b' 1' | |||||
107 | pushing to ../f |
|
111 | pushing to ../f | |
108 | searching for changes |
|
112 | searching for changes | |
109 | abort: push creates new remote heads on branch 'a'! |
|
113 | abort: push creates new remote heads on branch 'a'! | |
110 |
( |
|
114 | (did you forget to merge? use push -f to force) | |
111 | 1 |
|
115 | 1 | |
112 | % push replacement head on existing branches |
|
116 | % push replacement head on existing branches | |
113 | pushing to ../f |
|
117 | pushing to ../f |
General Comments 0
You need to be logged in to leave comments.
Login now