# HG changeset patch # User Benoit Boissinot # Date 2010-02-08 18:44:04 # Node ID 65a90c8e11eee8c2c22a4f31cffc3e7e83c5c6e0 # Parent ea52a2d4f42c7924c4f9d5c08041c9f0793a4d26 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. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1491,7 +1491,7 @@ class localrepository(repo.repository): update, updated_heads = self.findoutgoing(remote, common, remote_heads) msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) - def checkbranch(lheads, rheads, updatelb): + def checkbranch(lheads, rheads, updatelb, branchname=None): ''' check whether there are more local heads than remote heads on a specific branch. @@ -1527,9 +1527,18 @@ class localrepository(repo.repository): warn = 1 if warn: - self.ui.warn(_("abort: push creates new remote heads!\n")) - self.ui.status(_("(did you forget to merge?" - " use push -f to force)\n")) + if branchname is not None: + msg = _("abort: push creates new remote heads" + " on branch '%s'!\n") % branchname + else: + msg = _("abort: push creates new remote heads!\n") + self.ui.warn(msg) + if len(lheads) > len(rheads): + self.ui.status(_("(did you forget to merge?" + " use push -f to force)\n")) + else: + self.ui.status(_("(you should pull and merge or" + " use push -f to force)\n")) return False return True @@ -1570,7 +1579,7 @@ class localrepository(repo.repository): for branch, lheads in localbrheads.iteritems(): if branch in remotebrheads: rheads = remotebrheads[branch] - if not checkbranch(lheads, rheads, update): + if not checkbranch(lheads, rheads, update, branch): return None, 0 else: if not checkbranch(heads, remote_heads, update): diff --git a/tests/test-push-warn.out b/tests/test-push-warn.out --- a/tests/test-push-warn.out +++ b/tests/test-push-warn.out @@ -2,8 +2,8 @@ updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved pushing to ../a searching for changes -abort: push creates new remote heads! -(did you forget to merge? use push -f to force) +abort: push creates new remote heads on branch 'default'! +(you should pull and merge or use push -f to force) pulling from ../a searching for changes adding changesets @@ -13,7 +13,7 @@ added 1 changesets with 1 changes to 1 f (run 'hg heads' to see heads, 'hg merge' to merge) pushing to ../a searching for changes -abort: push creates new remote heads! +abort: push creates new remote heads on branch 'default'! (did you forget to merge? use push -f to force) 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) @@ -35,7 +35,7 @@ 0 files updated, 1 files merged, 0 files (branch merge, don't forget to commit) pushing to ../c searching for changes -abort: push creates new remote heads! +abort: push creates new remote heads on branch 'default'! (did you forget to merge? use push -f to force) 1 pushing to ../c @@ -44,12 +44,12 @@ no changes found 0 pushing to ../c searching for changes -abort: push creates new remote heads! -(did you forget to merge? use push -f to force) +abort: push creates new remote heads on branch 'default'! +(you should pull and merge or use push -f to force) 1 pushing to ../c searching for changes -abort: push creates new remote heads! +abort: push creates new remote heads on branch 'default'! (did you forget to merge? use push -f to force) 1 pushing to ../c @@ -106,8 +106,8 @@ 1 % fail on multiple head push pushing to ../f searching for changes -abort: push creates new remote heads! -(did you forget to merge? use push -f to force) +abort: push creates new remote heads on branch 'a'! +(you should pull and merge or use push -f to force) 1 % push replacement head on existing branches pushing to ../f @@ -153,8 +153,8 @@ adding c created new head pushing to h searching for changes -abort: push creates new remote heads! -(did you forget to merge? use push -f to force) +abort: push creates new remote heads on branch 'default'! +(you should pull and merge or use push -f to force) % check prepush logic with merged branches marked working directory as branch a @@ -167,6 +167,6 @@ 1 files updated, 0 files merged, 0 files (branch merge, don't forget to commit) pushing to j searching for changes -abort: push creates new remote heads! -(did you forget to merge? use push -f to force) +abort: push creates new remote heads on branch 'a'! +(you should pull and merge or use push -f to force) diff --git a/tests/test-subrepo.out b/tests/test-subrepo.out --- a/tests/test-subrepo.out +++ b/tests/test-subrepo.out @@ -151,7 +151,7 @@ adding file changes added 1 changesets with 1 changes to 1 files % push -f committing subrepository s -abort: push creates new remote heads! +abort: push creates new remote heads on branch 'default'! pushing ...sub/t pushing ...subrepo ss searching for changes