mercurial/localrepo.py
branchstable
changeset 10772 1e819576e926
parent 10771 01f097c4ae66
child 10773 bd36e5c0ccb1
child 10863 60b42f318a6d
equal deleted inserted replaced
10771:01f097c4ae66 10772:1e819576e926
  1501         inc = self.findincoming(remote, common, remote_heads, force=force)
  1501         inc = self.findincoming(remote, common, remote_heads, force=force)
  1502 
  1502 
  1503         update, updated_heads = self.findoutgoing(remote, common, remote_heads)
  1503         update, updated_heads = self.findoutgoing(remote, common, remote_heads)
  1504         msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
  1504         msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
  1505 
  1505 
  1506         def checkbranch(lheads, rheads, updatelb, branchname=None):
  1506         def checkbranch(lheads, rheads, branchname=None):
  1507             '''
  1507             '''
  1508             check whether there are more local heads than remote heads on
  1508             check whether there are more local heads than remote heads on
  1509             a specific branch.
  1509             a specific branch.
  1510 
  1510 
  1511             lheads: local branch heads
  1511             lheads: local branch heads
  1512             rheads: remote branch heads
  1512             rheads: remote branch heads
  1513             updatelb: outgoing local branch bases
       
  1514             '''
  1513             '''
  1515 
  1514 
  1516             warn = 0
  1515             warn = 0
  1517 
  1516 
  1518             if not revs and len(lheads) > len(rheads):
  1517             if len(lheads) > len(rheads):
  1519                 warn = 1
  1518                 warn = 1
  1520             else:
  1519             else:
  1521                 # add local heads involved in the push
       
  1522                 updatelheads = [self.changelog.heads(x, lheads)
       
  1523                                 for x in updatelb]
       
  1524                 newheads = set(sum(updatelheads, [])) & set(lheads)
       
  1525 
       
  1526                 if not newheads:
       
  1527                     return True
       
  1528 
       
  1529                 # add heads we don't have or that are not involved in the push
  1520                 # add heads we don't have or that are not involved in the push
       
  1521                 newheads = set(lheads)
  1530                 for r in rheads:
  1522                 for r in rheads:
  1531                     if r in self.changelog.nodemap:
  1523                     if r in self.changelog.nodemap:
  1532                         desc = self.changelog.heads(r, heads)
  1524                         desc = self.changelog.heads(r, heads)
  1533                         l = [h for h in heads if h in desc]
  1525                         l = [h for h in heads if h in desc]
  1534                         if not l:
  1526                         if not l:
  1588                         self.ui.status(_("(use 'hg push -f' to force)\n"))
  1580                         self.ui.status(_("(use 'hg push -f' to force)\n"))
  1589                         return None, 0
  1581                         return None, 0
  1590                     for branch, lheads in localbrheads.iteritems():
  1582                     for branch, lheads in localbrheads.iteritems():
  1591                         if branch in remotebrheads:
  1583                         if branch in remotebrheads:
  1592                             rheads = remotebrheads[branch]
  1584                             rheads = remotebrheads[branch]
  1593                             if not checkbranch(lheads, rheads, update, branch):
  1585                             if not checkbranch(lheads, rheads, branch):
  1594                                 return None, 0
  1586                                 return None, 0
  1595                 else:
  1587                 else:
  1596                     if not checkbranch(heads, remote_heads, update):
  1588                     if not checkbranch(heads, remote_heads):
  1597                         return None, 0
  1589                         return None, 0
  1598 
  1590 
  1599             if inc:
  1591             if inc:
  1600                 self.ui.warn(_("note: unsynced remote changes!\n"))
  1592                 self.ui.warn(_("note: unsynced remote changes!\n"))
  1601 
  1593