[PATCH] merge: improve error messages when aborting because of head count

Greg Ward greg-hg at gerg.ca
Mon Jun 14 16:06:28 CDT 2010


# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1276549392 14400
# Node ID 5d2161258411648e7a2861049979e2b3f1478535
# Parent  7422ede2bda7c8a786c4f0d1f1e5138219423b95
merge: improve error messages when aborting because of head count.
- if > 2 heads on current branch, assume the user wants to merge
  with another head on this branch and tell them how to see
  all branch heads
- if 1 head on current branch, assume the user wants to merge
  with another branch and show them how to see all repository heads
  ('heads -t')

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2564,8 +2564,8 @@
             raise util.Abort(_(
                 'branch \'%s\' has %d heads - '
                 'please merge with an explicit rev\n'
-                '(run \'hg heads .\' to see heads)')
-                % (branch, len(bheads)))
+                '(run \'hg heads %s\' to see all branch heads)')
+                % (branch, len(bheads), branch))
 
         parent = repo.dirstate.parents()[0]
         if len(bheads) == 1:
@@ -2573,7 +2573,7 @@
                 raise util.Abort(_(
                     'branch \'%s\' has one head - '
                     'please merge with an explicit rev\n'
-                    '(run \'hg heads\' to see all heads)')
+                    '(run \'hg heads -t\' to see all repository heads)')
                     % branch)
             msg = _('there is nothing to merge')
             if parent != repo.lookup(repo[None].branch()):
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,7 +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)
+(run 'hg heads default' to see all branch 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.out b/tests/test-merge-default.out
--- a/tests/test-merge-default.out
+++ b/tests/test-merge-default.out
@@ -6,11 +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)
+(run 'hg heads default' to see all branch 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)
+(run 'hg heads default' to see all branch heads)
 % should succeed
 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
@@ -32,7 +32,7 @@
 marked working directory as branch foobranch
 % 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)
+(run 'hg heads -t' to see all repository heads)
 % merge preview not affected by common ancestor
 2:2d95304fed5d
 4:f25cbe84d8b3
diff --git a/tests/test-newbranch.out b/tests/test-newbranch.out
--- a/tests/test-newbranch.out
+++ b/tests/test-newbranch.out
@@ -167,11 +167,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)
+(run 'hg heads -t' to see all repository 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)
+(run 'hg heads default' to see all branch 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)


More information about the Mercurial-devel mailing list