view tests/test-git-import @ 11769:ca6cebd8734e stable

dirstate: ignore symlinks when fs cannot handle them (issue1888) When the filesystem cannot handle the executable bit, we currently ignore it completely when looking for modified files. Similarly, it is impossible to set or clear the bit when the filesystem ignores it. This patch makes Mercurial treat symbolic links the same way. Symlinks are a little different since they manifest themselves as small files containing a filename (the symlink target). On Windows, these files show up as regular files, and on Linux and Mac they show up as real symlinks. Issue1888 presents a case where the symlink files are better ignored from the Windows side. A Linux client creates symlinks in a working copy which is shared over a network between Linux and Windows clients. The Samba server is helpful and defererences the symlink when the Windows client looks at it. This means that Mercurial on the Windows side sees file content instead of a file name in the symlink, and hence flags the link as modified. Ignoring the change would be much more helpful, similarly to how Mercurial does not report any changes when executable bits are ignored in a checkout on Windows. An initial checkout of a symbolic link on a file system that cannot handle symbolic links will still result in a regular file containing the target file name as its content. Sharing such a checkout with a Linux client will not turn the file into a symlink automatically, but 'hg revert' can fix that. After the revert, the Windows client will see the correct file content (provided by the Samba server when it follows the link on the Linux side) and otherwise ignore the change. Running 'hg perfstatus' 10 times gives these results: Before: After: min: 0.544703 min: 0.546549 med: 0.547592 med: 0.548881 avg: 0.549146 avg: 0.548549 max: 0.564112 max: 0.551504 The median time is increased about 0.24%.
author Martin Geisler <mg@aragost.com>
date Mon, 09 Aug 2010 15:31:56 +0200
parents 377d879e9d1b
children 77600d697d0e
line wrap: on
line source

#!/bin/sh

hg init a
cd a

echo % new file
hg import -d "1000000 0" -mnew - <<EOF
diff --git a/new b/new
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/new
@@ -0,0 +1 @@
+a
EOF
hg tip -q

echo % new empty file
hg import -d "1000000 0" -mempty - <<EOF
diff --git a/empty b/empty
new file mode 100644
EOF
hg tip -q
hg locate empty

echo % chmod +x
hg import -d "1000000 0" -msetx - <<EOF
diff --git a/new b/new
old mode 100644
new mode 100755
EOF
hg tip -q

test -x new || echo failed

echo % copy
hg import -d "1000000 0" -mcopy - <<EOF
diff --git a/new b/copy
old mode 100755
new mode 100644
similarity index 100%
copy from new
copy to copy
diff --git a/new b/copyx
similarity index 100%
copy from new
copy to copyx
EOF
hg tip -q

if "$TESTDIR/hghave" -q execbit; then
    test -f copy -a ! -x copy || echo failed
    test -x copyx || echo failed
else
    test -f copy || echo failed
fi
cat copy
hg cat copy

echo % rename
hg import -d "1000000 0" -mrename - <<EOF
diff --git a/copy b/rename
similarity index 100%
rename from copy
rename to rename
EOF
hg tip -q

hg locate

echo % delete
hg import -d "1000000 0" -mdelete - <<EOF
diff --git a/copyx b/copyx
deleted file mode 100755
index 7898192..0000000
--- a/copyx
+++ /dev/null
@@ -1 +0,0 @@
-a
EOF
hg tip -q

hg locate
test -f copyx && echo failed || true

echo % regular diff
hg import -d "1000000 0" -mregular - <<EOF
diff --git a/rename b/rename
index 7898192..72e1fe3 100644
--- a/rename
+++ b/rename
@@ -1 +1,5 @@
 a
+a
+a
+a
+a
EOF
hg tip -q

echo % copy and modify
hg import -d "1000000 0" -mcopymod - <<EOF
diff --git a/rename b/copy2
similarity index 80%
copy from rename
copy to copy2
index 72e1fe3..b53c148 100644
--- a/rename
+++ b/copy2
@@ -1,5 +1,5 @@
 a
 a
-a
+b
 a
 a
EOF
hg tip -q

hg cat copy2

echo % rename and modify
hg import -d "1000000 0" -mrenamemod - <<EOF
diff --git a/copy2 b/rename2
similarity index 80%
rename from copy2
rename to rename2
index b53c148..8f81e29 100644
--- a/copy2
+++ b/rename2
@@ -1,5 +1,5 @@
 a
 a
 b
-a
+c
 a
EOF
hg tip -q

hg locate copy2
hg cat rename2

echo % one file renamed multiple times
hg import -d "1000000 0" -mmultirenames - <<EOF
diff --git a/rename2 b/rename3
rename from rename2
rename to rename3
diff --git a/rename2 b/rename3-2
rename from rename2
rename to rename3-2
EOF
hg tip -q
hg log -vr. --template '{rev} {files} / {file_copies}\n'

hg locate rename2 rename3 rename3-2
hg cat rename3
echo
hg cat rename3-2

echo foo > foo
hg add foo
hg ci -m 'add foo'
echo % binary files and regular patch hunks
hg import -d "1000000 0" -m binaryregular - <<EOF
diff --git a/binary b/binary
new file mode 100644
index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
GIT binary patch
literal 4
Lc\${NkU|;|M00aO5

diff --git a/foo b/foo2
rename from foo
rename to foo2
EOF
hg tip -q
cat foo2
hg manifest --debug | grep binary

echo % many binary files
hg import -d "1000000 0" -m multibinary - <<EOF
diff --git a/mbinary1 b/mbinary1
new file mode 100644
index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
GIT binary patch
literal 4
Lc\${NkU|;|M00aO5

diff --git a/mbinary2 b/mbinary2
new file mode 100644
index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490
GIT binary patch
literal 5
Mc\${NkU|\`?^000jF3jhEB

EOF
hg tip -q
hg manifest --debug | grep mbinary

echo % filenames with spaces
hg import -d "1000000 0" -m spaces - <<EOF
diff --git a/foo bar b/foo bar
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/foo bar	
@@ -0,0 +1 @@
+foo
EOF
hg tip -q
cat "foo bar"

echo % copy then modify the original file
hg import -d "1000000 0" -m copy-mod-orig - <<EOF
diff --git a/foo2 b/foo2
index 257cc56..fe08ec6 100644
--- a/foo2
+++ b/foo2
@@ -1 +1,2 @@
 foo
+new line
diff --git a/foo2 b/foo3
similarity index 100%
copy from foo2
copy to foo3
EOF
hg tip -q

cat foo3