##// END OF EJS Templates
streamingclone: extract the scanning part from the generation part...
marmoute -
r48237:2f4ca480 default
parent child Browse files
Show More
@@ -603,21 +603,19 def _test_sync_point_walk_2(repo):
603 """a function for synchronisation during tests"""
603 """a function for synchronisation during tests"""
604
604
605
605
606 def generatev2(repo, includes, excludes, includeobsmarkers):
606 def _v2_walk(repo, includes, excludes, includeobsmarkers):
607 """Emit content for version 2 of a streaming clone.
607 """emit a seris of files information useful to clone a repo
608
609 return (entries, totalfilesize)
610
611 entries is a list of tuple (vfs-key, file-path, file-type, size)
608
612
609 the data stream consists the following entries:
613 - `vfs-key`: is a key to the right vfs to write the file (see _makemap)
610 1) A char representing the file destination (eg: store or cache)
614 - `name`: file path of the file to copy (to be feed to the vfss)
611 2) A varint containing the length of the filename
615 - `file-type`: do this file need to be copied with the source lock ?
612 3) A varint containing the length of file data
616 - `size`: the size of the file (or None)
613 4) N bytes containing the filename (the internal, store-agnostic form)
614 5) N bytes containing the file data
615
616 Returns a 3-tuple of (file count, file size, data iterator).
617 """
617 """
618
618 assert repo._currentlock(repo._lockref) is not None
619 with repo.lock():
620
621 entries = []
619 entries = []
622 totalfilesize = 0
620 totalfilesize = 0
623
621
@@ -625,7 +623,6 def generatev2(repo, includes, excludes,
625 if includes or excludes:
623 if includes or excludes:
626 matcher = narrowspec.match(repo.root, includes, excludes)
624 matcher = narrowspec.match(repo.root, includes, excludes)
627
625
628 repo.ui.debug(b'scanning\n')
629 for rl_type, name, ename, size in _walkstreamfiles(repo, matcher):
626 for rl_type, name, ename, size in _walkstreamfiles(repo, matcher):
630 if size:
627 if size:
631 ft = _fileappend
628 ft = _fileappend
@@ -644,6 +641,32 def generatev2(repo, includes, excludes,
644 if repo.cachevfs.exists(name):
641 if repo.cachevfs.exists(name):
645 totalfilesize += repo.cachevfs.lstat(name).st_size
642 totalfilesize += repo.cachevfs.lstat(name).st_size
646 entries.append((_srccache, name, _filefull, None))
643 entries.append((_srccache, name, _filefull, None))
644 return entries, totalfilesize
645
646
647 def generatev2(repo, includes, excludes, includeobsmarkers):
648 """Emit content for version 2 of a streaming clone.
649
650 the data stream consists the following entries:
651 1) A char representing the file destination (eg: store or cache)
652 2) A varint containing the length of the filename
653 3) A varint containing the length of file data
654 4) N bytes containing the filename (the internal, store-agnostic form)
655 5) N bytes containing the file data
656
657 Returns a 3-tuple of (file count, file size, data iterator).
658 """
659
660 with repo.lock():
661
662 repo.ui.debug(b'scanning\n')
663
664 entries, totalfilesize = _v2_walk(
665 repo,
666 includes=includes,
667 excludes=excludes,
668 includeobsmarkers=includeobsmarkers,
669 )
647
670
648 chunks = _emit2(repo, entries, totalfilesize)
671 chunks = _emit2(repo, entries, totalfilesize)
649 first = next(chunks)
672 first = next(chunks)
General Comments 0
You need to be logged in to leave comments. Login now