diff mercurial/bundlerepo.py @ 1980:dfb796786337

use HG10UN header for uncompressed bundle - use HG10UN instead of HG11 for uncompressed bundles header - check HG10BZ for compressed bundle - better error handling for invalid header some notes: - people who created uncompressed bundle will no longer be able to use them (it could be fixed with hand-editing) - older hg cannot detect an uncompressed bundle (bzip2 decompression will fail).
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 21 Mar 2006 06:03:33 +0100
parents 915b81a35e46
children 736b6c96bbbc
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Mon Mar 20 17:14:58 2006 +0100
+++ b/mercurial/bundlerepo.py	Tue Mar 21 06:03:33 2006 +0100
@@ -174,12 +174,20 @@
         f = open(bundlename, "rb")
         s = os.fstat(f.fileno())
         self.bundlefile = f
-        header = self.bundlefile.read(4)
-        if header == "HG10":
+        header = self.bundlefile.read(6)
+        if not header.startswith("HG"):
+            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":
             raise util.Abort(_("%s: compressed bundle not supported")
                              % bundlename)
-        elif header != "HG11":
-            raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename)
+        elif header == "HG10UN":
+            # uncompressed bundle supported
+            pass
+        else:
+            raise util.Abort(_("%s: unknown bundle compression type")
+                             % bundlename)
         self.changelog = bundlechangelog(self.opener, self.bundlefile)
         self.manifest = bundlemanifest(self.opener, self.bundlefile,
                                        self.changelog.rev)