D1376: bundlerepo: don't assume there are only two bundle classes

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Nov 11 21:52:07 EST 2017


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundlerepo.py

CHANGE DETAILS

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -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 = {}



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list