--- a/mercurial/commands.py Sun Feb 07 00:43:24 2010 +0100
+++ b/mercurial/commands.py Sun Feb 07 00:51:59 2010 +0100
@@ -2136,16 +2136,19 @@
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
--- a/tests/test-merge-closedheads.out Sun Feb 07 00:43:24 2010 +0100
+++ b/tests/test-merge-closedheads.out Sun Feb 07 00:51:59 2010 +0100
@@ -8,6 +8,7 @@
% 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
--- a/tests/test-merge-default Sun Feb 07 00:43:24 2010 +0100
+++ b/tests/test-merge-default Sun Feb 07 00:51:59 2010 +0100
@@ -42,4 +42,11 @@
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
--- a/tests/test-merge-default.out Sun Feb 07 00:43:24 2010 +0100
+++ b/tests/test-merge-default.out Sun Feb 07 00:51:59 2010 +0100
@@ -6,9 +6,11 @@
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 @@
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)
--- a/tests/test-newbranch.out Sun Feb 07 00:43:24 2010 +0100
+++ b/tests/test-newbranch.out Sun Feb 07 00:51:59 2010 +0100
@@ -168,9 +168,11 @@
% 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)