bundlerepo: don't assume there are only two bundle classes
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 11 Nov 2017 18:14:41 -0800
changeset 35051 4f04c9207a76
parent 35050 d2458ba810c5
child 35052 df2a676a2e9e
bundlerepo: don't assume there are only two bundle classes exchange.readbundle() can return a type that represents a stream clone bundle. Explicitly handle the bundle1 type and raise a reasonable error message for unhandled bundle types. Differential Revision: https://phab.mercurial-scm.org/D1376
mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py	Sat Nov 11 18:09:16 2017 -0800
+++ b/mercurial/bundlerepo.py	Sat Nov 11 18:14:41 2017 -0800
@@ -296,13 +296,16 @@
 
             if not hadchangegroup:
                 raise error.Abort(_("No changegroups found"))
-
-        elif self.bundle.compressed():
-            f = self._writetempbundle(self.bundle.read, '.hg10un',
-                                      header='HG10UN')
-            self.bundlefile = self.bundle = exchange.readbundle(ui, f,
-                                                                bundlepath,
-                                                                self.vfs)
+        elif isinstance(self.bundle, changegroup.cg1unpacker):
+            if self.bundle.compressed():
+                f = self._writetempbundle(self.bundle.read, '.hg10un',
+                                          header='HG10UN')
+                self.bundlefile = self.bundle = exchange.readbundle(ui, f,
+                                                                    bundlepath,
+                                                                    self.vfs)
+        else:
+            raise error.Abort(_('bundle type %s cannot be read') %
+                              type(self.bundle))
 
         # dict with the mapping 'filename' -> position in the bundle
         self.bundlefilespos = {}