# HG changeset patch # User Pierre-Yves David # Date 2022-01-14 17:02:25 # Node ID 8475a136490995b323677b05c22e594691e53624 # Parent 739f2ca3aa3f839ca77d264bf685628f055dde0b 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 diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -47,6 +47,15 @@ def new_stream_clone_requirements( 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 @@ def generatebundlev1(repo, compression=b 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(): diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py --- a/mercurial/wireprotov1server.py +++ b/mercurial/wireprotov1server.py @@ -300,7 +300,7 @@ def _capabilities(repo, proto): 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')