add support for HG10GZ bundles to bundlerepo.bundlerevlog()
authorBenoit Allard <benoit@aeteurope.nl>
Thu, 24 Apr 2008 11:48:07 +0200
changeset 6569 c15bfe9cdcd6
parent 6568 0c4c804c8261
child 6570 626cb86a6523
add support for HG10GZ bundles to bundlerepo.bundlerevlog()
mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py	Thu Apr 24 11:43:54 2008 +0200
+++ b/mercurial/bundlerepo.py	Thu Apr 24 11:48:07 2008 +0200
@@ -12,7 +12,7 @@
 
 from node import hex, nullid, short
 from i18n import _
-import changegroup, util, os, struct, bz2, tempfile, shutil, mdiff
+import changegroup, util, os, struct, bz2, zlib, tempfile, shutil, mdiff
 import repo, localrepo, changelog, manifest, filelog, revlog
 
 class bundlerevlog(revlog.revlog):
@@ -173,14 +173,17 @@
             raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename)
         elif not header.startswith("HG10"):
             raise util.Abort(_("%s: unknown bundle version") % bundlename)
-        elif header == "HG10BZ":
+        elif (header == "HG10BZ") or (header == "HG10GZ"):
             fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-",
                                             suffix=".hg10un", dir=self.path)
             self.tempfile = temp
             fptemp = os.fdopen(fdtemp, 'wb')
             def generator(f):
-                zd = bz2.BZ2Decompressor()
-                zd.decompress("BZ")
+                if header == "HG10BZ":
+                    zd = bz2.BZ2Decompressor()
+                    zd.decompress("BZ")
+                elif header == "HG10GZ":
+                    zd = zlib.decompressobj()
                 for chunk in f:
                     yield zd.decompress(chunk)
             gen = generator(util.filechunkiter(self.bundlefile, 4096))