changeset 50197:c493cb859158

bundlerepo: move the handling of bundl1 in its own method This should make the overall flow simpler to follow.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Feb 2023 19:04:44 +0100
parents 2a7e8471782c
children a6a8946d5173
files mercurial/bundlerepo.py
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Thu Feb 23 19:02:01 2023 +0100
+++ b/mercurial/bundlerepo.py	Thu Feb 23 19:04:44 2023 +0100
@@ -318,14 +318,7 @@
             cgpart.seek(0, os.SEEK_SET)
 
         elif isinstance(bundle, changegroup.cg1unpacker):
-            if bundle.compressed():
-                f = self._writetempbundle(
-                    bundle.read, b'.hg10un', header=b'HG10UN'
-                )
-                bundle = exchange.readbundle(self.ui, f, bundlepath, self.vfs)
-
-            self._bundlefile = bundle
-            self._cgunpacker = bundle
+            self._handle_bundle1(bundle, bundlepath)
         else:
             raise error.Abort(
                 _(b'bundle type %s cannot be read') % type(bundle)
@@ -342,6 +335,14 @@
             [ctx.node() for ctx in self[self.firstnewrev :]],
         )
 
+    def _handle_bundle1(self, bundle, bundlepath):
+        if bundle.compressed():
+            f = self._writetempbundle(bundle.read, b'.hg10un', header=b'HG10UN')
+            bundle = exchange.readbundle(self.ui, f, bundlepath, self.vfs)
+
+        self._bundlefile = bundle
+        self._cgunpacker = bundle
+
     def _handle_bundle2_cg_part(self, bundle, part):
         assert part.type == b'changegroup'
         cgstream = part