comparison mercurial/localrepo.py @ 10911:4327409c1303

merge
author Sune Foldager <cryo@cyanite.org>
date Wed, 14 Apr 2010 19:43:40 +0200
parents 468876bc3885 78db9b7d9f65
children 3d7c20986027
comparison
equal deleted inserted replaced
10907:a6c4dd5175b5 10911:4327409c1303
1514 ''' 1514 '''
1515 common = {} 1515 common = {}
1516 remote_heads = remote.heads() 1516 remote_heads = remote.heads()
1517 inc = self.findincoming(remote, common, remote_heads, force=force) 1517 inc = self.findincoming(remote, common, remote_heads, force=force)
1518 1518
1519 cl = self.changelog
1520 update, updated_heads = self.findoutgoing(remote, common, remote_heads) 1519 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1521 msng_cl, bases, heads = cl.nodesbetween(update, revs) 1520 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1522
1523 outgoingnodeset = set(msng_cl)
1524 # compute set of nodes which, if they were a head before, no longer are
1525 nolongeraheadnodeset = set(p for n in msng_cl for p in cl.parents(n))
1526 1521
1527 def checkbranch(lheads, rheads, branchname=None): 1522 def checkbranch(lheads, rheads, branchname=None):
1528 ''' 1523 '''
1529 check whether there are more local heads than remote heads on 1524 check whether there are more local heads than remote heads on
1530 a specific branch. 1525 a specific branch.
1531 1526
1532 lheads: local branch heads 1527 lheads: local branch heads
1533 rheads: remote branch heads 1528 rheads: remote branch heads
1534 ''' 1529 '''
1535 newlheads = [n for n in lheads if n in outgoingnodeset] 1530
1536 formerrheads = [n for n in rheads if n in nolongeraheadnodeset] 1531 warn = 0
1537 if len(newlheads) > len(formerrheads): 1532
1538 # we add more new heads than we demote former heads to non-head 1533 if len(lheads) > len(rheads):
1534 warn = 1
1535 else:
1536 # add local heads involved in the push
1537 updatelheads = [self.changelog.heads(x, lheads)
1538 for x in update]
1539 newheads = set(sum(updatelheads, [])) & set(lheads)
1540
1541 if not newheads:
1542 return True
1543
1544 # add heads we don't have or that are not involved in the push
1545 for r in rheads:
1546 if r in self.changelog.nodemap:
1547 desc = self.changelog.heads(r, heads)
1548 l = [h for h in heads if h in desc]
1549 if not l:
1550 newheads.add(r)
1551 else:
1552 newheads.add(r)
1553 if len(newheads) > len(rheads):
1554 warn = 1
1555
1556 if warn:
1539 if branchname is not None: 1557 if branchname is not None:
1540 msg = _("abort: push creates new remote heads" 1558 msg = _("abort: push creates new remote heads"
1541 " on branch '%s'!\n") % branchname 1559 " on branch '%s'!\n") % branchname
1542 else: 1560 else:
1543 msg = _("abort: push creates new remote heads!\n") 1561 msg = _("abort: push creates new remote heads!\n")
1597 self.ui.warn(_("note: unsynced remote changes!\n")) 1615 self.ui.warn(_("note: unsynced remote changes!\n"))
1598 1616
1599 1617
1600 if revs is None: 1618 if revs is None:
1601 # use the fast path, no race possible on push 1619 # use the fast path, no race possible on push
1602 nodes = cl.findmissing(common.keys()) 1620 nodes = self.changelog.findmissing(common.keys())
1603 cg = self._changegroup(nodes, 'push') 1621 cg = self._changegroup(nodes, 'push')
1604 else: 1622 else:
1605 cg = self.changegroupsubset(update, revs, 'push') 1623 cg = self.changegroupsubset(update, revs, 'push')
1606 return cg, remote_heads 1624 return cg, remote_heads
1607 1625