comparison mercurial/localrepo.py @ 10396:65a90c8e11ee

prepush: add more precise error messages Part of the patch is from timeless@mozdev.org - indicate the branch name where there are multiple heads - give better advice when hitting a possible race, where new heads are added between discovery and the call to branchmap(). In that case, asking the user to merge isn't helpful, since only remote has the changes.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 08 Feb 2010 19:44:04 +0100
parents 9be6c5900c07
children 2d30d66a89ad
comparison
equal deleted inserted replaced
10395:ea52a2d4f42c 10396:65a90c8e11ee
1489 inc = self.findincoming(remote, common, remote_heads, force=force) 1489 inc = self.findincoming(remote, common, remote_heads, force=force)
1490 1490
1491 update, updated_heads = self.findoutgoing(remote, common, remote_heads) 1491 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1492 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) 1492 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1493 1493
1494 def checkbranch(lheads, rheads, updatelb): 1494 def checkbranch(lheads, rheads, updatelb, branchname=None):
1495 ''' 1495 '''
1496 check whether there are more local heads than remote heads on 1496 check whether there are more local heads than remote heads on
1497 a specific branch. 1497 a specific branch.
1498 1498
1499 lheads: local branch heads 1499 lheads: local branch heads
1525 newheads.add(r) 1525 newheads.add(r)
1526 if len(newheads) > len(rheads): 1526 if len(newheads) > len(rheads):
1527 warn = 1 1527 warn = 1
1528 1528
1529 if warn: 1529 if warn:
1530 self.ui.warn(_("abort: push creates new remote heads!\n")) 1530 if branchname is not None:
1531 self.ui.status(_("(did you forget to merge?" 1531 msg = _("abort: push creates new remote heads"
1532 " use push -f to force)\n")) 1532 " on branch '%s'!\n") % branchname
1533 else:
1534 msg = _("abort: push creates new remote heads!\n")
1535 self.ui.warn(msg)
1536 if len(lheads) > len(rheads):
1537 self.ui.status(_("(did you forget to merge?"
1538 " use push -f to force)\n"))
1539 else:
1540 self.ui.status(_("(you should pull and merge or"
1541 " use push -f to force)\n"))
1533 return False 1542 return False
1534 return True 1543 return True
1535 1544
1536 if not bases: 1545 if not bases:
1537 self.ui.status(_("no changes found\n")) 1546 self.ui.status(_("no changes found\n"))
1568 self.ui.status(_("(use 'hg push -f' to force)\n")) 1577 self.ui.status(_("(use 'hg push -f' to force)\n"))
1569 return None, 0 1578 return None, 0
1570 for branch, lheads in localbrheads.iteritems(): 1579 for branch, lheads in localbrheads.iteritems():
1571 if branch in remotebrheads: 1580 if branch in remotebrheads:
1572 rheads = remotebrheads[branch] 1581 rheads = remotebrheads[branch]
1573 if not checkbranch(lheads, rheads, update): 1582 if not checkbranch(lheads, rheads, update, branch):
1574 return None, 0 1583 return None, 0
1575 else: 1584 else:
1576 if not checkbranch(heads, remote_heads, update): 1585 if not checkbranch(heads, remote_heads, update):
1577 return None, 0 1586 return None, 0
1578 1587