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