Show More
@@ -174,12 +174,20 b' class bundlerepository(localrepo.localre' | |||||
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( |
|
177 | header = self.bundlefile.read(6) | |
178 |
if header |
|
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 |
|
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) |
@@ -304,7 +304,7 b' def write_bundle(cg, filename=None, comp' | |||||
304 | fh.write("HG10") |
|
304 | fh.write("HG10") | |
305 | z = bz2.BZ2Compressor(9) |
|
305 | z = bz2.BZ2Compressor(9) | |
306 | else: |
|
306 | else: | |
307 |
fh.write("HG1 |
|
307 | fh.write("HG10UN") | |
308 | z = nocompress() |
|
308 | z = nocompress() | |
309 | while 1: |
|
309 | while 1: | |
310 | chunk = cg.read(4096) |
|
310 | chunk = cg.read(4096) | |
@@ -2569,18 +2569,24 b' def unbundle(ui, repo, fname, **opts):' | |||||
2569 | """ |
|
2569 | """ | |
2570 | f = urllib.urlopen(fname) |
|
2570 | f = urllib.urlopen(fname) | |
2571 |
|
2571 | |||
2572 |
header = f.read( |
|
2572 | header = f.read(6) | |
2573 |
if header |
|
2573 | if not header.startswith("HG"): | |
|
2574 | raise util.Abort(_("%s: not a Mercurial bundle file") % fname) | |||
|
2575 | elif not header.startswith("HG10"): | |||
|
2576 | raise util.Abort(_("%s: unknown bundle version") % fname) | |||
|
2577 | elif header == "HG10BZ": | |||
2574 | def generator(f): |
|
2578 | def generator(f): | |
2575 | zd = bz2.BZ2Decompressor() |
|
2579 | zd = bz2.BZ2Decompressor() | |
|
2580 | zd.decompress("BZ") | |||
2576 | for chunk in f: |
|
2581 | for chunk in f: | |
2577 | yield zd.decompress(chunk) |
|
2582 | yield zd.decompress(chunk) | |
2578 |
elif header == "HG1 |
|
2583 | elif header == "HG10UN": | |
2579 | def generator(f): |
|
2584 | def generator(f): | |
2580 | for chunk in f: |
|
2585 | for chunk in f: | |
2581 | yield chunk |
|
2586 | yield chunk | |
2582 | else: |
|
2587 | else: | |
2583 |
raise util.Abort(_("%s: |
|
2588 | raise util.Abort(_("%s: unknown bundle compression type") | |
|
2589 | % fname) | |||
2584 | gen = generator(util.filechunkiter(f, 4096)) |
|
2590 | gen = generator(util.filechunkiter(f, 4096)) | |
2585 | if repo.addchangegroup(util.chunkbuffer(gen)): |
|
2591 | if repo.addchangegroup(util.chunkbuffer(gen)): | |
2586 | return 1 |
|
2592 | return 1 |
General Comments 0
You need to be logged in to leave comments.
Login now