[PATCH 3 of 3 V2] merge: compare symbolic-link-ness to check identity against the unknown file

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed May 15 10:44:51 CDT 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1368632246 -32400
#      Thu May 16 00:37:26 2013 +0900
# Node ID 6e46faccfdec3732e2c34a7e9ab03db481bce4bb
# Parent  185f02ec640199455dabfb80ebaca407f1249f82
merge: compare symbolic-link-ness to check identity against the unknown file

Before this patch, identity against the unknown file in the working
directory is checked by "filectx.cmp()".

It just compares between contents of two files, even though one of
them is symbolic-link and another is not.

For example, symbolic-link to "./a" is recognized as identical to
regular file containing "./a" (without EOL) unexpectedly.

This patch compares also symbolic-link-ness of each target files,
before checking contents of them.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -113,7 +113,8 @@
     return (not repo.dirstate._ignore(f)
         and repo.wopener.audit.check(f)
         and repo.dirstate.normalize(f) not in repo.dirstate
-        and mctx[f].cmp(wctx[f]))
+        and ((stat.S_ISLNK(mode) != ('l' in mctx.manifest().flags(f)))
+             or mctx[f].cmp(wctx[f])))
 
 def _checkunknown(repo, wctx, mctx):
     "check for collisions between unknown files and files in mctx"
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -139,7 +139,7 @@
   $ hg commit -m "commit #2"
   $ hg update 1
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo This is file c1 > c
+  $ printf './a' > c
   $ hg add c
   $ hg commit -m "commit #3"
   created new head
@@ -156,7 +156,7 @@
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg diff --nodates
-  diff -r 85de557015a8 b
+  diff -r eb53cd0c74cb b
   --- a/b
   +++ b/b
   @@ -1,1 +1,1 @@
@@ -193,4 +193,15 @@
   $ rm c/d/e/k
   $ hg update -q 3
 
+#if symlink
+  $ hg update -q -C 1
+  $ hg cat -r 3 c
+  ./a (no-eol)
+  $ ln -s ./a c
+  $ hg update -q 3
+  c: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
+  [255]
+#endif
+
   $ cd ..


More information about the Mercurial-devel mailing list