Patchwork [1,of,2] merge: make internal merge fail cleanly on symlinks

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 8, 2013, 3:23 a.m.
Message ID <578178376b070a97e970.1357615431@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/496/
State Superseded
Commit 26627c30735a610f59979a36885b327b25d8dbff
Delegated to: Bryan O'Sullivan
Headers show

Comments

Mads Kiilerich - Jan. 8, 2013, 3:23 a.m.
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1357614941 -3600
# Node ID 578178376b070a97e9706a0bc163074650f5980f
# Parent  5a3c71b0e0428d19153bb34485ec6271bc53db9b
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.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -204,6 +204,10 @@  def _imerge(repo, mynode, orig, fcd, fco
     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
diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -832,3 +832,20 @@  cat is a bad merge-tool and doesn't chan
   # 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