changeset 18256:d084df89d948

merge: make internal merge fail cleanly on symlinks Simplemerge is not symlink aware and will never do the the right thing on symlinks. It would read the symlink as a file and abort with 'No such file or directory' on dangling symlinks. Instead, internal:merge now simply fails to merge symlinks.
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 08 Jan 2013 04:15:41 +0100
parents 7ca534f31a83
children a35d0128545e
files mercurial/filemerge.py tests/test-merge-tools.t
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filemerge.py	Sun Dec 16 20:50:57 2012 +0100
+++ b/mercurial/filemerge.py	Tue Jan 08 04:15:41 2013 +0100
@@ -204,6 +204,10 @@
     Uses the internal non-interactive simple merge algorithm for merging
     files. It will fail if there are any conflicts and leave markers in
     the partially merged file."""
+    tool, toolpath, binary, symlink = toolconf
+    if symlink:
+        return False, 1
+
     r = _premerge(repo, toolconf, files)
     if r:
         a, b, c, back = files
--- a/tests/test-merge-tools.t	Sun Dec 16 20:50:57 2012 +0100
+++ b/tests/test-merge-tools.t	Tue Jan 08 04:15:41 2013 +0100
@@ -832,3 +832,20 @@
   # hg stat
   M f
   ? f.orig
+
+#if symlink
+
+internal merge cannot handle symlinks and shouldn't try:
+
+  $ hg update -q -C 1
+  $ rm f
+  $ ln -s symlink f
+  $ hg commit -qm 'f is symlink'
+  $ hg merge -r 2 --tool internal:merge
+  merging f
+  merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  [1]
+
+#endif