changeset 19800:4894e0d9462d

update: improve error message for dirty non-linear update with rev
author Siddharth Agarwal <sid0@fb.com>
date Mon, 23 Sep 2013 20:08:52 -0700
parents ab3e42225dbc
children 41abe2e3e3b7
files mercurial/merge.py tests/test-up-local-change.t tests/test-update-branches.t
diffstat 3 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Mon Sep 23 20:07:30 2013 -0700
+++ b/mercurial/merge.py	Mon Sep 23 20:08:52 2013 -0700
@@ -666,8 +666,8 @@
     x = can't happen
     * = don't-care
     1 = abort: not a linear update (merge or update --check to force update)
-    2 = abort: crosses branches (use 'hg merge' to merge or
-                 use 'hg update -C' to discard changes)
+    2 = abort: uncommitted changes (commit and merge, or update --clean to
+                 discard changes)
     3 = abort: uncommitted changes (commit or update --clean to discard changes)
     4 = abort: uncommitted local changes
     5 = incompatible options (checked in commands.py)
@@ -728,13 +728,14 @@
                     # note: the <node> variable contains a random identifier
                     if repo[node].node() in foreground:
                         pa = p1  # allow updating to successors
-                    elif dirty and onode is None:
-                        msg = _("crosses branches (merge branches or use"
-                                " --clean to discard changes)")
-                        raise util.Abort(msg)
                     elif dirty:
                         msg = _("uncommitted changes")
-                        hint = _("commit or update --clean to discard changes")
+                        if onode is None:
+                            hint = _("commit and merge, or update --clean to"
+                                     " discard changes")
+                        else:
+                            hint = _("commit or update --clean to discard"
+                                     " changes")
                         raise util.Abort(msg, hint=hint)
                     else:  # node is none
                         msg = _("not a linear update")
--- a/tests/test-up-local-change.t	Mon Sep 23 20:07:30 2013 -0700
+++ b/tests/test-up-local-change.t	Mon Sep 23 20:08:52 2013 -0700
@@ -167,7 +167,8 @@
   summary:     2
   
   $ hg --debug up
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit and merge, or update --clean to discard changes)
   [255]
   $ hg --debug merge
   abort: outstanding uncommitted changes
--- a/tests/test-update-branches.t	Mon Sep 23 20:07:30 2013 -0700
+++ b/tests/test-update-branches.t	Mon Sep 23 20:08:52 2013 -0700
@@ -140,6 +140,12 @@
   parent=3
   M foo
 
+  $ norevtest 'none dirty cross'  dirty 2
+  abort: uncommitted changes
+  (commit and merge, or update --clean to discard changes)
+  parent=2
+  M foo
+
   $ revtest 'none dirtysub cross'  dirtysub 3 4
   abort: uncommitted changes
   (commit or update --clean to discard changes)