Show More
@@ -120,27 +120,35 b' def writebundle(cg, filename, bundletype' | |||||
120 | if cleanup is not None: |
|
120 | if cleanup is not None: | |
121 | os.unlink(cleanup) |
|
121 | os.unlink(cleanup) | |
122 |
|
122 | |||
123 | def unbundle(header, fh): |
|
123 | def decompressor(fh, alg): | |
124 |
if |
|
124 | if alg == 'UN': | |
125 | return fh |
|
125 | return fh | |
126 | elif not header.startswith('HG'): |
|
126 | elif alg == 'GZ': | |
127 | # old client with uncompressed bundle |
|
|||
128 | def generator(f): |
|
|||
129 | yield header |
|
|||
130 | for chunk in f: |
|
|||
131 | yield chunk |
|
|||
132 | elif header == 'HG10GZ': |
|
|||
133 | def generator(f): |
|
127 | def generator(f): | |
134 | zd = zlib.decompressobj() |
|
128 | zd = zlib.decompressobj() | |
135 | for chunk in f: |
|
129 | for chunk in f: | |
136 | yield zd.decompress(chunk) |
|
130 | yield zd.decompress(chunk) | |
137 |
elif |
|
131 | elif alg == 'BZ': | |
138 | def generator(f): |
|
132 | def generator(f): | |
139 | zd = bz2.BZ2Decompressor() |
|
133 | zd = bz2.BZ2Decompressor() | |
140 | zd.decompress("BZ") |
|
134 | zd.decompress("BZ") | |
141 | for chunk in util.filechunkiter(f, 4096): |
|
135 | for chunk in util.filechunkiter(f, 4096): | |
142 | yield zd.decompress(chunk) |
|
136 | yield zd.decompress(chunk) | |
143 | return util.chunkbuffer(generator(fh)) |
|
137 | else: | |
|
138 | raise util.Abort("unknown bundle compression '%s'" % alg) | |||
|
139 | return generator(fh) | |||
|
140 | ||||
|
141 | def unbundle(header, fh): | |||
|
142 | if not header.startswith('HG'): | |||
|
143 | def fixup(f, h): | |||
|
144 | yield h | |||
|
145 | for x in f: | |||
|
146 | yield x | |||
|
147 | fh = fixup(f, h) | |||
|
148 | header = "HG10UN" | |||
|
149 | ||||
|
150 | alg = header[4:6] | |||
|
151 | return util.chunkbuffer(decompressor(fh, alg)) | |||
144 |
|
152 | |||
145 | def readbundle(fh, fname): |
|
153 | def readbundle(fh, fname): | |
146 | header = fh.read(6) |
|
154 | header = fh.read(6) |
General Comments 0
You need to be logged in to leave comments.
Login now