comparison 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
comparison
equal deleted inserted replaced
1979:d545fa1426b9 1980:dfb796786337
172 def __init__(self, ui, path, bundlename): 172 def __init__(self, ui, path, bundlename):
173 localrepo.localrepository.__init__(self, ui, path) 173 localrepo.localrepository.__init__(self, ui, path)
174 f = open(bundlename, "rb") 174 f = open(bundlename, "rb")
175 s = os.fstat(f.fileno()) 175 s = os.fstat(f.fileno())
176 self.bundlefile = f 176 self.bundlefile = f
177 header = self.bundlefile.read(4) 177 header = self.bundlefile.read(6)
178 if header == "HG10": 178 if not header.startswith("HG"):
179 raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename)
180 elif not header.startswith("HG10"):
181 raise util.Abort(_("%s: unknown bundle version") % bundlename)
182 elif header == "HG10BZ":
179 raise util.Abort(_("%s: compressed bundle not supported") 183 raise util.Abort(_("%s: compressed bundle not supported")
180 % bundlename) 184 % bundlename)
181 elif header != "HG11": 185 elif header == "HG10UN":
182 raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename) 186 # uncompressed bundle supported
187 pass
188 else:
189 raise util.Abort(_("%s: unknown bundle compression type")
190 % bundlename)
183 self.changelog = bundlechangelog(self.opener, self.bundlefile) 191 self.changelog = bundlechangelog(self.opener, self.bundlefile)
184 self.manifest = bundlemanifest(self.opener, self.bundlefile, 192 self.manifest = bundlemanifest(self.opener, self.bundlefile,
185 self.changelog.rev) 193 self.changelog.rev)
186 # dict with the mapping 'filename' -> position in the bundle 194 # dict with the mapping 'filename' -> position in the bundle
187 self.bundlefilespos = {} 195 self.bundlefilespos = {}