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