Show More
@@ -120,27 +120,35 b' def writebundle(cg, filename, bundletype' | |||
|
120 | 120 | if cleanup is not None: |
|
121 | 121 | os.unlink(cleanup) |
|
122 | 122 | |
|
123 | def unbundle(header, fh): | |
|
124 |
if |
|
|
123 | def decompressor(fh, alg): | |
|
124 | if alg == 'UN': | |
|
125 | 125 | return fh |
|
126 | elif not header.startswith('HG'): | |
|
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': | |
|
126 | elif alg == 'GZ': | |
|
133 | 127 | def generator(f): |
|
134 | 128 | zd = zlib.decompressobj() |
|
135 | 129 | for chunk in f: |
|
136 | 130 | yield zd.decompress(chunk) |
|
137 |
elif |
|
|
131 | elif alg == 'BZ': | |
|
138 | 132 | def generator(f): |
|
139 | 133 | zd = bz2.BZ2Decompressor() |
|
140 | 134 | zd.decompress("BZ") |
|
141 | 135 | for chunk in util.filechunkiter(f, 4096): |
|
142 | 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 | 153 | def readbundle(fh, fname): |
|
146 | 154 | header = fh.read(6) |
General Comments 0
You need to be logged in to leave comments.
Login now