[Request] [+- ] D12027: stream-clone: factor computation of new clone requirement out

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon Jan 24 11:34:58 UTC 2022


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This gather code duplicated in multiple place and will make it easier to modify
  it safely in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12027

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
@@ -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



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/20220124/ca76e426/attachment.html>


More information about the Mercurial-patches mailing list