Mercurial > hg-stable
changeset 48619:8475a1364909
stream-clone: factor computation of requirement of a stream clone
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/D12028
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 14 Jan 2022 18:02:25 +0100 |
parents | 739f2ca3aa3f |
children | a6f16ec07ed7 |
files | mercurial/streamclone.py mercurial/wireprotov1server.py |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/streamclone.py Fri Jan 14 17:57:49 2022 +0100 +++ b/mercurial/streamclone.py Fri Jan 14 18:02:25 2022 +0100 @@ -47,6 +47,15 @@ return requirements +def streamed_requirements(repo): + """the set of requirement the new clone will have to support + + This is used for advertising the stream options and to generate the actual + stream content.""" + requiredformats = repo.requirements & repo.supportedformats + return requiredformats + + def canperformstreamclone(pullop, bundle2=False): """Whether it is possible to perform a streaming clone as part of pull. @@ -346,7 +355,7 @@ if compression != b'UN': raise ValueError(b'we do not support the compression argument yet') - requirements = repo.requirements & repo.supportedformats + requirements = streamed_requirements(repo) requires = b','.join(sorted(requirements)) def gen():
--- a/mercurial/wireprotov1server.py Fri Jan 14 17:57:49 2022 +0100 +++ b/mercurial/wireprotov1server.py Fri Jan 14 18:02:25 2022 +0100 @@ -300,7 +300,7 @@ if streamclone.allowservergeneration(repo): if repo.ui.configbool(b'server', b'preferuncompressed'): caps.append(b'stream-preferred') - requiredformats = repo.requirements & repo.supportedformats + requiredformats = streamclone.streamed_requirements(repo) # if our local revlogs are just revlogv1, add 'stream' cap if not requiredformats - {requirementsmod.REVLOGV1_REQUIREMENT}: caps.append(b'stream')