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