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