Show More
@@ -136,29 +136,36 b' def decompressor(fh, alg):' | |||
|
136 | 136 | yield zd.decompress(chunk) |
|
137 | 137 | else: |
|
138 | 138 | raise util.Abort("unknown bundle compression '%s'" % alg) |
|
139 | return generator(fh) | |
|
139 | return util.chunkbuffer(generator(fh)) | |
|
140 | 140 | |
|
141 | 141 | class unbundle10(object): |
|
142 | 142 | def __init__(self, fh, alg): |
|
143 |
self._stream = |
|
|
143 | self._stream = decompressor(fh, alg) | |
|
144 | 144 | self._type = alg |
|
145 | 145 | def compressed(self): |
|
146 | 146 | return self._type != 'UN' |
|
147 | 147 | def read(self, l): |
|
148 | 148 | return self._stream.read(l) |
|
149 | 149 | |
|
150 | class headerlessfixup(object): | |
|
151 | def __init__(self, fh, h): | |
|
152 | self._h = h | |
|
153 | self._fh = fh | |
|
154 | def read(self, n): | |
|
155 | if self._h: | |
|
156 | d, self._h = self._h[:n], self._h[n:] | |
|
157 | if len(d) < n: | |
|
158 | d += self._fh.read(n - len(d)) | |
|
159 | return d | |
|
160 | return self._fh.read(n) | |
|
161 | ||
|
150 | 162 | def readbundle(fh, fname): |
|
151 | 163 | header = fh.read(6) |
|
152 | 164 | |
|
153 | 165 | if not fname: |
|
154 | 166 | fname = "stream" |
|
155 | 167 | if not header.startswith('HG') and header.startswith('\0'): |
|
156 |
|
|
|
157 | def fixup(f, h): | |
|
158 | yield h | |
|
159 | for x in f: | |
|
160 | yield x | |
|
161 | fh = fixup(fh, header) | |
|
168 | fh = headerlessfixup(fh, header) | |
|
162 | 169 | header = "HG10UN" |
|
163 | 170 | |
|
164 | 171 | magic, version, alg = header[0:2], header[2:4], header[4:6] |
General Comments 0
You need to be logged in to leave comments.
Login now