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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 15, 2013, 3:44 p.m.
Message ID <6e46faccfdec3732e2c3.1368632691@juju>
Download mbox | patch
Permalink /patch/1652/
State Superseded, archived
Commit 9bfa86746c9c1f6ab51deb8f174ffc482417d09f
Headers show

Comments

Katsunori FUJIWARA - May 15, 2013, 3:44 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@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.
Siddharth Agarwal - May 16, 2013, 8:27 p.m.
On 05/15/2013 08:44 AM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@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

This one's great and can seemingly land independently of the other two.
Matt Mackall - May 17, 2013, 7:42 p.m.
On Thu, 2013-05-16 at 00:44 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@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

Queued for stable, thanks.

Patch

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 ..