view tests/test-clone @ 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 be5e86c80628
children b1ae33b813cb
line wrap: on
line source

#!/bin/sh

echo
echo % prepare repo a
mkdir a
cd a
hg init
echo a > a
hg add a
hg commit -m test
echo first line > b
hg add b
# create a non-inlined filelog
python -c 'for x in range(10000): print x' >> data1
for j in 0 1 2 3 4 5 6 7 8 9; do
    cat data1 >> b
    hg commit -m test
done
echo % "list files in store/data (should show a 'b.d')"
for i in .hg/store/data/*; do
    echo $i
done

echo
echo % default operation
hg clone . ../b
cd ../b
cat a
hg verify

echo
echo % no update, with debug option
hg --debug clone -U . ../c
cd ../c
cat a 2>/dev/null || echo "a not present"
hg verify

echo
echo % default destination
mkdir ../d
cd ../d
hg clone ../a
cd a
hg cat a

echo
echo % "check that we drop the file: from the path before"
echo % "writing the .hgrc"
cd ../..
hg clone file:a e
grep 'file:' e/.hg/hgrc

echo
echo % check that path aliases are expanded
hg clone -q -U --config 'paths.foobar=a#0' foobar f
hg -R f showconfig paths.default | sed -e 's,.*/,,'

echo
echo % use --pull
hg clone --pull a g
hg -R g verify

echo
echo % clone to '.'
mkdir h
cd h
hg clone ../a .
cd ..

echo
echo
echo % "*** tests for option -u ***"
echo


echo
echo % "adding some more history to repo a"
cd a
echo % "tag ref1"
hg tag ref1
echo the quick brown fox >a
hg ci -m "hacked default"
echo % "updating back to ref1"
hg up ref1
echo
echo % "add branch 'stable' to repo a for later tests"
hg branch stable
echo some text >a
hg ci -m "starting branch stable"
echo % "tag ref2"
hg tag ref2
echo some more text >a
hg ci -m "another change for branch stable"
echo
echo % "updating back to ref2"
hg up ref2
echo
echo % "parents of repo a"
hg parents
echo
echo % "repo a has two heads"
hg heads
cd ..

echo
echo % "testing clone -U -u 1 a ua (must abort)"
hg clone -U -u 1 a ua

echo
echo % "testing clone -u . a ua"
hg clone -u . a ua
echo
echo % "repo ua has both heads"
hg -R ua heads
echo
echo % "same revision checked out in repo a and ua"
hg -R a parents --template "{node|short}\n"
hg -R ua parents --template "{node|short}\n"
rm -r ua

echo
echo % "testing clone --pull -u . a ua"
hg clone --pull -u . a ua
echo
echo % "repo ua has both heads"
hg -R ua heads
echo
echo % "same revision checked out in repo a and ua"
hg -R a parents --template "{node|short}\n"
hg -R ua parents --template "{node|short}\n"
rm -r ua

echo
echo % "testing clone -u stable a ua"
hg clone -u stable a ua
echo
echo % "repo ua has both heads"
hg -R ua heads
echo
echo % "branch stable is checked out"
hg -R ua parents
rm -r ua

echo
echo % "testing clone a ua"
hg clone a ua
echo
echo % "repo ua has both heads"
hg -R ua heads
echo
echo % "branch default is checked out"
hg -R ua parents
rm -r ua

echo
echo % "testing clone -u . a#stable ua"
hg clone -u . a#stable ua
echo
echo % "repo ua has only branch stable"
hg -R ua heads
echo
echo % "same revision checked out in repo a and ua"
hg -R a parents --template "{node|short}\n"
hg -R ua parents --template "{node|short}\n"
rm -r ua

echo
echo % "testing clone -u . -r stable a ua"
hg clone -u . -r stable a ua
echo
echo % "repo ua has only branch stable"
hg -R ua heads
echo
echo % "same revision checked out in repo a and ua"
hg -R a parents --template "{node|short}\n"
hg -R ua parents --template "{node|short}\n"
rm -r ua

echo
echo % "testing clone -r stable a ua"
hg clone -r stable a ua
echo
echo % "repo ua has only branch stable"
hg -R ua heads
echo
echo % "branch stable is checked out"
hg -R ua parents
rm -r ua

echo
echo % "testing clone -u . -r stable -r default a ua"
hg clone -u . -r stable -r default a ua
echo
echo % "repo ua has two heads"
hg -R ua heads
echo
echo % "same revision checked out in repo a and ua"
hg -R a parents --template "{node|short}\n"
hg -R ua parents --template "{node|short}\n"
rm -r ua

cat <<EOF > simpleclone.py
from mercurial import ui, hg
myui = ui.ui()
repo = hg.repository(myui, 'a')
hg.clone(myui, repo, dest="ua")
EOF

python simpleclone.py
rm -r ua

exit 0