changeset 5242:9cd6578750b9

improve error message for 'hg merge' when repo already at branchtip
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 25 Aug 2007 11:30:11 +0200
parents 2b8373bda032
children 423f4e8be115
files mercurial/commands.py tests/test-imerge tests/test-imerge.out tests/test-merge-default tests/test-merge-default.out
diffstat 5 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Aug 24 00:56:56 2007 +0200
+++ b/mercurial/commands.py	Sat Aug 25 11:30:11 2007 +0200
@@ -1928,10 +1928,13 @@
             raise util.Abort(_('repo has %d heads - '
                                'please merge with an explicit rev') %
                              len(heads))
+        parent = repo.dirstate.parents()[0]
         if len(heads) == 1:
-            raise util.Abort(_('there is nothing to merge - '
-                               'use "hg update" instead'))
-        parent = repo.dirstate.parents()[0]
+            msg = _('there is nothing to merge')
+            if parent != repo.lookup(repo.workingctx().branch()):
+                msg = _('%s - use "hg update" instead' % msg)
+            raise util.Abort(msg)
+
         if parent not in heads:
             raise util.Abort(_('working dir not at a head rev - '
                                'use "hg update" or merge with an explicit rev'))
--- a/tests/test-imerge	Fri Aug 24 00:56:56 2007 +0200
+++ b/tests/test-imerge	Sat Aug 25 11:30:11 2007 +0200
@@ -54,6 +54,10 @@
 hg ci -m'merged' -d '3 0'
 hg tip -v
 
+echo % nothing to merge -- tip
+hg imerge
+
+hg up 0
 echo % nothing to merge
 hg imerge
 
--- a/tests/test-imerge.out	Fri Aug 24 00:56:56 2007 +0200
+++ b/tests/test-imerge.out	Sat Aug 25 11:30:11 2007 +0200
@@ -41,5 +41,8 @@
 merged
 
 
+% nothing to merge -- tip
+abort: there is nothing to merge
+2 files updated, 0 files merged, 1 files removed, 0 files unresolved
 % nothing to merge
 abort: there is nothing to merge - use "hg update" instead
--- a/tests/test-merge-default	Fri Aug 24 00:56:56 2007 +0200
+++ b/tests/test-merge-default	Sat Aug 25 11:30:11 2007 +0200
@@ -34,6 +34,10 @@
 hg merge
 hg commit -mm2
 
+echo % should fail because at tip
+hg merge
+
+hg up 0
 echo % should fail because 1 head
 hg merge
 
--- a/tests/test-merge-default.out	Fri Aug 24 00:56:56 2007 +0200
+++ b/tests/test-merge-default.out	Sat Aug 25 11:30:11 2007 +0200
@@ -13,5 +13,8 @@
 % should succeed - 2 heads
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
+% should fail because at tip
+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