diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2136,16 +2136,19 @@ def merge(ui, repo, node=None, **opts): branch = repo.changectx(None).branch() bheads = repo.branchheads(branch) if len(bheads) > 2: - raise util.Abort(_("branch '%s' has %d heads - " - "please merge with an explicit rev") % - (branch, len(bheads))) + ui.warn(_("abort: branch '%s' has %d heads - " + "please merge with an explicit rev\n") + % (branch, len(bheads))) + ui.status(_("(run 'hg heads .' to see heads)\n")) + return False parent = repo.dirstate.parents()[0] if len(bheads) == 1: if len(repo.heads()) > 1: - raise util.Abort(_("branch '%s' has one head - " - "please merge with an explicit rev") % - branch) + ui.warn(_("abort: branch '%s' has one head - " + "please merge with an explicit rev\n" % branch)) + ui.status(_("(run 'hg heads' to see all heads)\n")) + return False msg = _('there is nothing to merge') if parent != repo.lookup(repo[None].branch()): msg = _('%s - use "hg update" instead') % msg diff --git a/tests/test-merge-closedheads.out b/tests/test-merge-closedheads.out --- a/tests/test-merge-closedheads.out +++ b/tests/test-merge-closedheads.out @@ -8,6 +8,7 @@ created new head % fail with three heads 0 files updated, 0 files merged, 0 files removed, 0 files unresolved abort: branch 'default' has 3 heads - please merge with an explicit rev +(run 'hg heads .' to see heads) % close one of the heads 1 files updated, 0 files merged, 1 files removed, 0 files unresolved % succeed with two open heads diff --git a/tests/test-merge-default b/tests/test-merge-default --- a/tests/test-merge-default +++ b/tests/test-merge-default @@ -42,4 +42,11 @@ hg up 0 echo % should fail because 1 head hg merge +hg up 3 +echo a >> a +hg branch foobranch +hg commit -mf +echo % should fail because merge with other branch +hg merge + true diff --git a/tests/test-merge-default.out b/tests/test-merge-default.out --- a/tests/test-merge-default.out +++ b/tests/test-merge-default.out @@ -6,9 +6,11 @@ created new head 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % should fail because not at a head abort: branch 'default' has 3 heads - please merge with an explicit rev +(run 'hg heads .' to see heads) 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % should fail because > 2 heads abort: branch 'default' has 3 heads - please merge with an explicit rev +(run 'hg heads .' to see heads) % should succeed 0 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) @@ -26,3 +28,9 @@ abort: there is nothing to merge 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % should fail because 1 head abort: there is nothing to merge - use "hg update" instead +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +marked working directory as branch foobranch +created new head +% should fail because merge with other branch +abort: branch 'foobranch' has one head - please merge with an explicit rev +(run 'hg heads' to see all heads) diff --git a/tests/test-newbranch.out b/tests/test-newbranch.out --- a/tests/test-newbranch.out +++ b/tests/test-newbranch.out @@ -168,9 +168,11 @@ summary: a % implicit merge with test branch as parent abort: branch 'test' has one head - please merge with an explicit rev +(run 'hg heads' to see all heads) 1 files updated, 0 files merged, 1 files removed, 0 files unresolved % implicit merge with default branch as parent abort: branch 'default' has 3 heads - please merge with an explicit rev +(run 'hg heads .' to see heads) % 3 branch heads, explicit merge required 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit)