1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
|
#require serve no-chg
#testcases stream-legacy stream-bundle2-v2 stream-bundle2-v3
#if stream-legacy
$ cat << EOF >> $HGRCPATH
> [server]
> bundle2.stream = no
> [format]
> # persistent nodemap is too broken with legacy format,
> # however client with nodemap support will have better stream support.
> use-persistent-nodemap=no
> EOF
#endif
#if stream-bundle2-v3
$ cat << EOF >> $HGRCPATH
> [experimental]
> stream-v3 = yes
> EOF
#endif
Initialize repository
$ hg init server
$ cd server
$ sh $TESTDIR/testlib/stream_clone_setup.sh
adding 00changelog-ab349180a0405010.nd
adding 00changelog.d
adding 00changelog.i
adding 00changelog.n
adding 00manifest.d
adding 00manifest.i
adding container/isam-build-centos7/bazel-coverage-generator-sandboxfs-compatibility-0758e3e4f6057904d44399bd666faba9e7f40686.patch
adding data/foo.d
adding data/foo.i
adding data/foo.n
adding data/undo.babar
adding data/undo.d
adding data/undo.foo.d
adding data/undo.foo.i
adding data/undo.foo.n
adding data/undo.i
adding data/undo.n
adding data/undo.py
adding foo.d
adding foo.i
adding foo.n
adding meta/foo.d
adding meta/foo.i
adding meta/foo.n
adding meta/undo.babar
adding meta/undo.d
adding meta/undo.foo.d
adding meta/undo.foo.i
adding meta/undo.foo.n
adding meta/undo.i
adding meta/undo.n
adding meta/undo.py
adding savanah/foo.d
adding savanah/foo.i
adding savanah/foo.n
adding savanah/undo.babar
adding savanah/undo.d
adding savanah/undo.foo.d
adding savanah/undo.foo.i
adding savanah/undo.foo.n
adding savanah/undo.i
adding savanah/undo.n
adding savanah/undo.py
adding store/C\xc3\xa9lesteVille_is_a_Capital_City (esc)
adding store/foo.d
adding store/foo.i
adding store/foo.n
adding store/undo.babar
adding store/undo.d
adding store/undo.foo.d
adding store/undo.foo.i
adding store/undo.foo.n
adding store/undo.i
adding store/undo.n
adding store/undo.py
adding undo.babar
adding undo.d
adding undo.foo.d
adding undo.foo.i
adding undo.foo.n
adding undo.i
adding undo.n
adding undo.py
$ hg --config server.uncompressed=false serve -p $HGPORT -d --pid-file=hg.pid
$ cat hg.pid > $DAEMON_PIDS
$ cd ..
Check local clone
==================
The logic is close enough of uncompressed.
This is present here to reuse the testing around file with "special" names.
$ hg clone server local-clone
updating to branch default
1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
Check that the clone went well
$ hg verify -R local-clone -q
Check uncompressed
==================
Cannot stream clone when server.uncompressed is set to false
------------------------------------------------------------
When `server.uncompressed` is disabled, the client should fallback to a bundle
based clone with a warning.
$ get-with-headers.py $LOCALIP:$HGPORT '?cmd=stream_out'
200 Script output follows
1
$ hg debugcapabilities http://localhost:$HGPORT
Main capabilities:
batch
branchmap
$USUAL_BUNDLE2_CAPS_SERVER$
changegroupsubset
compression=$BUNDLE2_COMPRESSIONS$
getbundle
httpheader=1024
httpmediatype=0.1rx,0.1tx,0.2tx
known
lookup
pushkey
unbundle=HG10GZ,HG10BZ,HG10UN
unbundlehash
Bundle2 capabilities:
HG20
bookmarks
changegroup
01
02
03
checkheads
related
digests
md5
sha1
sha512
error
abort
unsupportedcontent
pushraced
pushkey
hgtagsfnodes
listkeys
phases
heads
pushkey
remote-changegroup
http
https
$ hg clone --stream -U http://localhost:$HGPORT server-disabled
warning: stream clone requested but server has them disabled
requesting all changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 1088 changes to 1088 files
new changesets 96ee1d7354c4:5223b5e3265f
$ killdaemons.py
$ cd server
$ hg serve -p $HGPORT -d --pid-file=hg.pid --error errors.txt
$ cat hg.pid > $DAEMON_PIDS
$ cd ..
Basic clone
-----------
Check that --stream trigger a stream clone and result in a valid repositoty
We check the associated output for exact bytes on file number as changes in
these value implies changes in the data transfered and can detect unintended
changes in the process.
#if stream-legacy
$ hg clone --stream -U http://localhost:$HGPORT clone1
streaming all changes
1091 files to transfer, 102 KB of data (no-zstd !)
stream-cloned 1091 files / 102 KB in * seconds (* */sec) (glob) (no-zstd !)
1091 files to transfer, 98.8 KB of data (zstd !)
stream-cloned 1091 files / 98.8 KB in * seconds (* */sec) (glob) (zstd !)
searching for changes
no changes found
#endif
#if stream-bundle2-v2
$ hg clone --stream -U http://localhost:$HGPORT clone1
streaming all changes
1094 files to transfer, 102 KB of data (no-zstd !)
stream-cloned 1094 files / 102 KB in * seconds (* */sec) (glob) (no-zstd !)
1094 files to transfer, 98.9 KB of data (zstd no-rust !)
stream-cloned 1094 files / 98.9 KB in * seconds (* */sec) (glob) (zstd no-rust !)
1096 files to transfer, 99.0 KB of data (zstd rust !)
stream-cloned 1096 files / 99.0 KB in * seconds (* */sec) (glob) (zstd rust !)
#endif
#if stream-bundle2-v3
$ hg clone --stream -U http://localhost:$HGPORT clone1
streaming all changes
1093 entries to transfer
stream-cloned 1094 files / 102 KB in * seconds (* */sec) (glob) (no-zstd !)
stream-cloned 1094 files / 98.9 KB in * seconds (* */sec) (glob) (zstd no-rust !)
stream-cloned 1096 files / 99.0 KB in * seconds (* */sec) (glob) (zstd rust !)
#endif
#if no-stream-legacy
$ ls -1 clone1/.hg/cache
branch2-base
branch2-served
rbc-names-v2
rbc-revs-v2
tags2
tags2-served
#endif
$ hg -R clone1 verify --quiet
$ cat server/errors.txt
getbundle requests with stream=1 are uncompressed
-------------------------------------------------
We check that `getbundle` will return a stream bundle when requested.
XXX manually building the --requestheader is fragile and will drift away from actual usage
$ get-with-headers.py $LOCALIP:$HGPORT '?cmd=getbundle' content-type --bodyfile body --hgproto '0.1 0.2 comp=zlib,none' --requestheader "x-hgarg-1=bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%252C03%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps%250Astream%253Dv2&cg=0&common=0000000000000000000000000000000000000000&heads=c17445101a72edac06facd130d14808dfbd5c7c2&stream=1"
200 Script output follows
content-type: application/mercurial-0.2
$ f --size --hex --bytes 48 body
body: size=* (glob)
0000: 04 6e 6f 6e 65 48 47 32 30 00 00 00 00 00 00 00 |.noneHG20.......|
0010: ?? 07 53 54 52 45 41 4d 32 00 00 00 00 03 00 09 |?.STREAM2.......| (glob)
0020: 06 09 04 0c ?? 62 79 74 65 63 6f 75 6e 74 31 30 |....?bytecount10| (glob)
--uncompressed is an alias to --stream
---------------------------------------
The alias flag should trigger a stream clone too.
$ hg clone --uncompressed -U http://localhost:$HGPORT clone1-uncompressed
streaming all changes
* files to transfer* (glob) (no-stream-bundle2-v3 !)
* entries to transfer (glob) (stream-bundle2-v3 !)
stream-cloned * files / * KB in * seconds (* */sec) (glob)
searching for changes (stream-legacy !)
no changes found (stream-legacy !)
Clone with background file closing enabled
-------------------------------------------
The backgound file closing logic should trigger when configured to do so, and
the result should be a valid repository.
$ hg --debug --config worker.backgroundclose=true --config worker.backgroundcloseminfilecount=1 clone --stream -U http://localhost:$HGPORT clone-background | grep "background file closing"
starting 4 threads for background file closing
starting 4 threads for background file closing (no-stream-legacy !)
$ hg verify -R clone-background --quiet
Cannot stream clone when there are secret changesets
----------------------------------------------------
If secret changeset are present the should not be cloned (by default) and the
clone falls back to a bundle clone.
$ hg -R server phase --force --secret -r tip
$ hg clone --stream -U http://localhost:$HGPORT secret-denied
warning: stream clone requested but server has them disabled
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 1025 changes to 1025 files
new changesets 96ee1d7354c4:c17445101a72
$ killdaemons.py
Streaming of secrets can be overridden by server config
-------------------------------------------------------
Secret changeset can still be streamed if the server is configured to do so.
$ cd server
$ hg serve --config server.uncompressedallowsecret=true -p $HGPORT -d --pid-file=hg.pid
$ cat hg.pid > $DAEMON_PIDS
$ cd ..
$ hg clone --stream -U http://localhost:$HGPORT secret-allowed
streaming all changes
* files to transfer* (glob) (no-stream-bundle2-v3 !)
* entries to transfer (glob) (stream-bundle2-v3 !)
stream-cloned * files / * KB in * seconds (* */sec) (glob)
searching for changes (stream-legacy !)
no changes found (stream-legacy !)
$ killdaemons.py
Verify interaction between preferuncompressed and secret presence
-----------------------------------------------------------------
Secret presence will still make the clone falls back to a normal bundle even if
the server prefers stream clone.
$ cd server
$ hg serve --config server.preferuncompressed=true -p $HGPORT -d --pid-file=hg.pid
$ cat hg.pid > $DAEMON_PIDS
$ cd ..
$ hg clone -U http://localhost:$HGPORT preferuncompressed-secret
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 1025 changes to 1025 files
new changesets 96ee1d7354c4:c17445101a72
$ killdaemons.py
Clone not allowed when full bundles disabled and can't serve secrets
--------------------------------------------------------------------
The clone should fail as no valid option is found.
$ cd server
$ hg serve --config server.disablefullbundle=true -p $HGPORT -d --pid-file=hg.pid
$ cat hg.pid > $DAEMON_PIDS
$ cd ..
$ hg clone --stream http://localhost:$HGPORT secret-full-disabled
warning: stream clone requested but server has them disabled
requesting all changes
remote: abort: server has pull-based clones disabled
abort: pull failed on remote
(remove --pull if specified or upgrade Mercurial)
[100]
Local stream clone with secrets involved
----------------------------------------
(This is just a test over behavior: if you have access to the repo's files,
there is no security so it isn't important to prevent a clone here.)
$ hg clone -U --stream server local-secret
warning: stream clone requested but server has them disabled
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 1025 changes to 1025 files
new changesets 96ee1d7354c4:c17445101a72
(revert introduction of secret changeset)
$ hg -R server phase --draft 'secret()'
Stream clone while repo is changing:
------------------------------------
We should send a repository in a valid state, ignoring the ongoing transaction.
$ mkdir changing
$ cd changing
prepare repo with small and big file to cover both code paths in emitrevlogdata
(inlined revlog and non-inlined revlogs).
$ hg init repo
$ touch repo/f1
$ $TESTDIR/seq.py 50000 > repo/f2
$ hg -R repo ci -Aqm "0"
$ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1"
$ export HG_TEST_STREAM_WALKED_FILE_1
$ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2"
$ export HG_TEST_STREAM_WALKED_FILE_2
$ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3"
$ export HG_TEST_STREAM_WALKED_FILE_3
$ HG_TEST_STREAM_WALKED_FILE_4="$TESTTMP/sync_file_walked_4"
$ export HG_TEST_STREAM_WALKED_FILE_4
$ HG_TEST_STREAM_WALKED_FILE_5="$TESTTMP/sync_file_walked_5"
$ export HG_TEST_STREAM_WALKED_FILE_5
# $ cat << EOF >> $HGRCPATH
# > [hooks]
# > pre-clone=rm -f "$TESTTMP/sync_file_walked_*"
# > EOF
$ hg serve -R repo -p $HGPORT1 -d --error errors.log --pid-file=hg.pid --config extensions.stream_steps="$RUNTESTDIR/testlib/ext-stream-clone-steps.py"
$ cat hg.pid >> $DAEMON_PIDS
clone while modifying the repo between stating file with write lock and
actually serving file content
also delete some cache in the process
$ (hg clone -q --stream -U http://localhost:$HGPORT1 clone; touch "$HG_TEST_STREAM_WALKED_FILE_5") &
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1
(delete one file)
$ ls repo/.hg/cache/rbc-revs-v2
repo/.hg/cache/rbc-revs-v2
$ rm repo/.hg/cache/rbc-revs-v2
(truncate another)
$ ls repo/.hg/cache/rbc-names-v2
repo/.hg/cache/rbc-names-v2
$ echo football > repo/.hg/cache/rbc-names-v2
(lenghten another one)
$ ls repo/.hg/cache/branch2-served
repo/.hg/cache/branch2-served
$ echo bar >> repo/.hg/cache/branch2-served
(remove one in wcache))
$ ls repo/.hg/wcache/manifestfulltextcache
repo/.hg/wcache/manifestfulltextcache
$ rm repo/.hg/wcache/manifestfulltextcache
$ touch $HG_TEST_STREAM_WALKED_FILE_2
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3
$ echo >> repo/f1
$ echo >> repo/f2
$ hg -R repo ci -m "1" --config ui.timeout.warn=-1
(truncate further)
$ ls repo/.hg/cache/rbc-names-v2
repo/.hg/cache/rbc-names-v2
$ echo foo > repo/.hg/cache/rbc-names-v2
(lenghten another one)
$ ls repo/.hg/cache/branch2-served
repo/.hg/cache/branch2-served
$ echo babar >> repo/.hg/cache/branch2-served
$ touch $HG_TEST_STREAM_WALKED_FILE_4
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_5
$ hg -R clone id
000000000000
$ hg -R clone verify --quiet
$ cat errors.log
$ cd ..
Stream repository with bookmarks
--------------------------------
The bookmark file should be send over in the stream bundle.
add a bookmark
$ hg -R server bookmark -r tip some-bookmark
clone it
$ hg clone --stream http://localhost:$HGPORT with-bookmarks
streaming all changes
1091 files to transfer, * KB of data (glob) (stream-legacy !)
1097 files to transfer, * KB of data (glob) (stream-bundle2-v2 no-rust !)
1099 files to transfer, * KB of data (glob) (stream-bundle2-v2 rust !)
1096 entries to transfer (stream-bundle2-v3 !)
stream-cloned * files / * KB in * seconds (* */sec) (glob)
searching for changes (stream-legacy !)
no changes found (stream-legacy !)
updating to branch default
1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg verify -R with-bookmarks -q
$ hg -R with-bookmarks bookmarks
some-bookmark 2:5223b5e3265f
Stream repository with phases
-----------------------------
The file storing phases information (e.g. phaseroots) should be sent as part of
the stream bundle.
Clone as publishing
$ hg -R server phase -r 'all()'
0: draft
1: draft
2: draft
$ hg clone --stream http://localhost:$HGPORT phase-publish
streaming all changes
1091 files to transfer, * KB of data (glob) (stream-legacy !)
1097 files to transfer, * KB of data (glob) (stream-bundle2-v2 no-rust !)
1099 files to transfer, * KB of data (glob) (stream-bundle2-v2 rust !)
1096 entries to transfer (stream-bundle2-v3 !)
stream-cloned * files * KB in * seconds (* */sec) (glob)
searching for changes (stream-legacy !)
no changes found (stream-legacy !)
updating to branch default
1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg verify -R phase-publish -q
$ hg -R phase-publish phase -r 'all()'
0: public
1: public
2: public
Clone as non publishing
$ cat << EOF >> server/.hg/hgrc
> [phases]
> publish = False
> EOF
$ killdaemons.py
$ hg -R server serve -p $HGPORT -d --pid-file=hg.pid
$ cat hg.pid > $DAEMON_PIDS
$ hg clone --stream http://localhost:$HGPORT phase-no-publish
streaming all changes
* files to transfer, * KB of data (glob) (no-stream-bundle2-v3 !)
* entries to transfer (glob) (stream-bundle2-v3 !)
stream-cloned * / * KB in * seconds (* */sec) (glob)
searching for changes (stream-legacy !)
no changes found (stream-legacy !)
updating to branch default
1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
Note: With v1 of the stream protocol, changeset are always cloned as public. It
make stream v1 unsuitable for non-publishing repository.
$ hg -R phase-no-publish phase -r 'all()'
0: public (stream-legacy !)
1: public (stream-legacy !)
2: public (stream-legacy !)
0: draft (no-stream-legacy !)
1: draft (no-stream-legacy !)
2: draft (no-stream-legacy !)
$ hg verify -R phase-no-publish -q
$ killdaemons.py
Stream repository with obsolescence
-----------------------------------
#if stream-legacy
With v1 of the stream protocol, changeset are always cloned as public. There's
no obsolescence markers exchange in stream v1.
#else
Clone non-publishing with obsolescence
The obsstore file should be send as part of the stream bundle
$ cat >> $HGRCPATH << EOF
> [experimental]
> evolution=all
> EOF
$ cd server
$ echo foo > foo
$ hg -q commit -m 'about to be pruned'
$ hg debugobsolete `hg log -r . -T '{node}'` -d '0 0' -u test --record-parents
1 new obsolescence markers
obsoleted 1 changesets
$ hg up null -q
$ hg log -T '{rev}: {phase}\n'
2: draft
1: draft
0: draft
$ hg serve -p $HGPORT -d --pid-file=hg.pid
$ cat hg.pid > $DAEMON_PIDS
$ cd ..
$ hg clone -U --stream http://localhost:$HGPORT with-obsolescence
streaming all changes
1099 files to transfer, * KB of data (glob) (stream-bundle2-v2 no-rust !)
1101 files to transfer, * KB of data (glob) (stream-bundle2-v2 rust !)
1098 entries to transfer (no-stream-bundle2-v2 !)
stream-cloned * files / * KB in * seconds (* */sec) (glob)
$ hg -R with-obsolescence log -T '{rev}: {phase}\n'
2: draft
1: draft
0: draft
$ hg debugobsolete -R with-obsolescence
8c206a663911c1f97f2f9d7382e417ae55872cfa 0 {5223b5e3265f0df40bb743da62249413d74ac70f} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
$ hg verify -R with-obsolescence -q
$ hg clone -U --stream --config experimental.evolution=0 http://localhost:$HGPORT with-obsolescence-no-evolution
streaming all changes
remote: abort: server has obsolescence markers, but client cannot receive them via stream clone
abort: pull failed on remote
[100]
$ killdaemons.py
#endif
Cloning a repo with no requirements doesn't give some obscure error
-------------------------------------------------------------------
$ mkdir -p empty-repo/.hg
$ hg clone -q --stream ssh://user@dummy/empty-repo empty-repo2
$ hg --cwd empty-repo2 verify -q
Cloning a repo with an empty manifestlog doesn't give some weird error
----------------------------------------------------------------------
$ rm -r empty-repo; hg init empty-repo
$ (cd empty-repo; touch x; hg commit -Am empty; hg debugstrip -r 0) > /dev/null
$ hg clone -q --stream ssh://user@dummy/empty-repo empty-repo3
$ hg --cwd empty-repo3 verify -q
Compression requirements are preserved across a stream clone
------------------------------------------------------------
$ hg init zlib-repo --config format.revlog-compression=zlib
$ hg clone -q --stream ssh://user@dummy/zlib-repo zlib-clone
$ hg -R zlib-repo/ debugrequires | grep compression
[1]
$ hg -R zlib-clone debugrequires | grep compression
[1]
#if zstd
$ hg init zstd-repo --config format.revlog-compression=zstd
$ hg clone -q --stream ssh://user@dummy/zstd-repo zstd-clone
$ hg -R zstd-repo debugrequires | grep compression
revlog-compression-zstd
$ hg -R zstd-clone debugrequires | grep compression
revlog-compression-zstd
#endif
|