##// END OF EJS Templates
localrepo: refactor prepush logic...
Peter Arrenbrecht -
r10877:dc097666 default
parent child Browse files
Show More
@@ -1500,8 +1500,13 b' class localrepository(repo.repository):'
1500 1500 remote_heads = remote.heads()
1501 1501 inc = self.findincoming(remote, common, remote_heads, force=force)
1502 1502
1503 cl = self.changelog
1503 1504 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1504 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1505 msng_cl, bases, heads = cl.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))
1505 1510
1506 1511 def checkbranch(lheads, rheads, branchname=None):
1507 1512 '''
@@ -1511,33 +1516,10 b' class localrepository(repo.repository):'
1511 1516 lheads: local branch heads
1512 1517 rheads: remote branch heads
1513 1518 '''
1514
1515 warn = 0
1516
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:
1519 newlheads = [n for n in lheads if n in outgoingnodeset]
1520 formerrheads = [n for n in rheads if n in nolongeraheadnodeset]
1521 if len(newlheads) > len(formerrheads):
1522 # we add more new heads than we demote former heads to non-head
1541 1523 if branchname is not None:
1542 1524 msg = _("abort: push creates new remote heads"
1543 1525 " on branch '%s'!\n") % branchname
@@ -1601,7 +1583,7 b' class localrepository(repo.repository):'
1601 1583
1602 1584 if revs is None:
1603 1585 # use the fast path, no race possible on push
1604 nodes = self.changelog.findmissing(common.keys())
1586 nodes = cl.findmissing(common.keys())
1605 1587 cg = self._changegroup(nodes, 'push')
1606 1588 else:
1607 1589 cg = self.changegroupsubset(update, revs, 'push')
General Comments 0
You need to be logged in to leave comments. Login now