changeset 6569:c15bfe9cdcd6

add support for HG10GZ bundles to bundlerepo.bundlerevlog()
author Benoit Allard <benoit@aeteurope.nl>
date Thu, 24 Apr 2008 11:48:07 +0200
parents 0c4c804c8261
children 626cb86a6523
files mercurial/bundlerepo.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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))