1491 common = {} |
1491 common = {} |
1492 remote_heads = remote.heads() |
1492 remote_heads = remote.heads() |
1493 inc = self.findincoming(remote, common, remote_heads, force=force) |
1493 inc = self.findincoming(remote, common, remote_heads, force=force) |
1494 |
1494 |
1495 update, updated_heads = self.findoutgoing(remote, common, remote_heads) |
1495 update, updated_heads = self.findoutgoing(remote, common, remote_heads) |
1496 if revs is not None: |
1496 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) |
1497 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) |
1497 |
1498 else: |
1498 def checkbranch(lheads, rheads, updatelb): |
1499 bases, heads = update, self.changelog.heads() |
|
1500 |
|
1501 def checkbranch(lheads, rheads, updatelh): |
|
1502 ''' |
1499 ''' |
1503 check whether there are more local heads than remote heads on |
1500 check whether there are more local heads than remote heads on |
1504 a specific branch. |
1501 a specific branch. |
1505 |
1502 |
1506 lheads: local branch heads |
1503 lheads: local branch heads |
1507 rheads: remote branch heads |
1504 rheads: remote branch heads |
1508 updatelh: outgoing local branch heads |
1505 updatelb: outgoing local branch bases |
1509 ''' |
1506 ''' |
1510 |
1507 |
1511 warn = 0 |
1508 warn = 0 |
1512 |
1509 |
1513 if not revs and len(lheads) > len(rheads): |
1510 if not revs and len(lheads) > len(rheads): |
1514 warn = 1 |
1511 warn = 1 |
1515 else: |
1512 else: |
|
1513 # add local heads involved in the push |
1516 updatelheads = [self.changelog.heads(x, lheads) |
1514 updatelheads = [self.changelog.heads(x, lheads) |
1517 for x in updatelh] |
1515 for x in updatelb] |
1518 newheads = set(sum(updatelheads, [])) & set(lheads) |
1516 newheads = set(sum(updatelheads, [])) & set(lheads) |
1519 |
1517 |
1520 if not newheads: |
1518 if not newheads: |
1521 return True |
1519 return True |
1522 |
1520 |
|
1521 # add heads we don't have or that are not involved in the push |
1523 for r in rheads: |
1522 for r in rheads: |
1524 if r in self.changelog.nodemap: |
1523 if r in self.changelog.nodemap: |
1525 desc = self.changelog.heads(r, heads) |
1524 desc = self.changelog.heads(r, heads) |
1526 l = [h for h in heads if h in desc] |
1525 l = [h for h in heads if h in desc] |
1527 if not l: |
1526 if not l: |
1533 |
1532 |
1534 if warn: |
1533 if warn: |
1535 if not rheads: # new branch requires --force |
1534 if not rheads: # new branch requires --force |
1536 self.ui.warn(_("abort: push creates new" |
1535 self.ui.warn(_("abort: push creates new" |
1537 " remote branch '%s'!\n") % |
1536 " remote branch '%s'!\n") % |
1538 self[updatelh[0]].branch()) |
1537 self[updatelb[0]].branch()) |
1539 else: |
1538 else: |
1540 self.ui.warn(_("abort: push creates new remote heads!\n")) |
1539 self.ui.warn(_("abort: push creates new remote heads!\n")) |
1541 |
1540 |
1542 self.ui.status(_("(did you forget to merge?" |
1541 self.ui.status(_("(did you forget to merge?" |
1543 " use push -f to force)\n")) |
1542 " use push -f to force)\n")) |
1576 if lh in remotehds: |
1575 if lh in remotehds: |
1577 rheads = remotehds[lh] |
1576 rheads = remotehds[lh] |
1578 else: |
1577 else: |
1579 rheads = [] |
1578 rheads = [] |
1580 lheads = localhds[lh] |
1579 lheads = localhds[lh] |
1581 updatelh = [upd for upd in update |
1580 updatelb = [upd for upd in update |
1582 if self[upd].branch() == lh] |
1581 if self[upd].branch() == lh] |
1583 if not updatelh: |
1582 if not updatelb: |
1584 continue |
1583 continue |
1585 if not checkbranch(lheads, rheads, updatelh): |
1584 if not checkbranch(lheads, rheads, updatelb): |
1586 return None, 0 |
1585 return None, 0 |
1587 else: |
1586 else: |
1588 if not checkbranch(heads, remote_heads, update): |
1587 if not checkbranch(heads, remote_heads, update): |
1589 return None, 0 |
1588 return None, 0 |
1590 |
1589 |