Show More
@@ -1,118 +1,118 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | 3 | mkdir test |
|
4 | 4 | cd test |
|
5 | 5 | hg init |
|
6 | 6 | echo foo>foo |
|
7 | 7 | hg commit -Am 1 -d '1 0' |
|
8 | 8 | echo bar>bar |
|
9 | 9 | hg commit -Am 2 -d '2 0' |
|
10 | 10 | mkdir baz |
|
11 | 11 | echo bletch>baz/bletch |
|
12 | 12 | hg commit -Am 3 -d '1000000000 0' |
|
13 | 13 | echo "[web]" >> .hg/hgrc |
|
14 | 14 | echo "name = test-archive" >> .hg/hgrc |
|
15 | 15 | cp .hg/hgrc .hg/hgrc-base |
|
16 | 16 | |
|
17 | 17 | # check http return codes |
|
18 | 18 | test_archtype() { |
|
19 | 19 | echo "allow_archive = $1" >> .hg/hgrc |
|
20 | 20 | hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log |
|
21 | 21 | cat hg.pid >> $DAEMON_PIDS |
|
22 | 22 | echo % $1 allowed should give 200 |
|
23 | 23 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1 |
|
24 | 24 | echo % $3 and $4 disallowed should both give 403 |
|
25 | 25 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1 |
|
26 | 26 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1 |
|
27 | 27 | "$TESTDIR/killdaemons.py" |
|
28 | 28 | cat errors.log |
|
29 | 29 | cp .hg/hgrc-base .hg/hgrc |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | echo |
|
33 | 33 | test_archtype gz tar.gz tar.bz2 zip |
|
34 | 34 | test_archtype bz2 tar.bz2 zip tar.gz |
|
35 | 35 | test_archtype zip zip tar.gz tar.bz2 |
|
36 | 36 | |
|
37 | 37 | echo "allow_archive = gz bz2 zip" >> .hg/hgrc |
|
38 | 38 | hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log |
|
39 | 39 | cat hg.pid >> $DAEMON_PIDS |
|
40 | 40 | |
|
41 | 41 | echo % invalid arch type should give 404 |
|
42 | 42 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1 |
|
43 | 43 | echo |
|
44 | 44 | |
|
45 | 45 | TIP=`hg id -v | cut -f1 -d' '` |
|
46 | 46 | QTIP=`hg id -q` |
|
47 | 47 | cat > getarchive.py <<EOF |
|
48 | 48 | import os, sys, urllib2 |
|
49 | 49 | try: |
|
50 | 50 | # Set stdout to binary mode for win32 platforms |
|
51 | 51 | import msvcrt |
|
52 | 52 | msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
|
53 | 53 | except ImportError: |
|
54 | 54 | pass |
|
55 | 55 | |
|
56 | 56 | node, archive = sys.argv[1:] |
|
57 | 57 | f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s' |
|
58 | 58 | % (os.environ['HGPORT'], node, archive)) |
|
59 | 59 | sys.stdout.write(f.read()) |
|
60 | 60 | EOF |
|
61 | http_proxy= python getarchive.py "$TIP" gz | gunzip | tar tf - | sed "s/$QTIP/TIP/" | |
|
62 | http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - | sed "s/$QTIP/TIP/" | |
|
61 | http_proxy= python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
62 | http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
63 | 63 | http_proxy= python getarchive.py "$TIP" zip > archive.zip |
|
64 | 64 | unzip -t archive.zip | sed "s/$QTIP/TIP/" |
|
65 | 65 | |
|
66 | 66 | "$TESTDIR/killdaemons.py" |
|
67 | 67 | |
|
68 | 68 | hg archive -t tar test.tar |
|
69 | 69 | tar tf test.tar |
|
70 | 70 | |
|
71 | 71 | hg archive -t tbz2 -X baz test.tar.bz2 |
|
72 | bunzip2 -dc test.tar.bz2 | tar tf - | |
|
72 | bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null | |
|
73 | 73 | |
|
74 | 74 | hg archive -t tgz -p %b-%h test-%h.tar.gz |
|
75 | gzip -dc test-$QTIP.tar.gz | tar tf - | sed "s/$QTIP/TIP/" | |
|
75 | gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
76 | 76 | |
|
77 | 77 | cat > md5comp.py <<EOF |
|
78 | 78 | from mercurial.util import md5 |
|
79 | 79 | import sys |
|
80 | 80 | f1, f2 = sys.argv[1:3] |
|
81 | 81 | h1 = md5(file(f1, 'rb').read()).hexdigest() |
|
82 | 82 | h2 = md5(file(f2, 'rb').read()).hexdigest() |
|
83 | 83 | print h1 == h2 or "md5 differ: " + repr((h1, h2)) |
|
84 | 84 | EOF |
|
85 | 85 | |
|
86 | 86 | # archive name is stored in the archive, so create similar |
|
87 | 87 | # archives and rename them afterwards. |
|
88 | 88 | hg archive -t tgz tip.tar.gz |
|
89 | 89 | mv tip.tar.gz tip1.tar.gz |
|
90 | 90 | sleep 1 |
|
91 | 91 | hg archive -t tgz tip.tar.gz |
|
92 | 92 | mv tip.tar.gz tip2.tar.gz |
|
93 | 93 | python md5comp.py tip1.tar.gz tip2.tar.gz |
|
94 | 94 | |
|
95 | 95 | hg archive -t zip -p /illegal test.zip |
|
96 | 96 | hg archive -t zip -p very/../bad test.zip |
|
97 | 97 | |
|
98 | 98 | hg archive --config ui.archivemeta=false -t zip -r 2 test.zip |
|
99 | 99 | unzip -t test.zip |
|
100 | 100 | |
|
101 | hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/" | |
|
101 | hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
102 | 102 | |
|
103 | 103 | hg archive -r 0 -t tar rev-%r.tar |
|
104 | 104 | if [ -f rev-0.tar ]; then |
|
105 | 105 | echo 'rev-0.tar created' |
|
106 | 106 | fi |
|
107 | 107 | |
|
108 | 108 | hg archive -t bogus test.bogus |
|
109 | 109 | |
|
110 | 110 | echo % server errors |
|
111 | 111 | cat errors.log |
|
112 | 112 | |
|
113 | 113 | echo '% empty repo' |
|
114 | 114 | hg init ../empty |
|
115 | 115 | cd ../empty |
|
116 | 116 | hg archive ../test-empty |
|
117 | 117 | |
|
118 | 118 | exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now