clonebundles: move the manifest reading in a dedicated function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 26 May 2023 16:55:52 +0200
changeset 50544 e6948aafda6f
parent 50540 9db197c73138
child 50545 dc201a09e82c
clonebundles: move the manifest reading in a dedicated function We are about to make the logic more advanced to help hosting solution, so we need to centralize it first.
mercurial/bundlecaches.py
mercurial/localrepo.py
mercurial/wireprotov1server.py
--- a/mercurial/bundlecaches.py	Mon May 29 17:04:14 2023 +0100
+++ b/mercurial/bundlecaches.py	Fri May 26 16:55:52 2023 +0200
@@ -25,6 +25,9 @@
 
 CB_MANIFEST_FILE = b'clonebundles.manifest'
 
+def get_manifest(repo):
+    return repo.vfs.tryread(CB_MANIFEST_FILE)
+
 
 @attr.s
 class bundlespec:
--- a/mercurial/localrepo.py	Mon May 29 17:04:14 2023 +0100
+++ b/mercurial/localrepo.py	Fri May 26 16:55:52 2023 +0200
@@ -349,7 +349,7 @@
         return self._caps
 
     def clonebundles(self):
-        return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
+        return bundlecaches.get_manifest(self._repo)
 
     def debugwireargs(self, one, two, three=None, four=None, five=None):
         """Used to test argument passing over the wire"""
--- a/mercurial/wireprotov1server.py	Mon May 29 17:04:14 2023 +0100
+++ b/mercurial/wireprotov1server.py	Fri May 26 16:55:52 2023 +0200
@@ -274,9 +274,8 @@
     depending on the request. e.g. you could advertise URLs for the closest
     data center given the client's IP address.
     """
-    return wireprototypes.bytesresponse(
-        repo.vfs.tryread(bundlecaches.CB_MANIFEST_FILE)
-    )
+    manifest = bundlecaches.get_manifest(repo)
+    return wireprototypes.bytesresponse(manifest)
 
 
 wireprotocaps = [