[Request] [+-- ] D10852: streamingclone: extract the scanning part from the generation part
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Jun 9 14:39:01 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
We will reuse the scanning part for local clone, so we need it in a dedicated
function.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10852
AFFECTED FILES
mercurial/streamclone.py
CHANGE DETAILS
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -603,6 +603,47 @@
"""a function for synchronisation during tests"""
+def _v2_walk(repo, includes, excludes, includeobsmarkers):
+ """emit a seris of files information useful to clone a repo
+
+ return (entries, totalfilesize)
+
+ entries is a list of tuple (vfs-key, file-path, file-type, size)
+
+ - `vfs-key`: is a key to the right vfs to write the file (see _makemap)
+ - `name`: file path of the file to copy (to be feed to the vfss)
+ - `file-type`: do this file need to be copied with the source lock ?
+ - `size`: the size of the file (or None)
+ """
+ assert repo._currentlock(repo._lockref) is not None
+ entries = []
+ totalfilesize = 0
+
+ matcher = None
+ if includes or excludes:
+ matcher = narrowspec.match(repo.root, includes, excludes)
+
+ for rl_type, name, ename, size in _walkstreamfiles(repo, matcher):
+ if size:
+ ft = _fileappend
+ if rl_type & store.FILEFLAGS_VOLATILE:
+ ft = _filefull
+ entries.append((_srcstore, name, ft, size))
+ totalfilesize += size
+ for name in _walkstreamfullstorefiles(repo):
+ if repo.svfs.exists(name):
+ totalfilesize += repo.svfs.lstat(name).st_size
+ entries.append((_srcstore, name, _filefull, None))
+ if includeobsmarkers and repo.svfs.exists(b'obsstore'):
+ totalfilesize += repo.svfs.lstat(b'obsstore').st_size
+ entries.append((_srcstore, b'obsstore', _filefull, None))
+ for name in cacheutil.cachetocopy(repo):
+ if repo.cachevfs.exists(name):
+ totalfilesize += repo.cachevfs.lstat(name).st_size
+ entries.append((_srccache, name, _filefull, None))
+ return entries, totalfilesize
+
+
def generatev2(repo, includes, excludes, includeobsmarkers):
"""Emit content for version 2 of a streaming clone.
@@ -618,32 +659,14 @@
with repo.lock():
- entries = []
- totalfilesize = 0
-
- matcher = None
- if includes or excludes:
- matcher = narrowspec.match(repo.root, includes, excludes)
+ repo.ui.debug(b'scanning\n')
- repo.ui.debug(b'scanning\n')
- for rl_type, name, ename, size in _walkstreamfiles(repo, matcher):
- if size:
- ft = _fileappend
- if rl_type & store.FILEFLAGS_VOLATILE:
- ft = _filefull
- entries.append((_srcstore, name, ft, size))
- totalfilesize += size
- for name in _walkstreamfullstorefiles(repo):
- if repo.svfs.exists(name):
- totalfilesize += repo.svfs.lstat(name).st_size
- entries.append((_srcstore, name, _filefull, None))
- if includeobsmarkers and repo.svfs.exists(b'obsstore'):
- totalfilesize += repo.svfs.lstat(b'obsstore').st_size
- entries.append((_srcstore, b'obsstore', _filefull, None))
- for name in cacheutil.cachetocopy(repo):
- if repo.cachevfs.exists(name):
- totalfilesize += repo.cachevfs.lstat(name).st_size
- entries.append((_srccache, name, _filefull, None))
+ entries, totalfilesize = _v2_walk(
+ repo,
+ includes=includes,
+ excludes=excludes,
+ includeobsmarkers=includeobsmarkers,
+ )
chunks = _emit2(repo, entries, totalfilesize)
first = next(chunks)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210609/ab82d94a/attachment-0001.html>
More information about the Mercurial-patches
mailing list