abort when using 'update -m' and this is not a merge
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Wed, 01 Feb 2006 08:46:24 +0100
changeset 1674 dee55c4a4963
parent 1667 daff3ef0de8d
child 1675 03191e1a4230
abort when using 'update -m' and this is not a merge add more testcases for updating with local changes
mercurial/localrepo.py
tests/test-up-local-change
tests/test-up-local-change.out
--- a/mercurial/localrepo.py	Mon Jan 30 19:34:35 2006 +1300
+++ b/mercurial/localrepo.py	Wed Feb 01 08:46:24 2006 +0100
@@ -1399,6 +1399,13 @@
 
         modified, added, removed, deleted, unknown = self.changes()
 
+        # is this a jump, or a merge?  i.e. is there a linear path
+        # from p1 to p2?
+        linear_path = (pa == p1 or pa == p2)
+
+        if allow and linear_path:
+            raise util.Abort(_("there is nothing to merge, "
+                               "just use 'hg update'"))
         if allow and not forcemerge:
             if modified or added or removed:
                 raise util.Abort(_("outstanding uncommited changes"))
@@ -1411,10 +1418,6 @@
                         raise util.Abort(_("'%s' already exists in the working"
                                            " dir and differs from remote") % f)
 
-        # is this a jump, or a merge?  i.e. is there a linear path
-        # from p1 to p2?
-        linear_path = (pa == p1 or pa == p2)
-
         # resolve the manifest to determine which files
         # we care about merging
         self.ui.note(_("resolving manifests\n"))
--- a/tests/test-up-local-change	Mon Jan 30 19:34:35 2006 +1300
+++ b/tests/test-up-local-change	Wed Feb 01 08:46:24 2006 +0100
@@ -24,11 +24,34 @@
 cd ../r2
 hg -q pull ../r1
 hg status
+hg parents
 hg --debug up
+hg parents
+hg --debug up 0
+hg parents
 hg --debug up -m || echo failed
-hg --debug up -f -m
+hg parents
+hg --debug up
 hg parents
 hg -v history
 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
               -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
 
+# create a second head
+cd ../r1
+hg up 0
+echo b2 > b
+echo a3 > a
+hg addremove
+hg commit -m "3" -d "0 0"
+
+cd ../r2
+hg -q pull ../r1
+hg status
+hg parents
+hg --debug up || echo failed
+hg --debug up -m || echo failed
+hg --debug up -f -m
+hg parents
+hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
+              -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
--- a/tests/test-up-local-change.out	Mon Jan 30 19:34:35 2006 +1300
+++ b/tests/test-up-local-change.out	Wed Feb 01 08:46:24 2006 +0100
@@ -7,6 +7,11 @@
 +abc
 adding b
 M a
+changeset:   0:c19d34741b0a
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     1
+
 resolving manifests
  force None allow None moddirstate True linear True
  ancestor a0c8bcbbb45c local a0c8bcbbb45c remote 1165e8bd193e
@@ -16,11 +21,38 @@
 merging a
 resolving a
 file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2
-abort: outstanding uncommited changes
-failed
+changeset:   1:1e71731e6fbb
+tag:         tip
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     2
+
 resolving manifests
- force None allow 1 moddirstate True linear True
- ancestor 1165e8bd193e local 1165e8bd193e remote 1165e8bd193e
+ force None allow None moddirstate True linear True
+ ancestor a0c8bcbbb45c local 1165e8bd193e remote a0c8bcbbb45c
+remote deleted b
+removing b
+changeset:   0:c19d34741b0a
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     1
+
+abort: there is nothing to merge, just use 'hg update'
+failed
+changeset:   0:c19d34741b0a
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     1
+
+resolving manifests
+ force None allow None moddirstate True linear True
+ ancestor a0c8bcbbb45c local a0c8bcbbb45c remote 1165e8bd193e
+ a versions differ, resolve
+remote created b
+getting b
+merging a
+resolving a
+file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2
 changeset:   1:1e71731e6fbb
 tag:         tip
 user:        test
@@ -50,3 +82,52 @@
 @@ -1,1 +1,1 @@ a2
 -a2
 +abc
+adding b
+M a
+changeset:   1:1e71731e6fbb
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     2
+
+resolving manifests
+ force None allow None moddirstate True linear False
+ ancestor a0c8bcbbb45c local 1165e8bd193e remote 4096f2872392
+ a versions differ, resolve
+ b versions differ, resolve
+this update spans a branch affecting the following files:
+ a (resolve)
+ b (resolve)
+aborting update spanning branches!
+(use update -m to merge across branches or -C to lose changes)
+failed
+abort: outstanding uncommited changes
+failed
+resolving manifests
+ force None allow 1 moddirstate True linear False
+ ancestor a0c8bcbbb45c local 1165e8bd193e remote 4096f2872392
+ a versions differ, resolve
+ b versions differ, resolve
+merging a
+resolving a
+file a: my d730145abbf9 other 13e0d5f949fa ancestor b789fdd96dc2
+merging b
+resolving b
+file b: my 1e88685f5dde other 61de8c7723ca ancestor 000000000000
+changeset:   1:1e71731e6fbb
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     2
+
+changeset:   2:83c51d0caff4
+tag:         tip
+parent:      0:c19d34741b0a
+user:        test
+date:        Thu Jan  1 00:00:00 1970 +0000
+summary:     3
+
+diff -r 1e71731e6fbb a
+--- a/a
++++ b/a
+@@ -1,1 +1,1 @@ a2
+-a2
++abc