Show More
@@ -0,0 +1,31 b'' | |||||
|
1 | from __future__ import absolute_import | |||
|
2 | ||||
|
3 | from mercurial import ( | |||
|
4 | encoding, | |||
|
5 | extensions, | |||
|
6 | streamclone, | |||
|
7 | testing, | |||
|
8 | ) | |||
|
9 | ||||
|
10 | ||||
|
11 | WALKED_FILE_1 = encoding.environ[b'HG_TEST_STREAM_WALKED_FILE_1'] | |||
|
12 | WALKED_FILE_2 = encoding.environ[b'HG_TEST_STREAM_WALKED_FILE_2'] | |||
|
13 | ||||
|
14 | ||||
|
15 | def _test_sync_point_walk_1(orig, repo): | |||
|
16 | testing.write_file(WALKED_FILE_1) | |||
|
17 | ||||
|
18 | ||||
|
19 | def _test_sync_point_walk_2(orig, repo): | |||
|
20 | assert repo._currentlock(repo._lockref) is None | |||
|
21 | testing.wait_file(WALKED_FILE_2) | |||
|
22 | ||||
|
23 | ||||
|
24 | def uisetup(ui): | |||
|
25 | extensions.wrapfunction( | |||
|
26 | streamclone, '_test_sync_point_walk_1', _test_sync_point_walk_1 | |||
|
27 | ) | |||
|
28 | ||||
|
29 | extensions.wrapfunction( | |||
|
30 | streamclone, '_test_sync_point_walk_2', _test_sync_point_walk_2 | |||
|
31 | ) |
@@ -247,6 +247,8 b' def generatev1(repo):' | |||||
247 | if size: |
|
247 | if size: | |
248 | entries.append((name, size)) |
|
248 | entries.append((name, size)) | |
249 | total_bytes += size |
|
249 | total_bytes += size | |
|
250 | _test_sync_point_walk_1(repo) | |||
|
251 | _test_sync_point_walk_2(repo) | |||
250 |
|
252 | |||
251 | repo.ui.debug( |
|
253 | repo.ui.debug( | |
252 | b'%d files, %d bytes to transfer\n' % (len(entries), total_bytes) |
|
254 | b'%d files, %d bytes to transfer\n' % (len(entries), total_bytes) | |
@@ -593,6 +595,14 b' def _emit2(repo, entries, totalfilesize)' | |||||
593 | fp.close() |
|
595 | fp.close() | |
594 |
|
596 | |||
595 |
|
597 | |||
|
598 | def _test_sync_point_walk_1(repo): | |||
|
599 | """a function for synchronisation during tests""" | |||
|
600 | ||||
|
601 | ||||
|
602 | def _test_sync_point_walk_2(repo): | |||
|
603 | """a function for synchronisation during tests""" | |||
|
604 | ||||
|
605 | ||||
596 | def generatev2(repo, includes, excludes, includeobsmarkers): |
|
606 | def generatev2(repo, includes, excludes, includeobsmarkers): | |
597 | """Emit content for version 2 of a streaming clone. |
|
607 | """Emit content for version 2 of a streaming clone. | |
598 |
|
608 | |||
@@ -635,6 +645,8 b' def generatev2(repo, includes, excludes,' | |||||
635 | chunks = _emit2(repo, entries, totalfilesize) |
|
645 | chunks = _emit2(repo, entries, totalfilesize) | |
636 | first = next(chunks) |
|
646 | first = next(chunks) | |
637 | assert first is None |
|
647 | assert first is None | |
|
648 | _test_sync_point_walk_1(repo) | |||
|
649 | _test_sync_point_walk_2(repo) | |||
638 |
|
650 | |||
639 | return len(entries), totalfilesize, chunks |
|
651 | return len(entries), totalfilesize, chunks | |
640 |
|
652 |
@@ -433,14 +433,35 b' Stream clone while repo is changing:' | |||||
433 | extension for delaying the server process so we reliably can modify the repo |
|
433 | extension for delaying the server process so we reliably can modify the repo | |
434 | while cloning |
|
434 | while cloning | |
435 |
|
435 | |||
436 |
$ cat > |
|
436 | $ cat > stream_steps.py <<EOF | |
437 |
> import |
|
437 | > import os | |
438 | > from mercurial import extensions, vfs |
|
438 | > import sys | |
439 | > def __call__(orig, self, path, *args, **kwargs): |
|
439 | > from mercurial import ( | |
440 | > if path == 'data/f1.i': |
|
440 | > encoding, | |
441 | > time.sleep(2) |
|
441 | > extensions, | |
442 | > return orig(self, path, *args, **kwargs) |
|
442 | > streamclone, | |
443 | > extensions.wrapfunction(vfs.vfs, '__call__', __call__) |
|
443 | > testing, | |
|
444 | > ) | |||
|
445 | > WALKED_FILE_1 = encoding.environ[b'HG_TEST_STREAM_WALKED_FILE_1'] | |||
|
446 | > WALKED_FILE_2 = encoding.environ[b'HG_TEST_STREAM_WALKED_FILE_2'] | |||
|
447 | > | |||
|
448 | > def _test_sync_point_walk_1(orig, repo): | |||
|
449 | > testing.write_file(WALKED_FILE_1) | |||
|
450 | > | |||
|
451 | > def _test_sync_point_walk_2(orig, repo): | |||
|
452 | > assert repo._currentlock(repo._lockref) is None | |||
|
453 | > testing.wait_file(WALKED_FILE_2) | |||
|
454 | > | |||
|
455 | > extensions.wrapfunction( | |||
|
456 | > streamclone, | |||
|
457 | > '_test_sync_point_walk_1', | |||
|
458 | > _test_sync_point_walk_1 | |||
|
459 | > ) | |||
|
460 | > extensions.wrapfunction( | |||
|
461 | > streamclone, | |||
|
462 | > '_test_sync_point_walk_2', | |||
|
463 | > _test_sync_point_walk_2 | |||
|
464 | > ) | |||
444 | > EOF |
|
465 | > EOF | |
445 |
|
466 | |||
446 | prepare repo with small and big file to cover both code paths in emitrevlogdata |
|
467 | prepare repo with small and big file to cover both code paths in emitrevlogdata | |
@@ -449,20 +470,32 b' prepare repo with small and big file to ' | |||||
449 | $ touch repo/f1 |
|
470 | $ touch repo/f1 | |
450 | $ $TESTDIR/seq.py 50000 > repo/f2 |
|
471 | $ $TESTDIR/seq.py 50000 > repo/f2 | |
451 | $ hg -R repo ci -Aqm "0" |
|
472 | $ hg -R repo ci -Aqm "0" | |
452 | $ hg serve -R repo -p $HGPORT1 -d --pid-file=hg.pid --config extensions.delayer=delayer.py |
|
473 | $ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1" | |
|
474 | $ export HG_TEST_STREAM_WALKED_FILE_1 | |||
|
475 | $ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2" | |||
|
476 | $ export HG_TEST_STREAM_WALKED_FILE_2 | |||
|
477 | $ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3" | |||
|
478 | $ export HG_TEST_STREAM_WALKED_FILE_3 | |||
|
479 | # $ cat << EOF >> $HGRCPATH | |||
|
480 | # > [hooks] | |||
|
481 | # > pre-clone=rm -f "$TESTTMP/sync_file_walked_*" | |||
|
482 | # > EOF | |||
|
483 | $ 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" | |||
453 | $ cat hg.pid >> $DAEMON_PIDS |
|
484 | $ cat hg.pid >> $DAEMON_PIDS | |
454 |
|
485 | |||
455 | clone while modifying the repo between stating file with write lock and |
|
486 | clone while modifying the repo between stating file with write lock and | |
456 | actually serving file content |
|
487 | actually serving file content | |
457 |
|
488 | |||
458 | $ hg clone -q --stream -U http://localhost:$HGPORT1 clone & |
|
489 | $ (hg clone -q --stream -U http://localhost:$HGPORT1 clone; touch "$HG_TEST_STREAM_WALKED_FILE_3") & | |
459 | $ sleep 1 |
|
490 | $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1 | |
460 | $ echo >> repo/f1 |
|
491 | $ echo >> repo/f1 | |
461 | $ echo >> repo/f2 |
|
492 | $ echo >> repo/f2 | |
462 | $ hg -R repo ci -m "1" --config ui.timeout.warn=-1 |
|
493 | $ hg -R repo ci -m "1" --config ui.timeout.warn=-1 | |
463 | $ wait |
|
494 | $ touch $HG_TEST_STREAM_WALKED_FILE_2 | |
|
495 | $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3 | |||
464 | $ hg -R clone id |
|
496 | $ hg -R clone id | |
465 | 000000000000 |
|
497 | 000000000000 | |
|
498 | $ cat errors.log | |||
466 | $ cd .. |
|
499 | $ cd .. | |
467 |
|
500 | |||
468 | Stream repository with bookmarks |
|
501 | Stream repository with bookmarks |
General Comments 0
You need to be logged in to leave comments.
Login now