set -ev

test $DARCS || DARCS=$PWD/../darcs
ACTUAL_DARCS=`which $DARCS`
DARCSPATH=`dirname $ACTUAL_DARCS`
PATH="$DARCSPATH:$PATH"
export PATH

rm -rf temp1 temp2

mkdir temp1; cd temp1 ; $DARCS init ; cd ..
$DARCS get temp1 temp2
cd temp2/ ; echo 'x' > _darcs/prefs/author ; cd ..
cd temp1/ ; echo 'x' > _darcs/prefs/author ; cd ..

cd temp1/
touch test ; $DARCS record
$DARCS add test     ; $DARCS record -a -m 'test'
$DARCS mv test best ; $DARCS record -a -m 'test -> best'
$DARCS mv best test ; $DARCS record -a -m 'best -> test'
cd ..

cd temp2/
touch test2
$DARCS add test2     ; $DARCS record -a -m 'test2'
$DARCS mv test2 best ; $DARCS record -a -m 'test2 -> best'
$DARCS mv best test2 ; $DARCS record -a -m 'best -> test2'

$DARCS pull ../temp1/ -a
cd ..

rm -rf temp1 temp2
