Patchwork [4,of,7,STABLE] merge: compare symbolic-link-ness to check identity against the unknown file

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 6, 2013, 8:35 p.m.
Message ID <a5d959e18918dbd0cf01.1367872504@juju>
Download mbox | patch
Permalink /patch/1567/
State Superseded, archived
Commit 9bfa86746c9c1f6ab51deb8f174ffc482417d09f
Headers show

Comments

Katsunori FUJIWARA - May 6, 2013, 8:35 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1367870651 -32400
#      Tue May 07 05:04:11 2013 +0900
# Branch stable
# Node ID a5d959e18918dbd0cf01ab193a00b5ba83c93596
# Parent  d12b0211d5ea3b6e30a732a9d5381314a83862b1
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.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -103,7 +103,8 @@ 
         return repo.dirstate.normalize(f) not in repo.dirstate.dirs()
     return (not repo.dirstate._ignore(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 @@
@@ -213,4 +213,15 @@ 
   abort: untracked files in working directory differ from files in requested revision
   [255]
 
+#if symlink
+  $ rm -rf c
+  $ 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 ..