#!/bin/sh

hg init rep; cd rep

touch empty-file
python -c 'for x in range(10000): print x' > large-file

hg addremove

hg commit -m A

rm large-file empty-file
python -c 'for x in range(10,10000): print x' > another-file

hg addremove -s50

hg commit -m B

echo % comparing two empty files caused ZeroDivisionError in the past
hg update -C 0
rm empty-file
touch another-empty-file
hg addremove -s50

cd ..

hg init rep2; cd rep2

python -c 'for x in range(10000): print x' > large-file
python -c 'for x in range(50): print x' > tiny-file

hg addremove

hg commit -m A

python -c 'for x in range(70): print x' > small-file
rm tiny-file
rm large-file

hg addremove -s50

hg commit -m B

echo % should all fail
hg addremove -s foo
hg addremove -s -1
hg addremove -s 1e6

cd ..

echo '% issue 1527'
hg init rep3; cd rep3
mkdir d
echo a > d/a
hg add d/a
hg commit -m 1

mv d/a d/b
hg addremove -s80
hg debugstate
mv d/b c
echo "% no copies found here (since the target isn't in d"
hg addremove -s80 d
echo "% copies here"
hg addremove -s80

true
