comparison mercurial/localrepo.py @ 10910:78db9b7d9f65

prepush: backed out refactoring It has some problems in corner cases and will fail on a test recently introduced on stable. Will maybe be reintroduced later, in a better version.
author Sune Foldager <cryo@cyanite.org>
date Wed, 14 Apr 2010 19:43:19 +0200
parents dc097666de01
children 4327409c1303
comparison
equal deleted inserted replaced
10877:dc097666de01 10910:78db9b7d9f65
1498 ''' 1498 '''
1499 common = {} 1499 common = {}
1500 remote_heads = remote.heads() 1500 remote_heads = remote.heads()
1501 inc = self.findincoming(remote, common, remote_heads, force=force) 1501 inc = self.findincoming(remote, common, remote_heads, force=force)
1502 1502
1503 cl = self.changelog
1504 update, updated_heads = self.findoutgoing(remote, common, remote_heads) 1503 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1505 msng_cl, bases, heads = cl.nodesbetween(update, revs) 1504 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1506
1507 outgoingnodeset = set(msng_cl)
1508 # compute set of nodes which, if they were a head before, no longer are
1509 nolongeraheadnodeset = set(p for n in msng_cl for p in cl.parents(n))
1510 1505
1511 def checkbranch(lheads, rheads, branchname=None): 1506 def checkbranch(lheads, rheads, branchname=None):
1512 ''' 1507 '''
1513 check whether there are more local heads than remote heads on 1508 check whether there are more local heads than remote heads on
1514 a specific branch. 1509 a specific branch.
1515 1510
1516 lheads: local branch heads 1511 lheads: local branch heads
1517 rheads: remote branch heads 1512 rheads: remote branch heads
1518 ''' 1513 '''
1519 newlheads = [n for n in lheads if n in outgoingnodeset] 1514
1520 formerrheads = [n for n in rheads if n in nolongeraheadnodeset] 1515 warn = 0
1521 if len(newlheads) > len(formerrheads): 1516
1522 # we add more new heads than we demote former heads to non-head 1517 if len(lheads) > len(rheads):
1518 warn = 1
1519 else:
1520 # add local heads involved in the push
1521 updatelheads = [self.changelog.heads(x, lheads)
1522 for x in update]
1523 newheads = set(sum(updatelheads, [])) & set(lheads)
1524
1525 if not newheads:
1526 return True
1527
1528 # add heads we don't have or that are not involved in the push
1529 for r in rheads:
1530 if r in self.changelog.nodemap:
1531 desc = self.changelog.heads(r, heads)
1532 l = [h for h in heads if h in desc]
1533 if not l:
1534 newheads.add(r)
1535 else:
1536 newheads.add(r)
1537 if len(newheads) > len(rheads):
1538 warn = 1
1539
1540 if warn:
1523 if branchname is not None: 1541 if branchname is not None:
1524 msg = _("abort: push creates new remote heads" 1542 msg = _("abort: push creates new remote heads"
1525 " on branch '%s'!\n") % branchname 1543 " on branch '%s'!\n") % branchname
1526 else: 1544 else:
1527 msg = _("abort: push creates new remote heads!\n") 1545 msg = _("abort: push creates new remote heads!\n")
1581 self.ui.warn(_("note: unsynced remote changes!\n")) 1599 self.ui.warn(_("note: unsynced remote changes!\n"))
1582 1600
1583 1601
1584 if revs is None: 1602 if revs is None:
1585 # use the fast path, no race possible on push 1603 # use the fast path, no race possible on push
1586 nodes = cl.findmissing(common.keys()) 1604 nodes = self.changelog.findmissing(common.keys())
1587 cg = self._changegroup(nodes, 'push') 1605 cg = self._changegroup(nodes, 'push')
1588 else: 1606 else:
1589 cg = self.changegroupsubset(update, revs, 'push') 1607 cg = self.changegroupsubset(update, revs, 'push')
1590 return cg, remote_heads 1608 return cg, remote_heads
1591 1609