##// END OF EJS Templates
tests: add some (?) output lines to catch "helpful" output from Solaris diff...
Augie Fackler -
r34900:1e2dc50d default
parent child Browse files
Show More
@@ -1,472 +1,474 b''
1 1 #require serve
2 2
3 3 $ hg init test
4 4 $ cd test
5 5 $ echo foo>foo
6 6 $ hg commit -Am 1 -d '1 0'
7 7 adding foo
8 8 $ echo bar>bar
9 9 $ hg commit -Am 2 -d '2 0'
10 10 adding bar
11 11 $ mkdir baz
12 12 $ echo bletch>baz/bletch
13 13 $ hg commit -Am 3 -d '1000000000 0'
14 14 adding baz/bletch
15 15 $ hg init subrepo
16 16 $ touch subrepo/sub
17 17 $ hg -q -R subrepo ci -Am "init subrepo"
18 18 $ echo "subrepo = subrepo" > .hgsub
19 19 $ hg add .hgsub
20 20 $ hg ci -m "add subrepo"
21 21
22 22 $ cat >> $HGRCPATH <<EOF
23 23 > [extensions]
24 24 > share =
25 25 > EOF
26 26
27 27 hg subrepos are shared when the parent repo is shared
28 28
29 29 $ cd ..
30 30 $ hg share test shared1
31 31 updating working directory
32 32 sharing subrepo subrepo from $TESTTMP/test/subrepo
33 33 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 34 $ cat shared1/subrepo/.hg/sharedpath
35 35 $TESTTMP/test/subrepo/.hg (no-eol) (glob)
36 36
37 37 hg subrepos are shared into existence on demand if the parent was shared
38 38
39 39 $ hg clone -qr 1 test clone1
40 40 $ hg share clone1 share2
41 41 updating working directory
42 42 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 43 $ hg -R clone1 -q pull
44 44 $ hg -R share2 update tip
45 45 sharing subrepo subrepo from $TESTTMP/test/subrepo
46 46 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 47 $ cat share2/subrepo/.hg/sharedpath
48 48 $TESTTMP/test/subrepo/.hg (no-eol) (glob)
49 49 $ echo 'mod' > share2/subrepo/sub
50 50 $ hg -R share2 ci -Sqm 'subrepo mod'
51 51 $ hg -R clone1 update -C tip
52 52 cloning subrepo subrepo from $TESTTMP/test/subrepo
53 53 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
54 54 $ find share2 | egrep 'sharedpath|00.+\.i' | sort
55 55 share2/.hg/sharedpath
56 56 share2/subrepo/.hg/sharedpath
57 57 $ hg -R share2 unshare
58 58 unsharing subrepo 'subrepo'
59 59 $ find share2 | egrep 'sharedpath|00.+\.i' | sort
60 60 share2/.hg/00changelog.i
61 61 share2/.hg/sharedpath.old
62 62 share2/.hg/store/00changelog.i
63 63 share2/.hg/store/00manifest.i
64 64 share2/subrepo/.hg/00changelog.i
65 65 share2/subrepo/.hg/sharedpath.old
66 66 share2/subrepo/.hg/store/00changelog.i
67 67 share2/subrepo/.hg/store/00manifest.i
68 68 $ hg -R share2/subrepo log -r tip -T compact
69 69 1[tip] 559dcc9bfa65 1970-01-01 00:00 +0000 test
70 70 subrepo mod
71 71
72 72 $ rm -rf clone1
73 73
74 74 $ hg clone -qr 1 test clone1
75 75 $ hg share clone1 shared3
76 76 updating working directory
77 77 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 78 $ hg -R clone1 -q pull
79 79 $ hg -R shared3 archive --config ui.archivemeta=False -r tip -S archive
80 80 sharing subrepo subrepo from $TESTTMP/test/subrepo
81 81 $ cat shared3/subrepo/.hg/sharedpath
82 82 $TESTTMP/test/subrepo/.hg (no-eol) (glob)
83 83 $ diff -r archive test
84 84 Only in test: .hg
85 Common subdirectories: archive/baz and test/baz (?)
86 Common subdirectories: archive/subrepo and test/subrepo (?)
85 87 Only in test/subrepo: .hg
86 88 [1]
87 89 $ rm -rf archive
88 90
89 91 $ cd test
90 92 $ echo "[web]" >> .hg/hgrc
91 93 $ echo "name = test-archive" >> .hg/hgrc
92 94 $ echo "archivesubrepos = True" >> .hg/hgrc
93 95 $ cp .hg/hgrc .hg/hgrc-base
94 96 > test_archtype() {
95 97 > echo "allow_archive = $1" >> .hg/hgrc
96 98 > test_archtype_run "$@"
97 99 > }
98 100 > test_archtype_deprecated() {
99 101 > echo "allow$1 = True" >> .hg/hgrc
100 102 > test_archtype_run "$@"
101 103 > }
102 104 > test_archtype_run() {
103 105 > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log \
104 106 > --config extensions.blackbox= --config blackbox.track=develwarn
105 107 > cat hg.pid >> $DAEMON_PIDS
106 108 > echo % $1 allowed should give 200
107 109 > get-with-headers.py localhost:$HGPORT "archive/tip.$2" | head -n 1
108 110 > echo % $3 and $4 disallowed should both give 403
109 111 > get-with-headers.py localhost:$HGPORT "archive/tip.$3" | head -n 1
110 112 > get-with-headers.py localhost:$HGPORT "archive/tip.$4" | head -n 1
111 113 > killdaemons.py
112 114 > cat errors.log
113 115 > hg blackbox --config extensions.blackbox= --config blackbox.track=
114 116 > cp .hg/hgrc-base .hg/hgrc
115 117 > }
116 118
117 119 check http return codes
118 120
119 121 $ test_archtype gz tar.gz tar.bz2 zip
120 122 % gz allowed should give 200
121 123 200 Script output follows
122 124 % tar.bz2 and zip disallowed should both give 403
123 125 403 Archive type not allowed: bz2
124 126 403 Archive type not allowed: zip
125 127 $ test_archtype bz2 tar.bz2 zip tar.gz
126 128 % bz2 allowed should give 200
127 129 200 Script output follows
128 130 % zip and tar.gz disallowed should both give 403
129 131 403 Archive type not allowed: zip
130 132 403 Archive type not allowed: gz
131 133 $ test_archtype zip zip tar.gz tar.bz2
132 134 % zip allowed should give 200
133 135 200 Script output follows
134 136 % tar.gz and tar.bz2 disallowed should both give 403
135 137 403 Archive type not allowed: gz
136 138 403 Archive type not allowed: bz2
137 139
138 140 check http return codes (with deprecated option)
139 141
140 142 $ test_archtype_deprecated gz tar.gz tar.bz2 zip
141 143 % gz allowed should give 200
142 144 200 Script output follows
143 145 % tar.bz2 and zip disallowed should both give 403
144 146 403 Archive type not allowed: bz2
145 147 403 Archive type not allowed: zip
146 148 $ test_archtype_deprecated bz2 tar.bz2 zip tar.gz
147 149 % bz2 allowed should give 200
148 150 200 Script output follows
149 151 % zip and tar.gz disallowed should both give 403
150 152 403 Archive type not allowed: zip
151 153 403 Archive type not allowed: gz
152 154 $ test_archtype_deprecated zip zip tar.gz tar.bz2
153 155 % zip allowed should give 200
154 156 200 Script output follows
155 157 % tar.gz and tar.bz2 disallowed should both give 403
156 158 403 Archive type not allowed: gz
157 159 403 Archive type not allowed: bz2
158 160
159 161 $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc
160 162 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
161 163 $ cat hg.pid >> $DAEMON_PIDS
162 164
163 165 check archive links' order
164 166
165 167 $ get-with-headers.py localhost:$HGPORT "?revcount=1" | grep '/archive/tip.'
166 168 <a href="/archive/tip.zip">zip</a>
167 169 <a href="/archive/tip.tar.gz">gz</a>
168 170 <a href="/archive/tip.tar.bz2">bz2</a>
169 171
170 172 invalid arch type should give 404
171 173
172 174 $ get-with-headers.py localhost:$HGPORT "archive/tip.invalid" | head -n 1
173 175 404 Unsupported archive type: None
174 176
175 177 $ TIP=`hg id -v | cut -f1 -d' '`
176 178 $ QTIP=`hg id -q`
177 179 $ cat > getarchive.py <<EOF
178 180 > from __future__ import absolute_import
179 181 > import os
180 182 > import sys
181 183 > from mercurial import (
182 184 > util,
183 185 > )
184 186 > try:
185 187 > # Set stdout to binary mode for win32 platforms
186 188 > import msvcrt
187 189 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
188 190 > except ImportError:
189 191 > pass
190 192 > if len(sys.argv) <= 3:
191 193 > node, archive = sys.argv[1:]
192 194 > requeststr = 'cmd=archive;node=%s;type=%s' % (node, archive)
193 195 > else:
194 196 > node, archive, file = sys.argv[1:]
195 197 > requeststr = 'cmd=archive;node=%s;type=%s;file=%s' % (node, archive, file)
196 198 > try:
197 199 > stdout = sys.stdout.buffer
198 200 > except AttributeError:
199 201 > stdout = sys.stdout
200 202 > try:
201 203 > f = util.urlreq.urlopen('http://$LOCALIP:%s/?%s'
202 204 > % (os.environ['HGPORT'], requeststr))
203 205 > stdout.write(f.read())
204 206 > except util.urlerr.httperror as e:
205 207 > sys.stderr.write(str(e) + '\n')
206 208 > EOF
207 209 $ $PYTHON getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null
208 210 test-archive-1701ef1f1510/.hg_archival.txt
209 211 test-archive-1701ef1f1510/.hgsub
210 212 test-archive-1701ef1f1510/.hgsubstate
211 213 test-archive-1701ef1f1510/bar
212 214 test-archive-1701ef1f1510/baz/bletch
213 215 test-archive-1701ef1f1510/foo
214 216 test-archive-1701ef1f1510/subrepo/sub
215 217 $ $PYTHON getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null
216 218 test-archive-1701ef1f1510/.hg_archival.txt
217 219 test-archive-1701ef1f1510/.hgsub
218 220 test-archive-1701ef1f1510/.hgsubstate
219 221 test-archive-1701ef1f1510/bar
220 222 test-archive-1701ef1f1510/baz/bletch
221 223 test-archive-1701ef1f1510/foo
222 224 test-archive-1701ef1f1510/subrepo/sub
223 225 $ $PYTHON getarchive.py "$TIP" zip > archive.zip
224 226 $ unzip -t archive.zip
225 227 Archive: archive.zip
226 228 testing: test-archive-1701ef1f1510/.hg_archival.txt*OK (glob)
227 229 testing: test-archive-1701ef1f1510/.hgsub*OK (glob)
228 230 testing: test-archive-1701ef1f1510/.hgsubstate*OK (glob)
229 231 testing: test-archive-1701ef1f1510/bar*OK (glob)
230 232 testing: test-archive-1701ef1f1510/baz/bletch*OK (glob)
231 233 testing: test-archive-1701ef1f1510/foo*OK (glob)
232 234 testing: test-archive-1701ef1f1510/subrepo/sub*OK (glob)
233 235 No errors detected in compressed data of archive.zip.
234 236
235 237 test that we can download single directories and files
236 238
237 239 $ $PYTHON getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null
238 240 test-archive-1701ef1f1510/baz/bletch
239 241 $ $PYTHON getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null
240 242 test-archive-1701ef1f1510/foo
241 243
242 244 test that we detect file patterns that match no files
243 245
244 246 $ $PYTHON getarchive.py "$TIP" gz foobar
245 247 HTTP Error 404: file(s) not found: foobar
246 248
247 249 test that we reject unsafe patterns
248 250
249 251 $ $PYTHON getarchive.py "$TIP" gz relre:baz
250 252 HTTP Error 404: file(s) not found: relre:baz
251 253
252 254 $ killdaemons.py
253 255
254 256 $ hg archive -t tar test.tar
255 257 $ tar tf test.tar
256 258 test/.hg_archival.txt
257 259 test/.hgsub
258 260 test/.hgsubstate
259 261 test/bar
260 262 test/baz/bletch
261 263 test/foo
262 264
263 265 $ hg archive --debug -t tbz2 -X baz test.tar.bz2 --config progress.debug=true
264 266 archiving: 0/4 files (0.00%)
265 267 archiving: .hgsub 1/4 files (25.00%)
266 268 archiving: .hgsubstate 2/4 files (50.00%)
267 269 archiving: bar 3/4 files (75.00%)
268 270 archiving: foo 4/4 files (100.00%)
269 271 $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null
270 272 test/.hg_archival.txt
271 273 test/.hgsub
272 274 test/.hgsubstate
273 275 test/bar
274 276 test/foo
275 277
276 278 $ hg archive -t tgz -p %b-%h test-%h.tar.gz
277 279 $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null
278 280 test-1701ef1f1510/.hg_archival.txt
279 281 test-1701ef1f1510/.hgsub
280 282 test-1701ef1f1510/.hgsubstate
281 283 test-1701ef1f1510/bar
282 284 test-1701ef1f1510/baz/bletch
283 285 test-1701ef1f1510/foo
284 286
285 287 $ hg archive autodetected_test.tar
286 288 $ tar tf autodetected_test.tar
287 289 autodetected_test/.hg_archival.txt
288 290 autodetected_test/.hgsub
289 291 autodetected_test/.hgsubstate
290 292 autodetected_test/bar
291 293 autodetected_test/baz/bletch
292 294 autodetected_test/foo
293 295
294 296 The '-t' should override autodetection
295 297
296 298 $ hg archive -t tar autodetect_override_test.zip
297 299 $ tar tf autodetect_override_test.zip
298 300 autodetect_override_test.zip/.hg_archival.txt
299 301 autodetect_override_test.zip/.hgsub
300 302 autodetect_override_test.zip/.hgsubstate
301 303 autodetect_override_test.zip/bar
302 304 autodetect_override_test.zip/baz/bletch
303 305 autodetect_override_test.zip/foo
304 306
305 307 $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do
306 308 > hg archive auto_test.$ext
307 309 > if [ -d auto_test.$ext ]; then
308 310 > echo "extension $ext was not autodetected."
309 311 > fi
310 312 > done
311 313
312 314 $ cat > md5comp.py <<EOF
313 315 > from __future__ import absolute_import, print_function
314 316 > import hashlib
315 317 > import sys
316 318 > f1, f2 = sys.argv[1:3]
317 319 > h1 = hashlib.md5(open(f1, 'rb').read()).hexdigest()
318 320 > h2 = hashlib.md5(open(f2, 'rb').read()).hexdigest()
319 321 > print(h1 == h2 or "md5 differ: " + repr((h1, h2)))
320 322 > EOF
321 323
322 324 archive name is stored in the archive, so create similar archives and
323 325 rename them afterwards.
324 326
325 327 $ hg archive -t tgz tip.tar.gz
326 328 $ mv tip.tar.gz tip1.tar.gz
327 329 $ sleep 1
328 330 $ hg archive -t tgz tip.tar.gz
329 331 $ mv tip.tar.gz tip2.tar.gz
330 332 $ $PYTHON md5comp.py tip1.tar.gz tip2.tar.gz
331 333 True
332 334
333 335 $ hg archive -t zip -p /illegal test.zip
334 336 abort: archive prefix contains illegal components
335 337 [255]
336 338 $ hg archive -t zip -p very/../bad test.zip
337 339
338 340 $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
339 341 $ unzip -t test.zip
340 342 Archive: test.zip
341 343 testing: test/bar*OK (glob)
342 344 testing: test/baz/bletch*OK (glob)
343 345 testing: test/foo*OK (glob)
344 346 No errors detected in compressed data of test.zip.
345 347
346 348 $ hg archive -t tar - | tar tf - 2>/dev/null
347 349 test-1701ef1f1510/.hg_archival.txt
348 350 test-1701ef1f1510/.hgsub
349 351 test-1701ef1f1510/.hgsubstate
350 352 test-1701ef1f1510/bar
351 353 test-1701ef1f1510/baz/bletch
352 354 test-1701ef1f1510/foo
353 355
354 356 $ hg archive -r 0 -t tar rev-%r.tar
355 357 $ [ -f rev-0.tar ]
356 358
357 359 test .hg_archival.txt
358 360
359 361 $ hg archive ../test-tags
360 362 $ cat ../test-tags/.hg_archival.txt
361 363 repo: daa7f7c60e0a224faa4ff77ca41b2760562af264
362 364 node: 1701ef1f151069b8747038e93b5186bb43a47504
363 365 branch: default
364 366 latesttag: null
365 367 latesttagdistance: 4
366 368 changessincelatesttag: 4
367 369 $ hg tag -r 2 mytag
368 370 $ hg tag -r 2 anothertag
369 371 $ hg archive -r 2 ../test-lasttag
370 372 $ cat ../test-lasttag/.hg_archival.txt
371 373 repo: daa7f7c60e0a224faa4ff77ca41b2760562af264
372 374 node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e
373 375 branch: default
374 376 tag: anothertag
375 377 tag: mytag
376 378
377 379 $ hg archive -t bogus test.bogus
378 380 abort: unknown archive type 'bogus'
379 381 [255]
380 382
381 383 enable progress extension:
382 384
383 385 $ cp $HGRCPATH $HGRCPATH.no-progress
384 386 $ cat >> $HGRCPATH <<EOF
385 387 > [progress]
386 388 > assume-tty = 1
387 389 > format = topic bar number
388 390 > delay = 0
389 391 > refresh = 0
390 392 > width = 60
391 393 > EOF
392 394
393 395 $ hg archive ../with-progress
394 396 \r (no-eol) (esc)
395 397 archiving [ ] 0/6\r (no-eol) (esc)
396 398 archiving [======> ] 1/6\r (no-eol) (esc)
397 399 archiving [=============> ] 2/6\r (no-eol) (esc)
398 400 archiving [====================> ] 3/6\r (no-eol) (esc)
399 401 archiving [===========================> ] 4/6\r (no-eol) (esc)
400 402 archiving [==================================> ] 5/6\r (no-eol) (esc)
401 403 archiving [==========================================>] 6/6\r (no-eol) (esc)
402 404 \r (no-eol) (esc)
403 405
404 406 cleanup after progress extension test:
405 407
406 408 $ cp $HGRCPATH.no-progress $HGRCPATH
407 409
408 410 server errors
409 411
410 412 $ cat errors.log
411 413
412 414 empty repo
413 415
414 416 $ hg init ../empty
415 417 $ cd ../empty
416 418 $ hg archive ../test-empty
417 419 abort: no working directory: please specify a revision
418 420 [255]
419 421
420 422 old file -- date clamped to 1980
421 423
422 424 $ touch -t 197501010000 old
423 425 $ hg add old
424 426 $ hg commit -m old
425 427 $ hg archive ../old.zip
426 428 $ unzip -l ../old.zip | grep -v -- ----- | egrep -v files$
427 429 Archive: ../old.zip
428 430 \s*Length.* (re)
429 431 *172*80*00:00*old/.hg_archival.txt (glob)
430 432 *0*80*00:00*old/old (glob)
431 433
432 434 show an error when a provided pattern matches no files
433 435
434 436 $ hg archive -I file_that_does_not_exist.foo ../empty.zip
435 437 abort: no files match the archive pattern
436 438 [255]
437 439
438 440 $ hg archive -X * ../empty.zip
439 441 abort: no files match the archive pattern
440 442 [255]
441 443
442 444 $ cd ..
443 445
444 446 issue3600: check whether "hg archive" can create archive files which
445 447 are extracted with expected timestamp, even though TZ is not
446 448 configured as GMT.
447 449
448 450 $ mkdir issue3600
449 451 $ cd issue3600
450 452
451 453 $ hg init repo
452 454 $ echo a > repo/a
453 455 $ hg -R repo add repo/a
454 456 $ hg -R repo commit -m '#0' -d '456789012 21600'
455 457 $ cat > show_mtime.py <<EOF
456 458 > from __future__ import absolute_import, print_function
457 459 > import os
458 460 > import sys
459 461 > print(int(os.stat(sys.argv[1]).st_mtime))
460 462 > EOF
461 463
462 464 $ hg -R repo archive --prefix tar-extracted archive.tar
463 465 $ (TZ=UTC-3; export TZ; tar xf archive.tar)
464 466 $ $PYTHON show_mtime.py tar-extracted/a
465 467 456789012
466 468
467 469 $ hg -R repo archive --prefix zip-extracted archive.zip
468 470 $ (TZ=UTC-3; export TZ; unzip -q archive.zip)
469 471 $ $PYTHON show_mtime.py zip-extracted/a
470 472 456789012
471 473
472 474 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now