changeset 19799:ab3e42225dbc

update: add error message for dirty non-linear update with no rev Previously, the error message for a dirty non-linear update was the same (and relatively unhelpful) whether or not a rev was specified. This patch and an upcoming one will introduce separate, more helpful hints.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 23 Sep 2013 20:07:30 -0700
parents 76df01e56e7f
children 4894e0d9462d
files mercurial/merge.py tests/test-merge5.t tests/test-subrepo-svn.t tests/test-update-branches.t
diffstat 4 files changed, 26 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Mon Sep 23 17:43:33 2013 -0700
+++ b/mercurial/merge.py	Mon Sep 23 20:07:30 2013 -0700
@@ -656,19 +656,21 @@
     -c  -C  dirty  rev  |  linear   same  cross
      n   n    n     n   |    ok     (1)     x
      n   n    n     y   |    ok     ok     ok
-     n   n    y     *   |   merge   (2)    (2)
+     n   n    y     n   |   merge   (2)    (2)
+     n   n    y     y   |   merge   (3)    (3)
      n   y    *     *   |    ---  discard  ---
-     y   n    y     *   |    ---    (3)    ---
+     y   n    y     *   |    ---    (4)    ---
      y   n    n     *   |    ---    ok     ---
-     y   y    *     *   |    ---    (4)    ---
+     y   y    *     *   |    ---    (5)    ---
 
     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)
-    3 = abort: uncommitted local changes
-    4 = incompatible options (checked in commands.py)
+    3 = abort: uncommitted changes (commit or update --clean to discard changes)
+    4 = abort: uncommitted local changes
+    5 = incompatible options (checked in commands.py)
 
     Return the same tuple as applyupdates().
     """
@@ -726,10 +728,14 @@
                     # note: the <node> variable contains a random identifier
                     if repo[node].node() in foreground:
                         pa = p1  # allow updating to successors
-                    elif dirty:
+                    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")
+                        raise util.Abort(msg, hint=hint)
                     else:  # node is none
                         msg = _("not a linear update")
                         hint = _("merge or update --check to force update")
--- a/tests/test-merge5.t	Mon Sep 23 17:43:33 2013 -0700
+++ b/tests/test-merge5.t	Mon Sep 23 20:07:30 2013 -0700
@@ -33,7 +33,8 @@
 Should abort:
 
   $ hg update -y 1
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   [255]
   $ mv c a
 
--- a/tests/test-subrepo-svn.t	Mon Sep 23 17:43:33 2013 -0700
+++ b/tests/test-subrepo-svn.t	Mon Sep 23 20:07:30 2013 -0700
@@ -477,7 +477,8 @@
 This is surprising, but is also correct based on the current code:
   $ echo "updating should (maybe) fail" > obstruct/other
   $ hg co tip
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   [255]
 
 Point to a Subversion branch which has since been deleted and recreated
--- a/tests/test-update-branches.t	Mon Sep 23 17:43:33 2013 -0700
+++ b/tests/test-update-branches.t	Mon Sep 23 20:07:30 2013 -0700
@@ -123,22 +123,26 @@
   M sub/suba
 
   $ revtest 'none dirty same'   dirty 2 3
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   parent=2
   M foo
 
   $ revtest 'none dirtysub same'   dirtysub 2 3
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   parent=2
   M sub/suba
 
   $ revtest 'none dirty cross'  dirty 3 4
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   parent=3
   M foo
 
   $ revtest 'none dirtysub cross'  dirtysub 3 4
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   parent=3
   M sub/suba
 
@@ -223,5 +227,6 @@
   $ hg up --quiet 0
   $ hg up --quiet 2
   $ hg up 5
-  abort: crosses branches (merge branches or use --clean to discard changes)
+  abort: uncommitted changes
+  (commit or update --clean to discard changes)
   [255]