bundlerepo: move the handling of bundl1 in its own method
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 23 Feb 2023 19:04:44 +0100
changeset 50197 c493cb859158
parent 50196 2a7e8471782c
child 50198 a6a8946d5173
bundlerepo: move the handling of bundl1 in its own method This should make the overall flow simpler to follow.
mercurial/bundlerepo.py
--- 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