Show More
@@ -1,474 +1,609 | |||
|
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) |
|
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) |
|
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) |
|
83 | 83 | $ diff -r archive test |
|
84 | 84 | Only in test: .hg |
|
85 | 85 | Common subdirectories: archive/baz and test/baz (?) |
|
86 | 86 | Common subdirectories: archive/subrepo and test/subrepo (?) |
|
87 | 87 | Only in test/subrepo: .hg |
|
88 | 88 | [1] |
|
89 | 89 | $ rm -rf archive |
|
90 | 90 | |
|
91 | 91 | $ cd test |
|
92 | 92 | $ echo "[web]" >> .hg/hgrc |
|
93 | 93 | $ echo "name = test-archive" >> .hg/hgrc |
|
94 | 94 | $ echo "archivesubrepos = True" >> .hg/hgrc |
|
95 | 95 | $ cp .hg/hgrc .hg/hgrc-base |
|
96 | 96 | > test_archtype() { |
|
97 | 97 | > echo "allow_archive = $1" >> .hg/hgrc |
|
98 | 98 | > test_archtype_run "$@" |
|
99 | 99 | > } |
|
100 | 100 | > test_archtype_deprecated() { |
|
101 | 101 | > echo "allow$1 = True" >> .hg/hgrc |
|
102 | 102 | > test_archtype_run "$@" |
|
103 | 103 | > } |
|
104 | 104 | > test_archtype_run() { |
|
105 | 105 | > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log \ |
|
106 | 106 | > --config extensions.blackbox= --config blackbox.track=develwarn |
|
107 | 107 | > cat hg.pid >> $DAEMON_PIDS |
|
108 | 108 | > echo % $1 allowed should give 200 |
|
109 |
> get-with-headers.py localhost:$HGPORT "archive/tip.$2" |
|
|
109 | > get-with-headers.py --bodyfile body localhost:$HGPORT "archive/tip.$2" - | |
|
110 | > f --size --sha1 body | |
|
110 | 111 | > echo % $3 and $4 disallowed should both give 403 |
|
111 |
> get-with-headers.py localhost:$HGPORT "archive/tip.$3" |
|
|
112 | > get-with-headers.py localhost:$HGPORT "archive/tip.$4" | head -n 1 | |
|
112 | > get-with-headers.py --bodyfile body localhost:$HGPORT "archive/tip.$3" - | |
|
113 | > f --size --sha1 body | |
|
114 | > get-with-headers.py --bodyfile body localhost:$HGPORT "archive/tip.$4" - | |
|
115 | > f --size --sha1 body | |
|
113 | 116 | > killdaemons.py |
|
114 | 117 | > cat errors.log |
|
115 | 118 | > hg blackbox --config extensions.blackbox= --config blackbox.track= |
|
116 | 119 | > cp .hg/hgrc-base .hg/hgrc |
|
117 | 120 | > } |
|
118 | 121 | |
|
119 | 122 | check http return codes |
|
120 | 123 | |
|
121 | 124 | $ test_archtype gz tar.gz tar.bz2 zip |
|
122 | 125 | % gz allowed should give 200 |
|
123 | 126 | 200 Script output follows |
|
127 | content-disposition: attachment; filename=test-archive-1701ef1f1510.tar.gz | |
|
128 | content-type: application/x-gzip | |
|
129 | date: * (glob) | |
|
130 | etag: W/"*" (glob) | |
|
131 | server: * (glob) | |
|
132 | transfer-encoding: chunked | |
|
133 | ||
|
134 | body: size=408, sha1=8fa06531bddecc365a9f5edb0f88b65974bfe505 | |
|
124 | 135 | % tar.bz2 and zip disallowed should both give 403 |
|
125 | 136 | 403 Archive type not allowed: bz2 |
|
137 | content-type: text/html; charset=ascii | |
|
138 | date: * (glob) | |
|
139 | etag: W/"*" (glob) | |
|
140 | server: * (glob) | |
|
141 | transfer-encoding: chunked | |
|
142 | ||
|
143 | body: size=1451, sha1=4c5cf0f574446c44feb7f88f4e0e2a56bd92c352 | |
|
126 | 144 | 403 Archive type not allowed: zip |
|
145 | content-type: text/html; charset=ascii | |
|
146 | date: * (glob) | |
|
147 | etag: W/"*" (glob) | |
|
148 | server: * (glob) | |
|
149 | transfer-encoding: chunked | |
|
150 | ||
|
151 | body: size=1451, sha1=cbfa5574b337348bfd0564cc534474d002e7d6c7 | |
|
127 | 152 | $ test_archtype bz2 tar.bz2 zip tar.gz |
|
128 | 153 | % bz2 allowed should give 200 |
|
129 | 154 | 200 Script output follows |
|
155 | content-disposition: attachment; filename=test-archive-1701ef1f1510.tar.bz2 | |
|
156 | content-type: application/x-bzip2 | |
|
157 | date: * (glob) | |
|
158 | etag: W/"*" (glob) | |
|
159 | server: * (glob) | |
|
160 | transfer-encoding: chunked | |
|
161 | ||
|
162 | body: size=426, sha1=8d87f5aba6e14f1bfea6c232985982c278b2fb0b | |
|
130 | 163 | % zip and tar.gz disallowed should both give 403 |
|
131 | 164 | 403 Archive type not allowed: zip |
|
165 | content-type: text/html; charset=ascii | |
|
166 | date: * (glob) | |
|
167 | etag: W/"*" (glob) | |
|
168 | server: * (glob) | |
|
169 | transfer-encoding: chunked | |
|
170 | ||
|
171 | body: size=1451, sha1=cbfa5574b337348bfd0564cc534474d002e7d6c7 | |
|
132 | 172 | 403 Archive type not allowed: gz |
|
173 | content-type: text/html; charset=ascii | |
|
174 | date: * (glob) | |
|
175 | etag: W/"*" (glob) | |
|
176 | server: * (glob) | |
|
177 | transfer-encoding: chunked | |
|
178 | ||
|
179 | body: size=1450, sha1=71f0b12d59f85fdcfe8ff493e2dc66863f2f7734 | |
|
133 | 180 | $ test_archtype zip zip tar.gz tar.bz2 |
|
134 | 181 | % zip allowed should give 200 |
|
135 | 182 | 200 Script output follows |
|
183 | content-disposition: attachment; filename=test-archive-1701ef1f1510.zip | |
|
184 | content-type: application/zip | |
|
185 | date: * (glob) | |
|
186 | etag: W/"*" (glob) | |
|
187 | server: * (glob) | |
|
188 | transfer-encoding: chunked | |
|
189 | ||
|
190 | body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 | |
|
136 | 191 | % tar.gz and tar.bz2 disallowed should both give 403 |
|
137 | 192 | 403 Archive type not allowed: gz |
|
193 | content-type: text/html; charset=ascii | |
|
194 | date: * (glob) | |
|
195 | etag: W/"*" (glob) | |
|
196 | server: * (glob) | |
|
197 | transfer-encoding: chunked | |
|
198 | ||
|
199 | body: size=1450, sha1=71f0b12d59f85fdcfe8ff493e2dc66863f2f7734 | |
|
138 | 200 | 403 Archive type not allowed: bz2 |
|
201 | content-type: text/html; charset=ascii | |
|
202 | date: * (glob) | |
|
203 | etag: W/"*" (glob) | |
|
204 | server: * (glob) | |
|
205 | transfer-encoding: chunked | |
|
206 | ||
|
207 | body: size=1451, sha1=4c5cf0f574446c44feb7f88f4e0e2a56bd92c352 | |
|
139 | 208 | |
|
140 | 209 | check http return codes (with deprecated option) |
|
141 | 210 | |
|
142 | 211 | $ test_archtype_deprecated gz tar.gz tar.bz2 zip |
|
143 | 212 | % gz allowed should give 200 |
|
144 | 213 | 200 Script output follows |
|
214 | content-disposition: attachment; filename=test-archive-1701ef1f1510.tar.gz | |
|
215 | content-type: application/x-gzip | |
|
216 | date: * (glob) | |
|
217 | etag: W/"*" (glob) | |
|
218 | server: * (glob) | |
|
219 | transfer-encoding: chunked | |
|
220 | ||
|
221 | body: size=408, sha1=8fa06531bddecc365a9f5edb0f88b65974bfe505 | |
|
145 | 222 | % tar.bz2 and zip disallowed should both give 403 |
|
146 | 223 | 403 Archive type not allowed: bz2 |
|
224 | content-type: text/html; charset=ascii | |
|
225 | date: * (glob) | |
|
226 | etag: W/"*" (glob) | |
|
227 | server: * (glob) | |
|
228 | transfer-encoding: chunked | |
|
229 | ||
|
230 | body: size=1451, sha1=4c5cf0f574446c44feb7f88f4e0e2a56bd92c352 | |
|
147 | 231 | 403 Archive type not allowed: zip |
|
232 | content-type: text/html; charset=ascii | |
|
233 | date: * (glob) | |
|
234 | etag: W/"*" (glob) | |
|
235 | server: * (glob) | |
|
236 | transfer-encoding: chunked | |
|
237 | ||
|
238 | body: size=1451, sha1=cbfa5574b337348bfd0564cc534474d002e7d6c7 | |
|
148 | 239 | $ test_archtype_deprecated bz2 tar.bz2 zip tar.gz |
|
149 | 240 | % bz2 allowed should give 200 |
|
150 | 241 | 200 Script output follows |
|
242 | content-disposition: attachment; filename=test-archive-1701ef1f1510.tar.bz2 | |
|
243 | content-type: application/x-bzip2 | |
|
244 | date: * (glob) | |
|
245 | etag: W/"*" (glob) | |
|
246 | server: * (glob) | |
|
247 | transfer-encoding: chunked | |
|
248 | ||
|
249 | body: size=426, sha1=8d87f5aba6e14f1bfea6c232985982c278b2fb0b | |
|
151 | 250 | % zip and tar.gz disallowed should both give 403 |
|
152 | 251 | 403 Archive type not allowed: zip |
|
252 | content-type: text/html; charset=ascii | |
|
253 | date: * (glob) | |
|
254 | etag: W/"*" (glob) | |
|
255 | server: * (glob) | |
|
256 | transfer-encoding: chunked | |
|
257 | ||
|
258 | body: size=1451, sha1=cbfa5574b337348bfd0564cc534474d002e7d6c7 | |
|
153 | 259 | 403 Archive type not allowed: gz |
|
260 | content-type: text/html; charset=ascii | |
|
261 | date: * (glob) | |
|
262 | etag: W/"*" (glob) | |
|
263 | server: * (glob) | |
|
264 | transfer-encoding: chunked | |
|
265 | ||
|
266 | body: size=1450, sha1=71f0b12d59f85fdcfe8ff493e2dc66863f2f7734 | |
|
154 | 267 | $ test_archtype_deprecated zip zip tar.gz tar.bz2 |
|
155 | 268 | % zip allowed should give 200 |
|
156 | 269 | 200 Script output follows |
|
270 | content-disposition: attachment; filename=test-archive-1701ef1f1510.zip | |
|
271 | content-type: application/zip | |
|
272 | date: * (glob) | |
|
273 | etag: W/"*" (glob) | |
|
274 | server: * (glob) | |
|
275 | transfer-encoding: chunked | |
|
276 | ||
|
277 | body: size=1377, sha1=677b14d3d048778d5eb5552c14a67e6192068650 | |
|
157 | 278 | % tar.gz and tar.bz2 disallowed should both give 403 |
|
158 | 279 | 403 Archive type not allowed: gz |
|
280 | content-type: text/html; charset=ascii | |
|
281 | date: * (glob) | |
|
282 | etag: W/"*" (glob) | |
|
283 | server: * (glob) | |
|
284 | transfer-encoding: chunked | |
|
285 | ||
|
286 | body: size=1450, sha1=71f0b12d59f85fdcfe8ff493e2dc66863f2f7734 | |
|
159 | 287 | 403 Archive type not allowed: bz2 |
|
288 | content-type: text/html; charset=ascii | |
|
289 | date: * (glob) | |
|
290 | etag: W/"*" (glob) | |
|
291 | server: * (glob) | |
|
292 | transfer-encoding: chunked | |
|
293 | ||
|
294 | body: size=1451, sha1=4c5cf0f574446c44feb7f88f4e0e2a56bd92c352 | |
|
160 | 295 | |
|
161 | 296 | $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc |
|
162 | 297 | $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log |
|
163 | 298 | $ cat hg.pid >> $DAEMON_PIDS |
|
164 | 299 | |
|
165 | 300 | check archive links' order |
|
166 | 301 | |
|
167 | 302 | $ get-with-headers.py localhost:$HGPORT "?revcount=1" | grep '/archive/tip.' |
|
168 | 303 | <a href="/archive/tip.zip">zip</a> |
|
169 | 304 | <a href="/archive/tip.tar.gz">gz</a> |
|
170 | 305 | <a href="/archive/tip.tar.bz2">bz2</a> |
|
171 | 306 | |
|
172 | 307 | invalid arch type should give 404 |
|
173 | 308 | |
|
174 | 309 | $ get-with-headers.py localhost:$HGPORT "archive/tip.invalid" | head -n 1 |
|
175 | 310 | 404 Unsupported archive type: None |
|
176 | 311 | |
|
177 | 312 | $ TIP=`hg id -v | cut -f1 -d' '` |
|
178 | 313 | $ QTIP=`hg id -q` |
|
179 | 314 | $ cat > getarchive.py <<EOF |
|
180 | 315 | > from __future__ import absolute_import |
|
181 | 316 | > import os |
|
182 | 317 | > import sys |
|
183 | 318 | > from mercurial import ( |
|
184 | 319 | > util, |
|
185 | 320 | > ) |
|
186 | 321 | > try: |
|
187 | 322 | > # Set stdout to binary mode for win32 platforms |
|
188 | 323 | > import msvcrt |
|
189 | 324 | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
|
190 | 325 | > except ImportError: |
|
191 | 326 | > pass |
|
192 | 327 | > if len(sys.argv) <= 3: |
|
193 | 328 | > node, archive = sys.argv[1:] |
|
194 | 329 | > requeststr = 'cmd=archive;node=%s;type=%s' % (node, archive) |
|
195 | 330 | > else: |
|
196 | 331 | > node, archive, file = sys.argv[1:] |
|
197 | 332 | > requeststr = 'cmd=archive;node=%s;type=%s;file=%s' % (node, archive, file) |
|
198 | 333 | > try: |
|
199 | 334 | > stdout = sys.stdout.buffer |
|
200 | 335 | > except AttributeError: |
|
201 | 336 | > stdout = sys.stdout |
|
202 | 337 | > try: |
|
203 | 338 | > f = util.urlreq.urlopen('http://$LOCALIP:%s/?%s' |
|
204 | 339 | > % (os.environ['HGPORT'], requeststr)) |
|
205 | 340 | > stdout.write(f.read()) |
|
206 | 341 | > except util.urlerr.httperror as e: |
|
207 | 342 | > sys.stderr.write(str(e) + '\n') |
|
208 | 343 | > EOF |
|
209 | 344 | $ $PYTHON getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null |
|
210 | 345 | test-archive-1701ef1f1510/.hg_archival.txt |
|
211 | 346 | test-archive-1701ef1f1510/.hgsub |
|
212 | 347 | test-archive-1701ef1f1510/.hgsubstate |
|
213 | 348 | test-archive-1701ef1f1510/bar |
|
214 | 349 | test-archive-1701ef1f1510/baz/bletch |
|
215 | 350 | test-archive-1701ef1f1510/foo |
|
216 | 351 | test-archive-1701ef1f1510/subrepo/sub |
|
217 | 352 | $ $PYTHON getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null |
|
218 | 353 | test-archive-1701ef1f1510/.hg_archival.txt |
|
219 | 354 | test-archive-1701ef1f1510/.hgsub |
|
220 | 355 | test-archive-1701ef1f1510/.hgsubstate |
|
221 | 356 | test-archive-1701ef1f1510/bar |
|
222 | 357 | test-archive-1701ef1f1510/baz/bletch |
|
223 | 358 | test-archive-1701ef1f1510/foo |
|
224 | 359 | test-archive-1701ef1f1510/subrepo/sub |
|
225 | 360 | $ $PYTHON getarchive.py "$TIP" zip > archive.zip |
|
226 | 361 | $ unzip -t archive.zip |
|
227 | 362 | Archive: archive.zip |
|
228 | 363 | testing: test-archive-1701ef1f1510/.hg_archival.txt*OK (glob) |
|
229 | 364 | testing: test-archive-1701ef1f1510/.hgsub*OK (glob) |
|
230 | 365 | testing: test-archive-1701ef1f1510/.hgsubstate*OK (glob) |
|
231 | 366 | testing: test-archive-1701ef1f1510/bar*OK (glob) |
|
232 | 367 | testing: test-archive-1701ef1f1510/baz/bletch*OK (glob) |
|
233 | 368 | testing: test-archive-1701ef1f1510/foo*OK (glob) |
|
234 | 369 | testing: test-archive-1701ef1f1510/subrepo/sub*OK (glob) |
|
235 | 370 | No errors detected in compressed data of archive.zip. |
|
236 | 371 | |
|
237 | 372 | test that we can download single directories and files |
|
238 | 373 | |
|
239 | 374 | $ $PYTHON getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null |
|
240 | 375 | test-archive-1701ef1f1510/baz/bletch |
|
241 | 376 | $ $PYTHON getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null |
|
242 | 377 | test-archive-1701ef1f1510/foo |
|
243 | 378 | |
|
244 | 379 | test that we detect file patterns that match no files |
|
245 | 380 | |
|
246 | 381 | $ $PYTHON getarchive.py "$TIP" gz foobar |
|
247 | 382 | HTTP Error 404: file(s) not found: foobar |
|
248 | 383 | |
|
249 | 384 | test that we reject unsafe patterns |
|
250 | 385 | |
|
251 | 386 | $ $PYTHON getarchive.py "$TIP" gz relre:baz |
|
252 | 387 | HTTP Error 404: file(s) not found: relre:baz |
|
253 | 388 | |
|
254 | 389 | $ killdaemons.py |
|
255 | 390 | |
|
256 | 391 | $ hg archive -t tar test.tar |
|
257 | 392 | $ tar tf test.tar |
|
258 | 393 | test/.hg_archival.txt |
|
259 | 394 | test/.hgsub |
|
260 | 395 | test/.hgsubstate |
|
261 | 396 | test/bar |
|
262 | 397 | test/baz/bletch |
|
263 | 398 | test/foo |
|
264 | 399 | |
|
265 | 400 | $ hg archive --debug -t tbz2 -X baz test.tar.bz2 --config progress.debug=true |
|
266 | 401 | archiving: 0/4 files (0.00%) |
|
267 | 402 | archiving: .hgsub 1/4 files (25.00%) |
|
268 | 403 | archiving: .hgsubstate 2/4 files (50.00%) |
|
269 | 404 | archiving: bar 3/4 files (75.00%) |
|
270 | 405 | archiving: foo 4/4 files (100.00%) |
|
271 | 406 | $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null |
|
272 | 407 | test/.hg_archival.txt |
|
273 | 408 | test/.hgsub |
|
274 | 409 | test/.hgsubstate |
|
275 | 410 | test/bar |
|
276 | 411 | test/foo |
|
277 | 412 | |
|
278 | 413 | $ hg archive -t tgz -p %b-%h test-%h.tar.gz |
|
279 | 414 | $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null |
|
280 | 415 | test-1701ef1f1510/.hg_archival.txt |
|
281 | 416 | test-1701ef1f1510/.hgsub |
|
282 | 417 | test-1701ef1f1510/.hgsubstate |
|
283 | 418 | test-1701ef1f1510/bar |
|
284 | 419 | test-1701ef1f1510/baz/bletch |
|
285 | 420 | test-1701ef1f1510/foo |
|
286 | 421 | |
|
287 | 422 | $ hg archive autodetected_test.tar |
|
288 | 423 | $ tar tf autodetected_test.tar |
|
289 | 424 | autodetected_test/.hg_archival.txt |
|
290 | 425 | autodetected_test/.hgsub |
|
291 | 426 | autodetected_test/.hgsubstate |
|
292 | 427 | autodetected_test/bar |
|
293 | 428 | autodetected_test/baz/bletch |
|
294 | 429 | autodetected_test/foo |
|
295 | 430 | |
|
296 | 431 | The '-t' should override autodetection |
|
297 | 432 | |
|
298 | 433 | $ hg archive -t tar autodetect_override_test.zip |
|
299 | 434 | $ tar tf autodetect_override_test.zip |
|
300 | 435 | autodetect_override_test.zip/.hg_archival.txt |
|
301 | 436 | autodetect_override_test.zip/.hgsub |
|
302 | 437 | autodetect_override_test.zip/.hgsubstate |
|
303 | 438 | autodetect_override_test.zip/bar |
|
304 | 439 | autodetect_override_test.zip/baz/bletch |
|
305 | 440 | autodetect_override_test.zip/foo |
|
306 | 441 | |
|
307 | 442 | $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do |
|
308 | 443 | > hg archive auto_test.$ext |
|
309 | 444 | > if [ -d auto_test.$ext ]; then |
|
310 | 445 | > echo "extension $ext was not autodetected." |
|
311 | 446 | > fi |
|
312 | 447 | > done |
|
313 | 448 | |
|
314 | 449 | $ cat > md5comp.py <<EOF |
|
315 | 450 | > from __future__ import absolute_import, print_function |
|
316 | 451 | > import hashlib |
|
317 | 452 | > import sys |
|
318 | 453 | > f1, f2 = sys.argv[1:3] |
|
319 | 454 | > h1 = hashlib.md5(open(f1, 'rb').read()).hexdigest() |
|
320 | 455 | > h2 = hashlib.md5(open(f2, 'rb').read()).hexdigest() |
|
321 | 456 | > print(h1 == h2 or "md5 differ: " + repr((h1, h2))) |
|
322 | 457 | > EOF |
|
323 | 458 | |
|
324 | 459 | archive name is stored in the archive, so create similar archives and |
|
325 | 460 | rename them afterwards. |
|
326 | 461 | |
|
327 | 462 | $ hg archive -t tgz tip.tar.gz |
|
328 | 463 | $ mv tip.tar.gz tip1.tar.gz |
|
329 | 464 | $ sleep 1 |
|
330 | 465 | $ hg archive -t tgz tip.tar.gz |
|
331 | 466 | $ mv tip.tar.gz tip2.tar.gz |
|
332 | 467 | $ $PYTHON md5comp.py tip1.tar.gz tip2.tar.gz |
|
333 | 468 | True |
|
334 | 469 | |
|
335 | 470 | $ hg archive -t zip -p /illegal test.zip |
|
336 | 471 | abort: archive prefix contains illegal components |
|
337 | 472 | [255] |
|
338 | 473 | $ hg archive -t zip -p very/../bad test.zip |
|
339 | 474 | |
|
340 | 475 | $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip |
|
341 | 476 | $ unzip -t test.zip |
|
342 | 477 | Archive: test.zip |
|
343 | 478 | testing: test/bar*OK (glob) |
|
344 | 479 | testing: test/baz/bletch*OK (glob) |
|
345 | 480 | testing: test/foo*OK (glob) |
|
346 | 481 | No errors detected in compressed data of test.zip. |
|
347 | 482 | |
|
348 | 483 | $ hg archive -t tar - | tar tf - 2>/dev/null |
|
349 | 484 | test-1701ef1f1510/.hg_archival.txt |
|
350 | 485 | test-1701ef1f1510/.hgsub |
|
351 | 486 | test-1701ef1f1510/.hgsubstate |
|
352 | 487 | test-1701ef1f1510/bar |
|
353 | 488 | test-1701ef1f1510/baz/bletch |
|
354 | 489 | test-1701ef1f1510/foo |
|
355 | 490 | |
|
356 | 491 | $ hg archive -r 0 -t tar rev-%r.tar |
|
357 | 492 | $ [ -f rev-0.tar ] |
|
358 | 493 | |
|
359 | 494 | test .hg_archival.txt |
|
360 | 495 | |
|
361 | 496 | $ hg archive ../test-tags |
|
362 | 497 | $ cat ../test-tags/.hg_archival.txt |
|
363 | 498 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 |
|
364 | 499 | node: 1701ef1f151069b8747038e93b5186bb43a47504 |
|
365 | 500 | branch: default |
|
366 | 501 | latesttag: null |
|
367 | 502 | latesttagdistance: 4 |
|
368 | 503 | changessincelatesttag: 4 |
|
369 | 504 | $ hg tag -r 2 mytag |
|
370 | 505 | $ hg tag -r 2 anothertag |
|
371 | 506 | $ hg archive -r 2 ../test-lasttag |
|
372 | 507 | $ cat ../test-lasttag/.hg_archival.txt |
|
373 | 508 | repo: daa7f7c60e0a224faa4ff77ca41b2760562af264 |
|
374 | 509 | node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e |
|
375 | 510 | branch: default |
|
376 | 511 | tag: anothertag |
|
377 | 512 | tag: mytag |
|
378 | 513 | |
|
379 | 514 | $ hg archive -t bogus test.bogus |
|
380 | 515 | abort: unknown archive type 'bogus' |
|
381 | 516 | [255] |
|
382 | 517 | |
|
383 | 518 | enable progress extension: |
|
384 | 519 | |
|
385 | 520 | $ cp $HGRCPATH $HGRCPATH.no-progress |
|
386 | 521 | $ cat >> $HGRCPATH <<EOF |
|
387 | 522 | > [progress] |
|
388 | 523 | > assume-tty = 1 |
|
389 | 524 | > format = topic bar number |
|
390 | 525 | > delay = 0 |
|
391 | 526 | > refresh = 0 |
|
392 | 527 | > width = 60 |
|
393 | 528 | > EOF |
|
394 | 529 | |
|
395 | 530 | $ hg archive ../with-progress |
|
396 | 531 | \r (no-eol) (esc) |
|
397 | 532 | archiving [ ] 0/6\r (no-eol) (esc) |
|
398 | 533 | archiving [======> ] 1/6\r (no-eol) (esc) |
|
399 | 534 | archiving [=============> ] 2/6\r (no-eol) (esc) |
|
400 | 535 | archiving [====================> ] 3/6\r (no-eol) (esc) |
|
401 | 536 | archiving [===========================> ] 4/6\r (no-eol) (esc) |
|
402 | 537 | archiving [==================================> ] 5/6\r (no-eol) (esc) |
|
403 | 538 | archiving [==========================================>] 6/6\r (no-eol) (esc) |
|
404 | 539 | \r (no-eol) (esc) |
|
405 | 540 | |
|
406 | 541 | cleanup after progress extension test: |
|
407 | 542 | |
|
408 | 543 | $ cp $HGRCPATH.no-progress $HGRCPATH |
|
409 | 544 | |
|
410 | 545 | server errors |
|
411 | 546 | |
|
412 | 547 | $ cat errors.log |
|
413 | 548 | |
|
414 | 549 | empty repo |
|
415 | 550 | |
|
416 | 551 | $ hg init ../empty |
|
417 | 552 | $ cd ../empty |
|
418 | 553 | $ hg archive ../test-empty |
|
419 | 554 | abort: no working directory: please specify a revision |
|
420 | 555 | [255] |
|
421 | 556 | |
|
422 | 557 | old file -- date clamped to 1980 |
|
423 | 558 | |
|
424 | 559 | $ touch -t 197501010000 old |
|
425 | 560 | $ hg add old |
|
426 | 561 | $ hg commit -m old |
|
427 | 562 | $ hg archive ../old.zip |
|
428 | 563 | $ unzip -l ../old.zip | grep -v -- ----- | egrep -v files$ |
|
429 | 564 | Archive: ../old.zip |
|
430 | 565 | \s*Length.* (re) |
|
431 | 566 | *172*80*00:00*old/.hg_archival.txt (glob) |
|
432 | 567 | *0*80*00:00*old/old (glob) |
|
433 | 568 | |
|
434 | 569 | show an error when a provided pattern matches no files |
|
435 | 570 | |
|
436 | 571 | $ hg archive -I file_that_does_not_exist.foo ../empty.zip |
|
437 | 572 | abort: no files match the archive pattern |
|
438 | 573 | [255] |
|
439 | 574 | |
|
440 | 575 | $ hg archive -X * ../empty.zip |
|
441 | 576 | abort: no files match the archive pattern |
|
442 | 577 | [255] |
|
443 | 578 | |
|
444 | 579 | $ cd .. |
|
445 | 580 | |
|
446 | 581 | issue3600: check whether "hg archive" can create archive files which |
|
447 | 582 | are extracted with expected timestamp, even though TZ is not |
|
448 | 583 | configured as GMT. |
|
449 | 584 | |
|
450 | 585 | $ mkdir issue3600 |
|
451 | 586 | $ cd issue3600 |
|
452 | 587 | |
|
453 | 588 | $ hg init repo |
|
454 | 589 | $ echo a > repo/a |
|
455 | 590 | $ hg -R repo add repo/a |
|
456 | 591 | $ hg -R repo commit -m '#0' -d '456789012 21600' |
|
457 | 592 | $ cat > show_mtime.py <<EOF |
|
458 | 593 | > from __future__ import absolute_import, print_function |
|
459 | 594 | > import os |
|
460 | 595 | > import sys |
|
461 | 596 | > print(int(os.stat(sys.argv[1]).st_mtime)) |
|
462 | 597 | > EOF |
|
463 | 598 | |
|
464 | 599 | $ hg -R repo archive --prefix tar-extracted archive.tar |
|
465 | 600 | $ (TZ=UTC-3; export TZ; tar xf archive.tar) |
|
466 | 601 | $ $PYTHON show_mtime.py tar-extracted/a |
|
467 | 602 | 456789012 |
|
468 | 603 | |
|
469 | 604 | $ hg -R repo archive --prefix zip-extracted archive.zip |
|
470 | 605 | $ (TZ=UTC-3; export TZ; unzip -q archive.zip) |
|
471 | 606 | $ $PYTHON show_mtime.py zip-extracted/a |
|
472 | 607 | 456789012 |
|
473 | 608 | |
|
474 | 609 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now