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