merge: handle linear update to symlink correctly (issue3316) stable
authorMatt Mackall <mpm@selenic.com>
Tue, 13 Mar 2012 16:28:08 -0500
branchstable
changeset 16255 ca5cc2976574
parent 16254 c7eef052c9e3
child 16256 c655e4acaa82
child 16257 7a5524f240ad
child 16268 1a4f560b660f
merge: handle linear update to symlink correctly (issue3316) This fixes a regression introduced by fcf66193b186. If no file-level merge is needed, we can update flags directly, otherwise we have a conflict to resolve in filemerge.
mercurial/merge.py
tests/test-merge-types.t
--- a/mercurial/merge.py	Tue Mar 13 15:12:26 2012 -0500
+++ b/mercurial/merge.py	Tue Mar 13 16:28:08 2012 -0500
@@ -173,9 +173,10 @@
         if m and m != a: # changed from a to m
             return m
         if n and n != a: # changed from a to n
-            if n == 'l' or a == 'l':
-                # can't automatically merge symlink flag change here, let
-                # filemerge take care of it
+            if (n == 'l' or a == 'l') and m1[f] != ma[f]:
+                # can't automatically merge symlink flag when there
+                # are file-level conflicts here, let filemerge take
+                # care of it
                 return m
             return n
         return '' # flag was cleared
--- a/tests/test-merge-types.t	Tue Mar 13 15:12:26 2012 -0500
+++ b/tests/test-merge-types.t	Tue Mar 13 16:28:08 2012 -0500
@@ -70,3 +70,39 @@
   > fi
   a has no flags (default for conflicts)
 
+Update to link without local change should get us a symlink (issue3316):
+
+ $ hg up -C 0
+ $ hg up
+ $ hg st
+
+Update to link with local change should cause a merge prompt (issue3200):
+
+  $ hg up -C 0
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo data > a
+  $ HGMERGE= hg up -y --debug
+    searching for copies back to rev 2
+  resolving manifests
+   overwrite: False, partial: False
+   ancestor: c334dc3be0da, local: c334dc3be0da+, remote: 521a1e40188f
+   a: versions differ -> m
+  preserving a for resolve of a
+  updating: a 1/1 files (100.00%)
+  couldn't find merge tool hgmerge
+  picked tool 'internal:prompt' for a (binary False symlink True)
+   no tool found to merge a
+  keep (l)ocal or take (o)ther? l
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  $ hg diff --git
+  diff --git a/a b/a
+  old mode 120000
+  new mode 100644
+  --- a/a
+  +++ b/a
+  @@ -1,1 +1,1 @@
+  -symlink
+  \ No newline at end of file
+  +data
+
+