Show More
@@ -1,143 +1,220 b'' | |||
|
1 | #!/bin/sh | |
|
1 | $ mkdir test | |
|
2 | $ cd test | |
|
3 | $ hg init | |
|
4 | $ echo foo>foo | |
|
5 | $ hg commit -Am 1 -d '1 0' | |
|
6 | adding foo | |
|
7 | $ echo bar>bar | |
|
8 | $ hg commit -Am 2 -d '2 0' | |
|
9 | adding bar | |
|
10 | $ mkdir baz | |
|
11 | $ echo bletch>baz/bletch | |
|
12 | $ hg commit -Am 3 -d '1000000000 0' | |
|
13 | adding baz/bletch | |
|
14 | $ echo "[web]" >> .hg/hgrc | |
|
15 | $ echo "name = test-archive" >> .hg/hgrc | |
|
16 | $ cp .hg/hgrc .hg/hgrc-base | |
|
17 | > test_archtype() { | |
|
18 | > echo "allow_archive = $1" >> .hg/hgrc | |
|
19 | > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log | |
|
20 | > cat hg.pid >> $DAEMON_PIDS | |
|
21 | > echo % $1 allowed should give 200 | |
|
22 | > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1 | |
|
23 | > echo % $3 and $4 disallowed should both give 403 | |
|
24 | > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1 | |
|
25 | > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1 | |
|
26 | > "$TESTDIR/killdaemons.py" | |
|
27 | > cat errors.log | |
|
28 | > cp .hg/hgrc-base .hg/hgrc | |
|
29 | > } | |
|
2 | 30 | |
|
3 | mkdir test | |
|
4 | cd test | |
|
5 | hg init | |
|
6 | echo foo>foo | |
|
7 | hg commit -Am 1 -d '1 0' | |
|
8 | echo bar>bar | |
|
9 | hg commit -Am 2 -d '2 0' | |
|
10 | mkdir baz | |
|
11 | echo bletch>baz/bletch | |
|
12 | hg commit -Am 3 -d '1000000000 0' | |
|
13 | echo "[web]" >> .hg/hgrc | |
|
14 | echo "name = test-archive" >> .hg/hgrc | |
|
15 | cp .hg/hgrc .hg/hgrc-base | |
|
31 | check http return codes | |
|
32 | ||
|
16 | 33 | |
|
17 | # check http return codes | |
|
18 | test_archtype() { | |
|
19 | echo "allow_archive = $1" >> .hg/hgrc | |
|
20 | hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log | |
|
21 | cat hg.pid >> $DAEMON_PIDS | |
|
22 | echo % $1 allowed should give 200 | |
|
23 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1 | |
|
24 |
|
|
|
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 | |
|
27 | "$TESTDIR/killdaemons.py" | |
|
28 | cat errors.log | |
|
29 | cp .hg/hgrc-base .hg/hgrc | |
|
30 | } | |
|
34 | $ test_archtype gz tar.gz tar.bz2 zip | |
|
35 | % gz allowed should give 200 | |
|
36 | 200 Script output follows | |
|
37 | % tar.bz2 and zip disallowed should both give 403 | |
|
38 | 403 Archive type not allowed: bz2 | |
|
39 | 403 Archive type not allowed: zip | |
|
40 | $ test_archtype bz2 tar.bz2 zip tar.gz | |
|
41 | % bz2 allowed should give 200 | |
|
42 | 200 Script output follows | |
|
43 | % zip and tar.gz disallowed should both give 403 | |
|
44 | 403 Archive type not allowed: zip | |
|
45 | 403 Archive type not allowed: gz | |
|
46 | $ test_archtype zip zip tar.gz tar.bz2 | |
|
47 | % zip allowed should give 200 | |
|
48 | 200 Script output follows | |
|
49 | % tar.gz and tar.bz2 disallowed should both give 403 | |
|
50 | 403 Archive type not allowed: gz | |
|
51 | 403 Archive type not allowed: bz2 | |
|
31 | 52 | |
|
32 | echo | |
|
33 | test_archtype gz tar.gz tar.bz2 zip | |
|
34 | test_archtype bz2 tar.bz2 zip tar.gz | |
|
35 | test_archtype zip zip tar.gz tar.bz2 | |
|
53 | $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc | |
|
54 | $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log | |
|
55 | $ cat hg.pid >> $DAEMON_PIDS | |
|
36 | 56 | |
|
37 | echo "allow_archive = gz bz2 zip" >> .hg/hgrc | |
|
38 | hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log | |
|
39 | cat hg.pid >> $DAEMON_PIDS | |
|
57 | invalid arch type should give 404 | |
|
40 | 58 | |
|
41 | echo % invalid arch type should give 404 | |
|
42 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1 | |
|
43 | echo | |
|
59 | $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1 | |
|
60 | 404 Unsupported archive type: None | |
|
44 | 61 | |
|
45 | TIP=`hg id -v | cut -f1 -d' '` | |
|
46 | QTIP=`hg id -q` | |
|
47 | cat > getarchive.py <<EOF | |
|
48 | import os, sys, urllib2 | |
|
49 | try: | |
|
50 | # Set stdout to binary mode for win32 platforms | |
|
51 | import msvcrt | |
|
52 | msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | |
|
53 | except ImportError: | |
|
54 | pass | |
|
55 | ||
|
56 | node, archive = sys.argv[1:] | |
|
57 | f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s' | |
|
58 | % (os.environ['HGPORT'], node, archive)) | |
|
59 | sys.stdout.write(f.read()) | |
|
60 | EOF | |
|
61 | python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
62 | python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
63 | python getarchive.py "$TIP" zip > archive.zip | |
|
64 | unzip -t archive.zip | sed "s/$QTIP/TIP/" | |
|
62 | $ TIP=`hg id -v | cut -f1 -d' '` | |
|
63 | $ QTIP=`hg id -q` | |
|
64 | $ cat > getarchive.py <<EOF | |
|
65 | > import os, sys, urllib2 | |
|
66 | > try: | |
|
67 | > # Set stdout to binary mode for win32 platforms | |
|
68 | > import msvcrt | |
|
69 | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | |
|
70 | > except ImportError: | |
|
71 | > pass | |
|
72 | > node, archive = sys.argv[1:] | |
|
73 | > f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s' | |
|
74 | > % (os.environ['HGPORT'], node, archive)) | |
|
75 | > sys.stdout.write(f.read()) | |
|
76 | > EOF | |
|
77 | $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
78 | test-archive-TIP/.hg_archival.txt | |
|
79 | test-archive-TIP/bar | |
|
80 | test-archive-TIP/baz/bletch | |
|
81 | test-archive-TIP/foo | |
|
82 | $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
83 | test-archive-TIP/.hg_archival.txt | |
|
84 | test-archive-TIP/bar | |
|
85 | test-archive-TIP/baz/bletch | |
|
86 | test-archive-TIP/foo | |
|
87 | $ python getarchive.py "$TIP" zip > archive.zip | |
|
88 | $ unzip -t archive.zip | sed "s/$QTIP/TIP/" | |
|
89 | Archive: archive.zip | |
|
90 | testing: test-archive-TIP/.hg_archival.txt OK | |
|
91 | testing: test-archive-TIP/bar OK | |
|
92 | testing: test-archive-TIP/baz/bletch OK | |
|
93 | testing: test-archive-TIP/foo OK | |
|
94 | No errors detected in compressed data of archive.zip. | |
|
65 | 95 | |
|
66 | "$TESTDIR/killdaemons.py" | |
|
96 | $ "$TESTDIR/killdaemons.py" | |
|
67 | 97 | |
|
68 | hg archive -t tar test.tar | |
|
69 | tar tf test.tar | |
|
98 | $ hg archive -t tar test.tar | |
|
99 | $ tar tf test.tar | |
|
100 | test/.hg_archival.txt | |
|
101 | test/bar | |
|
102 | test/baz/bletch | |
|
103 | test/foo | |
|
104 | ||
|
105 | $ hg archive -t tbz2 -X baz test.tar.bz2 | |
|
106 | $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null | |
|
107 | test/.hg_archival.txt | |
|
108 | test/bar | |
|
109 | test/foo | |
|
70 | 110 | |
|
71 |
hg archive -t t |
|
|
72 |
|
|
|
73 | ||
|
74 | hg archive -t tgz -p %b-%h test-%h.tar.gz | |
|
75 | gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
111 | $ hg archive -t tgz -p %b-%h test-%h.tar.gz | |
|
112 | $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
113 | test-TIP/.hg_archival.txt | |
|
114 | test-TIP/bar | |
|
115 | test-TIP/baz/bletch | |
|
116 | test-TIP/foo | |
|
76 | 117 | |
|
77 | hg archive autodetected_test.tar | |
|
78 | tar tf autodetected_test.tar | |
|
118 | $ hg archive autodetected_test.tar | |
|
119 | $ tar tf autodetected_test.tar | |
|
120 | autodetected_test/.hg_archival.txt | |
|
121 | autodetected_test/bar | |
|
122 | autodetected_test/baz/bletch | |
|
123 | autodetected_test/foo | |
|
79 | 124 | |
|
80 |
|
|
|
81 | hg archive -t tar autodetect_override_test.zip | |
|
82 |
|
|
|
125 | The '-t' should override autodetection | |
|
126 | ||
|
127 | $ hg archive -t tar autodetect_override_test.zip | |
|
128 | $ tar tf autodetect_override_test.zip | |
|
129 | autodetect_override_test.zip/.hg_archival.txt | |
|
130 | autodetect_override_test.zip/bar | |
|
131 | autodetect_override_test.zip/baz/bletch | |
|
132 | autodetect_override_test.zip/foo | |
|
83 | 133 | |
|
84 | for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do | |
|
85 | hg archive auto_test.$ext | |
|
86 | if [ -d auto_test.$ext ]; then | |
|
87 | echo "extension $ext was not autodetected." | |
|
88 | fi | |
|
89 | done | |
|
134 | $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do | |
|
135 | > hg archive auto_test.$ext | |
|
136 | > if [ -d auto_test.$ext ]; then | |
|
137 | > echo "extension $ext was not autodetected." | |
|
138 | > fi | |
|
139 | > done | |
|
90 | 140 | |
|
91 | cat > md5comp.py <<EOF | |
|
92 | try: | |
|
93 | from hashlib import md5 | |
|
94 | except ImportError: | |
|
95 | from md5 import md5 | |
|
96 | import sys | |
|
97 | f1, f2 = sys.argv[1:3] | |
|
98 | h1 = md5(file(f1, 'rb').read()).hexdigest() | |
|
99 | h2 = md5(file(f2, 'rb').read()).hexdigest() | |
|
100 | print h1 == h2 or "md5 differ: " + repr((h1, h2)) | |
|
101 | EOF | |
|
141 | $ cat > md5comp.py <<EOF | |
|
142 | > try: | |
|
143 | > from hashlib import md5 | |
|
144 | > except ImportError: | |
|
145 | > from md5 import md5 | |
|
146 | > import sys | |
|
147 | > f1, f2 = sys.argv[1:3] | |
|
148 | > h1 = md5(file(f1, 'rb').read()).hexdigest() | |
|
149 | > h2 = md5(file(f2, 'rb').read()).hexdigest() | |
|
150 | > print h1 == h2 or "md5 differ: " + repr((h1, h2)) | |
|
151 | > EOF | |
|
152 | ||
|
153 | archive name is stored in the archive, so create similar | |
|
154 | ||
|
155 | archives and rename them afterwards. | |
|
156 | ||
|
157 | $ hg archive -t tgz tip.tar.gz | |
|
158 | $ mv tip.tar.gz tip1.tar.gz | |
|
159 | $ sleep 1 | |
|
160 | $ hg archive -t tgz tip.tar.gz | |
|
161 | $ mv tip.tar.gz tip2.tar.gz | |
|
162 | $ python md5comp.py tip1.tar.gz tip2.tar.gz | |
|
163 | True | |
|
102 | 164 | |
|
103 | # archive name is stored in the archive, so create similar | |
|
104 | # archives and rename them afterwards. | |
|
105 | hg archive -t tgz tip.tar.gz | |
|
106 | mv tip.tar.gz tip1.tar.gz | |
|
107 | sleep 1 | |
|
108 | hg archive -t tgz tip.tar.gz | |
|
109 | mv tip.tar.gz tip2.tar.gz | |
|
110 | python md5comp.py tip1.tar.gz tip2.tar.gz | |
|
165 | $ hg archive -t zip -p /illegal test.zip | |
|
166 | abort: archive prefix contains illegal components | |
|
167 | $ hg archive -t zip -p very/../bad test.zip | |
|
168 | ||
|
169 | $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip | |
|
170 | $ unzip -t test.zip | |
|
171 | Archive: test.zip | |
|
172 | testing: test/bar OK | |
|
173 | testing: test/baz/bletch OK | |
|
174 | testing: test/foo OK | |
|
175 | No errors detected in compressed data of test.zip. | |
|
111 | 176 | |
|
112 | hg archive -t zip -p /illegal test.zip | |
|
113 | hg archive -t zip -p very/../bad test.zip | |
|
177 | $ hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
178 | test-TIP/.hg_archival.txt | |
|
179 | test-TIP/bar | |
|
180 | test-TIP/baz/bletch | |
|
181 | test-TIP/foo | |
|
114 | 182 | |
|
115 | hg archive --config ui.archivemeta=false -t zip -r 2 test.zip | |
|
116 | unzip -t test.zip | |
|
183 | $ hg archive -r 0 -t tar rev-%r.tar | |
|
184 | $ if [ -f rev-0.tar ]; then | |
|
185 | $ fi | |
|
117 | 186 | |
|
118 | hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
|
187 | test .hg_archival.txt | |
|
119 | 188 | |
|
120 | hg archive -r 0 -t tar rev-%r.tar | |
|
121 | if [ -f rev-0.tar ]; then | |
|
122 | echo 'rev-0.tar created' | |
|
123 | fi | |
|
189 | $ hg archive ../test-tags | |
|
190 | $ cat ../test-tags/.hg_archival.txt | |
|
191 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 | |
|
192 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e | |
|
193 | branch: default | |
|
194 | latesttag: null | |
|
195 | latesttagdistance: 3 | |
|
196 | $ hg tag -r 2 mytag | |
|
197 | $ hg tag -r 2 anothertag | |
|
198 | $ hg archive -r 2 ../test-lasttag | |
|
199 | $ cat ../test-lasttag/.hg_archival.txt | |
|
200 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 | |
|
201 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e | |
|
202 | branch: default | |
|
203 | tag: anothertag | |
|
204 | tag: mytag | |
|
124 | 205 | |
|
125 | echo '% test .hg_archival.txt' | |
|
126 | hg archive ../test-tags | |
|
127 | cat ../test-tags/.hg_archival.txt | |
|
128 | hg tag -r 2 mytag | |
|
129 | hg tag -r 2 anothertag | |
|
130 | hg archive -r 2 ../test-lasttag | |
|
131 | cat ../test-lasttag/.hg_archival.txt | |
|
206 | $ hg archive -t bogus test.bogus | |
|
207 | abort: unknown archive type 'bogus' | |
|
132 | 208 | |
|
133 | hg archive -t bogus test.bogus | |
|
209 | server errors | |
|
210 | ||
|
211 | $ cat errors.log | |
|
134 | 212 | |
|
135 | echo % server errors | |
|
136 | cat errors.log | |
|
213 | empty repo | |
|
137 | 214 | |
|
138 | echo '% empty repo' | |
|
139 |
|
|
|
140 | cd ../empty | |
|
141 | hg archive ../test-empty | |
|
215 | $ hg init ../empty | |
|
216 | $ cd ../empty | |
|
217 | $ hg archive ../test-empty | |
|
218 | abort: no working directory: please specify a revision | |
|
142 | 219 | |
|
143 | exit 0 | |
|
220 | $ exit 0 |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now