Mercurial > hg
changeset 48596:739f2ca3aa3f
stream-clone: factor computation of new clone requirement out
This gather code duplicated in multiple place and will make it easier to modify
it safely in the future.
Differential Revision: https://phab.mercurial-scm.org/D12027
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 14 Jan 2022 17:57:49 +0100 |
parents | 6a68350ec2ef |
children | 8475a1364909 |
files | mercurial/streamclone.py |
diffstat | 1 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/streamclone.py Tue Jan 18 00:07:43 2022 +0100 +++ b/mercurial/streamclone.py Fri Jan 14 17:57:49 2022 +0100 @@ -32,6 +32,21 @@ ) +def new_stream_clone_requirements( + supported_formats, default_requirements, streamed_requirements +): + """determine the final set of requirement for a new stream clone + + this method combine the "default" requirements that a new repository would + use with the constaint we get from the stream clone content. We keep local + configuration choice when possible. + """ + requirements = set(default_requirements) + requirements -= supported_formats + requirements.update(streamed_requirements) + return requirements + + def canperformstreamclone(pullop, bundle2=False): """Whether it is possible to perform a streaming clone as part of pull. @@ -184,12 +199,10 @@ with repo.lock(): consumev1(repo, fp, filecount, bytecount) - - # new requirements = old non-format requirements + - # new format-related remote requirements - # requirements from the streamed-in repository - repo.requirements = requirements | ( - repo.requirements - repo.supportedformats + repo.requirements = new_stream_clone_requirements( + repo.supportedformats, + repo.requirements, + requirements, ) repo.svfs.options = localrepo.resolvestorevfsoptions( repo.ui, repo.requirements, repo.features @@ -797,11 +810,10 @@ consumev2(repo, fp, filecount, filesize) - # new requirements = old non-format requirements + - # new format-related remote requirements - # requirements from the streamed-in repository - repo.requirements = set(requirements) | ( - repo.requirements - repo.supportedformats + repo.requirements = new_stream_clone_requirements( + repo.supportedformats, + repo.requirements, + requirements, ) repo.svfs.options = localrepo.resolvestorevfsoptions( repo.ui, repo.requirements, repo.features