##// END OF EJS Templates
merge with stable
Sune Foldager -
r10926:4d81cbd8 merge default
parent child Browse files
Show More
@@ -1514,110 +1514,106 b' class localrepository(repo.repository):'
1514 remote_heads = remote.heads()
1514 remote_heads = remote.heads()
1515 inc = self.findincoming(remote, common, remote_heads, force=force)
1515 inc = self.findincoming(remote, common, remote_heads, force=force)
1516
1516
1517 cl = self.changelog
1517 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1518 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1518 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1519 outg, bases, heads = cl.nodesbetween(update, revs)
1519
1520 def checkbranch(lheads, rheads, lheadcnt, branchname=None):
1521 '''
1522 check whether there are more local heads than remote heads on
1523 a specific branch.
1524
1525 lheads: local branch heads
1526 rheads: remote branch heads
1527 lheadcnt: total number of local branch heads
1528 '''
1529
1530 warn = 0
1531
1532 if len(lheads) > len(rheads):
1533 warn = 1
1534 else:
1535 # add local heads involved in the push
1536 updatelheads = [self.changelog.heads(x, lheads)
1537 for x in update]
1538 newheads = set(sum(updatelheads, [])) & set(lheads)
1539
1540 if not newheads:
1541 return True
1542
1543 # add heads we don't have or that are not involved in the push
1544 for r in rheads:
1545 if r in self.changelog.nodemap:
1546 desc = self.changelog.heads(r, heads)
1547 l = [h for h in heads if h in desc]
1548 if not l:
1549 newheads.add(r)
1550 else:
1551 newheads.add(r)
1552 if len(newheads) > len(rheads):
1553 warn = 1
1554
1555 if warn:
1556 if branchname is not None:
1557 msg = _("abort: push creates new remote heads"
1558 " on branch '%s'!\n") % branchname
1559 else:
1560 msg = _("abort: push creates new remote heads!\n")
1561 self.ui.warn(msg)
1562 if lheadcnt > len(rheads):
1563 self.ui.status(_("(did you forget to merge?"
1564 " use push -f to force)\n"))
1565 else:
1566 self.ui.status(_("(you should pull and merge or"
1567 " use push -f to force)\n"))
1568 return False
1569 return True
1570
1520
1571 if not bases:
1521 if not bases:
1572 self.ui.status(_("no changes found\n"))
1522 self.ui.status(_("no changes found\n"))
1573 return None, 1
1523 return None, 1
1574 elif not force:
1524
1575 # Check for each named branch if we're creating new remote heads.
1525 if not force and remote_heads != [nullid]:
1576 # To be a remote head after push, node must be either:
1526
1577 # - unknown locally
1527 def fail_multiple_heads(unsynced, branch=None):
1578 # - a local outgoing head descended from update
1528 if branch:
1579 # - a remote head that's known locally and not
1529 msg = _("abort: push creates new remote heads"
1580 # ancestral to an outgoing head
1530 " on branch '%s'!\n") % branch
1581 #
1531 else:
1582 # New named branches cannot be created without --force.
1532 msg = _("abort: push creates new remote heads!\n")
1533 self.ui.warn(msg)
1534 if unsynced:
1535 self.ui.status(_("(you should pull and merge or"
1536 " use push -f to force)\n"))
1537 else:
1538 self.ui.status(_("(did you forget to merge?"
1539 " use push -f to force)\n"))
1540 return None, 0
1583
1541
1584 if remote_heads != [nullid]:
1542 if remote.capable('branchmap'):
1585 if remote.capable('branchmap'):
1543 # Check for each named branch if we're creating new remote heads.
1586 remotebrheads = remote.branchmap()
1544 # To be a remote head after push, node must be either:
1545 # - unknown locally
1546 # - a local outgoing head descended from update
1547 # - a remote head that's known locally and not
1548 # ancestral to an outgoing head
1549 #
1550 # New named branches cannot be created without --force.
1551
1552 # 1. Create set of branches involved in the push.
1553 branches = set(self[n].branch() for n in outg)
1554
1555 # 2. Check for new branches on the remote.
1556 remotemap = remote.branchmap()
1557 newbranches = branches - set(remotemap)
1558 if newbranches: # new branch requires --force
1559 branchnames = ', '.join("%s" % b for b in newbranches)
1560 self.ui.warn(_("abort: push creates "
1561 "new remote branches: %s!\n")
1562 % branchnames)
1563 self.ui.status(_("(use 'hg push -f' to force)\n"))
1564 return None, 0
1587
1565
1588 lbrmap = self.branchmap()
1566 # 3. Construct the initial oldmap and newmap dicts.
1589 localbrheads = {}
1567 # They contain information about the remote heads before and
1590 if not revs:
1568 # after the push, respectively.
1591 for br, hds in lbrmap.iteritems():
1569 # Heads not found locally are not included in either dict,
1592 localbrheads[br] = (len(hds), hds)
1570 # since they won't be affected by the push.
1593 else:
1571 # unsynced contains all branches with incoming changesets.
1594 ctxgen = (self[n] for n in msng_cl)
1572 oldmap = {}
1595 self._updatebranchcache(localbrheads, ctxgen)
1573 newmap = {}
1596 for br, hds in localbrheads.iteritems():
1574 unsynced = set()
1597 localbrheads[br] = (len(lbrmap[br]), hds)
1575 for branch in branches:
1576 remoteheads = remotemap[branch]
1577 prunedheads = [h for h in remoteheads if h in cl.nodemap]
1578 oldmap[branch] = prunedheads
1579 newmap[branch] = list(prunedheads)
1580 if len(remoteheads) > len(prunedheads):
1581 unsynced.add(branch)
1582
1583 # 4. Update newmap with outgoing changes.
1584 # This will possibly add new heads and remove existing ones.
1585 ctxgen = (self[n] for n in outg)
1586 self._updatebranchcache(newmap, ctxgen)
1598
1587
1599 newbranches = list(set(localbrheads) - set(remotebrheads))
1588 # 5. Check for new heads.
1600 if newbranches: # new branch requires --force
1589 # If there are more heads after the push than before, a suitable
1601 branchnames = ', '.join("%s" % b for b in newbranches)
1590 # warning, depending on unsynced status, is displayed.
1602 self.ui.warn(_("abort: push creates "
1591 for branch in branches:
1603 "new remote branches: %s!\n")
1592 if len(newmap[branch]) > len(oldmap[branch]):
1604 % branchnames)
1593 return fail_multiple_heads(branch in unsynced, branch)
1605 # propose 'push -b .' in the msg too?
1594
1606 self.ui.status(_("(use 'hg push -f' to force)\n"))
1595 # 6. Check for unsynced changes on involved branches.
1607 return None, 0
1596 if unsynced:
1608 for branch, x in localbrheads.iteritems():
1597 self.ui.warn(_("note: unsynced remote changes!\n"))
1609 if branch in remotebrheads:
1610 headcnt, lheads = x
1611 rheads = remotebrheads[branch]
1612 if not checkbranch(lheads, rheads, headcnt, branch):
1613 return None, 0
1614 else:
1615 if not checkbranch(heads, remote_heads, len(heads)):
1616 return None, 0
1617
1598
1618 if inc:
1599 else:
1619 self.ui.warn(_("note: unsynced remote changes!\n"))
1600 # Old servers: Check for new topological heads.
1620
1601 # Code based on _updatebranchcache.
1602 newheads = set(h for h in remote_heads if h in cl.nodemap)
1603 oldheadcnt = len(newheads)
1604 newheads.update(outg)
1605 if len(newheads) > 1:
1606 for latest in reversed(outg):
1607 if latest not in newheads:
1608 continue
1609 minhrev = min(cl.rev(h) for h in newheads)
1610 reachable = cl.reachable(latest, cl.node(minhrev))
1611 reachable.remove(latest)
1612 newheads.difference_update(reachable)
1613 if len(newheads) > oldheadcnt:
1614 return fail_multiple_heads(inc)
1615 if inc:
1616 self.ui.warn(_("note: unsynced remote changes!\n"))
1621
1617
1622 if revs is None:
1618 if revs is None:
1623 # use the fast path, no race possible on push
1619 # use the fast path, no race possible on push
@@ -298,6 +298,8 b' hg glog -R inner --template "{rev}: {bra'
298 echo %% outgoing
298 echo %% outgoing
299 hg out inner --template "{rev}: {branches} {desc}\n"
299 hg out inner --template "{rev}: {branches} {desc}\n"
300 hg push inner
300 hg push inner
301 hg push inner -r4 -r5
302 hg in inner
301 cd ..
303 cd ..
302
304
303 exit 0
305 exit 0
@@ -211,7 +211,6 b' searching for changes'
211 2: A a2
211 2: A a2
212 pushing to inner
212 pushing to inner
213 searching for changes
213 searching for changes
214 note: unsynced remote changes!
215 adding changesets
214 adding changesets
216 adding manifests
215 adding manifests
217 adding file changes
216 adding file changes
@@ -253,7 +252,6 b' searching for changes'
253 3: A a2
252 3: A a2
254 pushing to inner
253 pushing to inner
255 searching for changes
254 searching for changes
256 note: unsynced remote changes!
257 adding changesets
255 adding changesets
258 adding manifests
256 adding manifests
259 adding file changes
257 adding file changes
@@ -303,3 +301,10 b' pushing to inner'
303 searching for changes
301 searching for changes
304 abort: push creates new remote heads on branch 'A'!
302 abort: push creates new remote heads on branch 'A'!
305 (did you forget to merge? use push -f to force)
303 (did you forget to merge? use push -f to force)
304 pushing to inner
305 searching for changes
306 abort: push creates new remote heads on branch 'A'!
307 (did you forget to merge? use push -f to force)
308 comparing with inner
309 searching for changes
310 no changes found
General Comments 0
You need to be logged in to leave comments. Login now