1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/usr/bin/env bash
# For issue600, testing optimize --relink
set -ev
## We don't support hard links on Windows.
if echo $OS | grep -i windows; then
echo darcs does not support hard links on Windows
exit 0
fi
## compare succeeds if there are hard links
compare () {
echo 'use File::Basename; $res=0; while ($fn=<'$1'/*>) { $fn2="'$2'/" . basename($fn); @fd1=lstat($fn); @fd2=lstat($fn2); $res += ($fd1[1] != $fd2[1]);}; exit($res);' | perl
}
rm -rf temp
mkdir temp
cd temp
mkdir x
darcs init --repodir x
cd x
date > foo
darcs add foo
darcs record -a -A me -m 'addfoo'
cd ..
## Does the filesystem support hard linking at all?
mkdir z1
echo "hi" > z1/foo
mkdir z2
if ! ln z1/foo z2/foo ; then
echo No ln command for `pwd`; assuming no hard links.
exit 0
fi
if ! compare z1 z2 ; then
echo Filesystem for `pwd` does not support hard links.
exit 0
fi
# workaround for SunOS cp which does not support `-a' option but also
# doesn't fail when it is encountered.
cp -r x y
## Now try relinking using darcs.
rm -rf z
darcs optimize --verbose --relink --repodir x --sibling y
rm -rf x/_darcs/patches/pend* y/_darcs/patches/pend*
if compare x/_darcs/patches y/_darcs/patches
then echo darcs --relink is working, hard links were done.
else echo darcs --relink is not working, it did not make any hard links.
exit 2
fi
cd ..
rm -rf temp
|