2005-08-30 21:17:05 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
mkdir test
|
|
|
|
cd test
|
|
|
|
hg init
|
|
|
|
echo foo>foo
|
2007-06-21 06:20:37 +04:00
|
|
|
hg commit -Am 1 -d '1 0'
|
2005-08-30 21:17:05 +04:00
|
|
|
echo bar>bar
|
2007-06-21 06:20:37 +04:00
|
|
|
hg commit -Am 2 -d '2 0'
|
2005-08-30 21:17:05 +04:00
|
|
|
mkdir baz
|
|
|
|
echo bletch>baz/bletch
|
2007-06-21 06:20:37 +04:00
|
|
|
hg commit -Am 3 -d '1000000000 0'
|
2005-09-15 23:05:48 +04:00
|
|
|
echo "[web]" >> .hg/hgrc
|
2005-08-30 21:17:05 +04:00
|
|
|
echo "name = test-archive" >> .hg/hgrc
|
2008-09-05 19:28:37 +04:00
|
|
|
cp .hg/hgrc .hg/hgrc-base
|
|
|
|
|
|
|
|
# check http return codes
|
|
|
|
test_archtype() {
|
|
|
|
echo "allow_archive = $1" >> .hg/hgrc
|
|
|
|
hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
|
|
|
|
cat hg.pid >> $DAEMON_PIDS
|
|
|
|
echo % $1 allowed should give 200
|
|
|
|
"$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1
|
|
|
|
echo % $3 and $4 disallowed should both give 403
|
|
|
|
"$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1
|
|
|
|
"$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1
|
2008-11-08 01:28:53 +03:00
|
|
|
"$TESTDIR/killdaemons.py"
|
2008-09-05 19:28:37 +04:00
|
|
|
cat errors.log
|
|
|
|
cp .hg/hgrc-base .hg/hgrc
|
|
|
|
}
|
|
|
|
|
|
|
|
echo
|
|
|
|
test_archtype gz tar.gz tar.bz2 zip
|
|
|
|
test_archtype bz2 tar.bz2 zip tar.gz
|
|
|
|
test_archtype zip zip tar.gz tar.bz2
|
|
|
|
|
|
|
|
echo "allow_archive = gz bz2 zip" >> .hg/hgrc
|
2008-01-22 11:11:11 +03:00
|
|
|
hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
|
2006-07-06 22:45:34 +04:00
|
|
|
cat hg.pid >> $DAEMON_PIDS
|
2005-08-30 21:17:05 +04:00
|
|
|
|
2008-09-05 19:28:37 +04:00
|
|
|
echo % invalid arch type should give 404
|
|
|
|
"$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1
|
|
|
|
echo
|
|
|
|
|
2005-08-30 21:17:05 +04:00
|
|
|
TIP=`hg id -v | cut -f1 -d' '`
|
|
|
|
QTIP=`hg id -q`
|
|
|
|
cat > getarchive.py <<EOF
|
2007-10-05 23:17:01 +04:00
|
|
|
import os, sys, urllib2
|
2008-10-12 21:11:59 +04:00
|
|
|
try:
|
|
|
|
# Set stdout to binary mode for win32 platforms
|
|
|
|
import msvcrt
|
|
|
|
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2005-08-30 21:17:05 +04:00
|
|
|
node, archive = sys.argv[1:]
|
2007-10-05 23:17:01 +04:00
|
|
|
f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
|
|
|
|
% (os.environ['HGPORT'], node, archive))
|
2005-08-30 21:17:05 +04:00
|
|
|
sys.stdout.write(f.read())
|
|
|
|
EOF
|
2006-05-03 13:25:36 +04:00
|
|
|
http_proxy= python getarchive.py "$TIP" gz | gunzip | tar tf - | sed "s/$QTIP/TIP/"
|
|
|
|
http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - | sed "s/$QTIP/TIP/"
|
2005-08-30 21:17:05 +04:00
|
|
|
http_proxy= python getarchive.py "$TIP" zip > archive.zip
|
|
|
|
unzip -t archive.zip | sed "s/$QTIP/TIP/"
|
|
|
|
|
2008-11-08 01:28:53 +03:00
|
|
|
"$TESTDIR/killdaemons.py"
|
|
|
|
|
2006-04-22 02:47:27 +04:00
|
|
|
hg archive -t tar test.tar
|
|
|
|
tar tf test.tar
|
|
|
|
|
|
|
|
hg archive -t tbz2 -X baz test.tar.bz2
|
|
|
|
bunzip2 -dc test.tar.bz2 | tar tf -
|
|
|
|
|
|
|
|
hg archive -t tgz -p %b-%h test-%h.tar.gz
|
|
|
|
gzip -dc test-$QTIP.tar.gz | tar tf - | sed "s/$QTIP/TIP/"
|
|
|
|
|
2007-07-05 22:39:03 +04:00
|
|
|
cat > md5comp.py <<EOF
|
2008-04-08 17:41:21 +04:00
|
|
|
from mercurial.util import md5
|
|
|
|
import sys
|
2007-07-05 22:39:03 +04:00
|
|
|
f1, f2 = sys.argv[1:3]
|
2008-04-08 17:41:21 +04:00
|
|
|
h1 = md5(file(f1, 'rb').read()).hexdigest()
|
|
|
|
h2 = md5(file(f2, 'rb').read()).hexdigest()
|
2007-07-05 22:39:03 +04:00
|
|
|
print h1 == h2 or "md5 differ: " + repr((h1, h2))
|
2007-06-21 06:20:37 +04:00
|
|
|
EOF
|
|
|
|
|
2007-07-05 22:39:03 +04:00
|
|
|
# archive name is stored in the archive, so create similar
|
|
|
|
# archives and rename them afterwards.
|
2007-06-21 06:20:37 +04:00
|
|
|
hg archive -t tgz tip.tar.gz
|
2007-07-05 22:39:03 +04:00
|
|
|
mv tip.tar.gz tip1.tar.gz
|
2007-06-21 06:20:37 +04:00
|
|
|
sleep 1
|
|
|
|
hg archive -t tgz tip.tar.gz
|
2007-07-05 22:39:03 +04:00
|
|
|
mv tip.tar.gz tip2.tar.gz
|
|
|
|
python md5comp.py tip1.tar.gz tip2.tar.gz
|
2007-06-21 06:20:37 +04:00
|
|
|
|
2006-04-22 02:47:27 +04:00
|
|
|
hg archive -t zip -p /illegal test.zip
|
|
|
|
hg archive -t zip -p very/../bad test.zip
|
|
|
|
|
2008-02-29 00:39:59 +03:00
|
|
|
hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
|
2006-04-22 02:47:27 +04:00
|
|
|
unzip -t test.zip
|
2006-06-22 02:15:06 +04:00
|
|
|
|
|
|
|
hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/"
|
2007-07-10 21:06:24 +04:00
|
|
|
|
2007-07-12 02:56:16 +04:00
|
|
|
hg archive -r 0 -t tar rev-%r.tar
|
|
|
|
if [ -f rev-0.tar ]; then
|
|
|
|
echo 'rev-0.tar created'
|
|
|
|
fi
|
2007-07-12 03:15:03 +04:00
|
|
|
|
2008-02-05 17:54:42 +03:00
|
|
|
hg archive -t bogus test.bogus
|
|
|
|
|
2008-01-22 11:11:11 +03:00
|
|
|
echo % server errors
|
|
|
|
cat errors.log
|
|
|
|
|
2007-07-10 21:06:24 +04:00
|
|
|
echo '% empty repo'
|
|
|
|
hg init ../empty
|
|
|
|
cd ../empty
|
|
|
|
hg archive ../test-empty
|
2008-01-22 11:11:11 +03:00
|
|
|
|
2007-07-12 03:15:03 +04:00
|
|
|
exit 0
|