#!/bin/sh

echo % setting up repo
hg init test
cd test
echo a > a
echo b > b
hg ci -Ama

echo % change permissions for git diffs
chmod 755 a
hg ci -Amb

echo % set up hgweb
hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
cat hg.pid >> $DAEMON_PIDS

echo % revision
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/0'

echo % raw revision
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-rev/0'

echo % diff removed file
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a'

echo % set up hgweb with git diffs
"$TESTDIR/killdaemons.py"
hg serve --config 'diff.git=1' -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
cat hg.pid >> $DAEMON_PIDS

echo % revision
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/0'

echo % revision
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-rev/0'

echo % diff removed file
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a'

cd ..
echo % test import rev as raw-rev
hg clone -r0 test test1
cd test1
hg import -q --exact http://localhost:$HGPORT/rev/1

echo % errors
cat ../test/errors.log
