Patchwork [4,of,9] update: improve error message for dirty non-linear update with rev

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 24, 2013, 4:51 a.m.
Message ID <f12996d75571ec256890.1379998261@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2616/
State Accepted
Commit 4894e0d9462dc91b90a2637f56d661e14a201f8d
Headers show

Comments

Siddharth Agarwal - Sept. 24, 2013, 4:51 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1379992132 25200
#      Mon Sep 23 20:08:52 2013 -0700
# Node ID f12996d75571ec2568906159e39277ade0579681
# Parent  3c9d933940fabae7052a1bdad0eb9b47e61fb455
update: improve error message for dirty non-linear update with rev

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -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")
diff --git a/tests/test-up-local-change.t b/tests/test-up-local-change.t
--- a/tests/test-up-local-change.t
+++ b/tests/test-up-local-change.t
@@ -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
diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -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)