Show More
@@ -1,150 +1,150 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 | python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" |
|
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/" |
|
62 | python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
63 | python getarchive.py "$TIP" zip > archive.zip |
|
63 | 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 - 2>/dev/null |
|
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 - 2>/dev/null | sed "s/$QTIP/TIP/" |
|
75 | gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
76 |
|
76 | |||
77 | hg archive autodetected_test.tar |
|
77 | hg archive autodetected_test.tar | |
78 | tar tf autodetected_test.tar |
|
78 | tar tf autodetected_test.tar | |
79 |
|
79 | |||
80 | # The '-t' should override autodetection |
|
80 | # The '-t' should override autodetection | |
81 | hg archive -t tar autodetect_override_test.zip |
|
81 | hg archive -t tar autodetect_override_test.zip | |
82 | tar tf autodetect_override_test.zip |
|
82 | tar tf autodetect_override_test.zip | |
83 |
|
83 | |||
84 | for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do |
|
84 | for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do | |
85 | hg archive auto_test.$ext |
|
85 | hg archive auto_test.$ext | |
86 | if [ -d auto_test.$ext ]; then |
|
86 | if [ -d auto_test.$ext ]; then | |
87 | echo "extension $ext was not autodetected." |
|
87 | echo "extension $ext was not autodetected." | |
88 | fi |
|
88 | fi | |
89 | done |
|
89 | done | |
90 |
|
90 | |||
91 | cat > md5comp.py <<EOF |
|
91 | cat > md5comp.py <<EOF | |
92 | try: |
|
92 | try: | |
93 | from hashlib import md5 |
|
93 | from hashlib import md5 | |
94 | except ImportError: |
|
94 | except ImportError: | |
95 | from md5 import md5 |
|
95 | from md5 import md5 | |
96 | import sys |
|
96 | import sys | |
97 | f1, f2 = sys.argv[1:3] |
|
97 | f1, f2 = sys.argv[1:3] | |
98 | h1 = md5(file(f1, 'rb').read()).hexdigest() |
|
98 | h1 = md5(file(f1, 'rb').read()).hexdigest() | |
99 | h2 = md5(file(f2, 'rb').read()).hexdigest() |
|
99 | h2 = md5(file(f2, 'rb').read()).hexdigest() | |
100 | print h1 == h2 or "md5 differ: " + repr((h1, h2)) |
|
100 | print h1 == h2 or "md5 differ: " + repr((h1, h2)) | |
101 | EOF |
|
101 | EOF | |
102 |
|
102 | |||
103 | # archive name is stored in the archive, so create similar |
|
103 | # archive name is stored in the archive, so create similar | |
104 | # archives and rename them afterwards. |
|
104 | # archives and rename them afterwards. | |
105 | hg archive -t tgz tip.tar.gz |
|
105 | hg archive -t tgz tip.tar.gz | |
106 | mv tip.tar.gz tip1.tar.gz |
|
106 | mv tip.tar.gz tip1.tar.gz | |
107 | sleep 1 |
|
107 | sleep 1 | |
108 | hg archive -t tgz tip.tar.gz |
|
108 | hg archive -t tgz tip.tar.gz | |
109 | mv tip.tar.gz tip2.tar.gz |
|
109 | mv tip.tar.gz tip2.tar.gz | |
110 | python md5comp.py tip1.tar.gz tip2.tar.gz |
|
110 | python md5comp.py tip1.tar.gz tip2.tar.gz | |
111 |
|
111 | |||
112 | hg archive -t zip -p /illegal test.zip |
|
112 | hg archive -t zip -p /illegal test.zip | |
113 | hg archive -t zip -p very/../bad test.zip |
|
113 | hg archive -t zip -p very/../bad test.zip | |
114 |
|
114 | |||
115 | hg archive --config ui.archivemeta=false -t zip -r 2 test.zip |
|
115 | hg archive --config ui.archivemeta=false -t zip -r 2 test.zip | |
116 | unzip -t test.zip |
|
116 | unzip -t test.zip | |
117 |
|
117 | |||
118 | hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" |
|
118 | hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/" | |
119 |
|
119 | |||
120 | hg archive -r 0 -t tar rev-%r.tar |
|
120 | hg archive -r 0 -t tar rev-%r.tar | |
121 | if [ -f rev-0.tar ]; then |
|
121 | if [ -f rev-0.tar ]; then | |
122 | echo 'rev-0.tar created' |
|
122 | echo 'rev-0.tar created' | |
123 | fi |
|
123 | fi | |
124 |
|
124 | |||
125 | echo '% test .hg_archival.txt' |
|
125 | echo '% test .hg_archival.txt' | |
126 | hg archive ../test-tags |
|
126 | hg archive ../test-tags | |
127 | cat ../test-tags/.hg_archival.txt |
|
127 | cat ../test-tags/.hg_archival.txt | |
128 | hg tag -r 2 mytag |
|
128 | hg tag -r 2 mytag | |
129 | hg tag -r 2 anothertag |
|
129 | hg tag -r 2 anothertag | |
130 | hg archive -r 2 ../test-lasttag |
|
130 | hg archive -r 2 ../test-lasttag | |
131 | cat ../test-lasttag/.hg_archival.txt |
|
131 | cat ../test-lasttag/.hg_archival.txt | |
132 |
|
132 | |||
133 | hg archive -t bogus test.bogus |
|
133 | hg archive -t bogus test.bogus | |
134 |
|
134 | |||
135 | echo % server errors |
|
135 | echo % server errors | |
136 | cat errors.log |
|
136 | cat errors.log | |
137 |
|
137 | |||
138 | echo '% empty repo' |
|
138 | echo '% empty repo' | |
139 | hg init ../empty |
|
139 | hg init ../empty | |
140 | cd ../empty |
|
140 | cd ../empty | |
141 | hg archive ../test-empty |
|
141 | hg archive ../test-empty | |
142 |
|
142 | |||
143 | echo '% old file -- date clamped to 1980' |
|
143 | echo '% old file -- date clamped to 1980' | |
144 | touch -d 1975-01-01 old |
|
144 | touch -d 1975-01-01 old | |
145 | hg add old |
|
145 | hg add old | |
146 | hg commit -m old |
|
146 | hg commit -m old | |
147 | hg archive ../old.zip |
|
147 | hg archive ../old.zip | |
148 | unzip -l ../old.zip | grep 80 && echo ok |
|
148 | unzip -l ../old.zip | grep 80 > /dev/null && echo ok | |
149 |
|
149 | |||
150 | exit 0 |
|
150 | exit 0 |
@@ -1,86 +1,84 b'' | |||||
1 | adding foo |
|
1 | adding foo | |
2 | adding bar |
|
2 | adding bar | |
3 | adding baz/bletch |
|
3 | adding baz/bletch | |
4 |
|
4 | |||
5 | % gz allowed should give 200 |
|
5 | % gz allowed should give 200 | |
6 | 200 Script output follows |
|
6 | 200 Script output follows | |
7 | % tar.bz2 and zip disallowed should both give 403 |
|
7 | % tar.bz2 and zip disallowed should both give 403 | |
8 | 403 Archive type not allowed: bz2 |
|
8 | 403 Archive type not allowed: bz2 | |
9 | 403 Archive type not allowed: zip |
|
9 | 403 Archive type not allowed: zip | |
10 | % bz2 allowed should give 200 |
|
10 | % bz2 allowed should give 200 | |
11 | 200 Script output follows |
|
11 | 200 Script output follows | |
12 | % zip and tar.gz disallowed should both give 403 |
|
12 | % zip and tar.gz disallowed should both give 403 | |
13 | 403 Archive type not allowed: zip |
|
13 | 403 Archive type not allowed: zip | |
14 | 403 Archive type not allowed: gz |
|
14 | 403 Archive type not allowed: gz | |
15 | % zip allowed should give 200 |
|
15 | % zip allowed should give 200 | |
16 | 200 Script output follows |
|
16 | 200 Script output follows | |
17 | % tar.gz and tar.bz2 disallowed should both give 403 |
|
17 | % tar.gz and tar.bz2 disallowed should both give 403 | |
18 | 403 Archive type not allowed: gz |
|
18 | 403 Archive type not allowed: gz | |
19 | 403 Archive type not allowed: bz2 |
|
19 | 403 Archive type not allowed: bz2 | |
20 | % invalid arch type should give 404 |
|
20 | % invalid arch type should give 404 | |
21 | 404 Unsupported archive type: None |
|
21 | 404 Unsupported archive type: None | |
22 |
|
22 | |||
23 | test-archive-TIP/.hg_archival.txt |
|
23 | test-archive-TIP/.hg_archival.txt | |
24 | test-archive-TIP/bar |
|
24 | test-archive-TIP/bar | |
25 | test-archive-TIP/baz/bletch |
|
25 | test-archive-TIP/baz/bletch | |
26 | test-archive-TIP/foo |
|
26 | test-archive-TIP/foo | |
27 | test-archive-TIP/.hg_archival.txt |
|
27 | test-archive-TIP/.hg_archival.txt | |
28 | test-archive-TIP/bar |
|
28 | test-archive-TIP/bar | |
29 | test-archive-TIP/baz/bletch |
|
29 | test-archive-TIP/baz/bletch | |
30 | test-archive-TIP/foo |
|
30 | test-archive-TIP/foo | |
31 | Archive: archive.zip |
|
31 | Archive: archive.zip | |
32 | testing: test-archive-TIP/.hg_archival.txt OK |
|
32 | testing: test-archive-TIP/.hg_archival.txt OK | |
33 | testing: test-archive-TIP/bar OK |
|
33 | testing: test-archive-TIP/bar OK | |
34 | testing: test-archive-TIP/baz/bletch OK |
|
34 | testing: test-archive-TIP/baz/bletch OK | |
35 | testing: test-archive-TIP/foo OK |
|
35 | testing: test-archive-TIP/foo OK | |
36 | No errors detected in compressed data of archive.zip. |
|
36 | No errors detected in compressed data of archive.zip. | |
37 | test/.hg_archival.txt |
|
37 | test/.hg_archival.txt | |
38 | test/bar |
|
38 | test/bar | |
39 | test/baz/bletch |
|
39 | test/baz/bletch | |
40 | test/foo |
|
40 | test/foo | |
41 | test/.hg_archival.txt |
|
41 | test/.hg_archival.txt | |
42 | test/bar |
|
42 | test/bar | |
43 | test/foo |
|
43 | test/foo | |
44 | test-TIP/.hg_archival.txt |
|
44 | test-TIP/.hg_archival.txt | |
45 | test-TIP/bar |
|
45 | test-TIP/bar | |
46 | test-TIP/baz/bletch |
|
46 | test-TIP/baz/bletch | |
47 | test-TIP/foo |
|
47 | test-TIP/foo | |
48 | autodetected_test/.hg_archival.txt |
|
48 | autodetected_test/.hg_archival.txt | |
49 | autodetected_test/bar |
|
49 | autodetected_test/bar | |
50 | autodetected_test/baz/bletch |
|
50 | autodetected_test/baz/bletch | |
51 | autodetected_test/foo |
|
51 | autodetected_test/foo | |
52 | autodetect_override_test.zip/.hg_archival.txt |
|
52 | autodetect_override_test.zip/.hg_archival.txt | |
53 | autodetect_override_test.zip/bar |
|
53 | autodetect_override_test.zip/bar | |
54 | autodetect_override_test.zip/baz/bletch |
|
54 | autodetect_override_test.zip/baz/bletch | |
55 | autodetect_override_test.zip/foo |
|
55 | autodetect_override_test.zip/foo | |
56 | True |
|
56 | True | |
57 | abort: archive prefix contains illegal components |
|
57 | abort: archive prefix contains illegal components | |
58 | Archive: test.zip |
|
58 | Archive: test.zip | |
59 | testing: test/bar OK |
|
59 | testing: test/bar OK | |
60 | testing: test/baz/bletch OK |
|
60 | testing: test/baz/bletch OK | |
61 | testing: test/foo OK |
|
61 | testing: test/foo OK | |
62 | No errors detected in compressed data of test.zip. |
|
62 | No errors detected in compressed data of test.zip. | |
63 | test-TIP/.hg_archival.txt |
|
63 | test-TIP/.hg_archival.txt | |
64 | test-TIP/bar |
|
64 | test-TIP/bar | |
65 | test-TIP/baz/bletch |
|
65 | test-TIP/baz/bletch | |
66 | test-TIP/foo |
|
66 | test-TIP/foo | |
67 | rev-0.tar created |
|
67 | rev-0.tar created | |
68 | % test .hg_archival.txt |
|
68 | % test .hg_archival.txt | |
69 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 |
|
69 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 | |
70 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e |
|
70 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e | |
71 | branch: default |
|
71 | branch: default | |
72 | latesttag: null |
|
72 | latesttag: null | |
73 | latesttagdistance: 3 |
|
73 | latesttagdistance: 3 | |
74 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 |
|
74 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 | |
75 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e |
|
75 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e | |
76 | branch: default |
|
76 | branch: default | |
77 | tag: anothertag |
|
77 | tag: anothertag | |
78 | tag: mytag |
|
78 | tag: mytag | |
79 | abort: unknown archive type 'bogus' |
|
79 | abort: unknown archive type 'bogus' | |
80 | % server errors |
|
80 | % server errors | |
81 | % empty repo |
|
81 | % empty repo | |
82 | abort: no working directory: please specify a revision |
|
82 | abort: no working directory: please specify a revision | |
83 | % old file -- date clamped to 1980 |
|
83 | % old file -- date clamped to 1980 | |
84 | 147 1980-01-01 00:00 old/.hg_archival.txt |
|
|||
85 | 0 1980-01-01 00:00 old/old |
|
|||
86 | ok |
|
84 | ok |
General Comments 0
You need to be logged in to leave comments.
Login now