merge: make internal merge fail cleanly on symlinks
authorMads Kiilerich <mads@kiilerich.com>
Tue, 08 Jan 2013 04:15:41 +0100
changeset 18256 d084df89d948
parent 18255 7ca534f31a83
child 18257 a35d0128545e
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.
mercurial/filemerge.py
tests/test-merge-tools.t
--- 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