Show More
@@ -138,24 +138,24 b' def decompressor(fh, alg):' | |||
|
138 | 138 | raise util.Abort("unknown bundle compression '%s'" % alg) |
|
139 | 139 | return generator(fh) |
|
140 | 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)) | |
|
152 | ||
|
153 | 141 | def readbundle(fh, fname): |
|
154 | 142 | header = fh.read(6) |
|
155 | if not header.startswith('HG'): | |
|
156 | raise util.Abort(_('%s: not a Mercurial bundle file') % fname) | |
|
157 | if not header.startswith('HG10'): | |
|
158 | raise util.Abort(_('%s: unknown bundle version') % fname) | |
|
159 | elif header not in bundletypes: | |
|
160 | raise util.Abort(_('%s: unknown bundle compression type') % fname) | |
|
161 | return unbundle(header, fh) | |
|
143 | ||
|
144 | if not fname: | |
|
145 | fname = "stream" | |
|
146 | if not header.startswith('HG') and header.startswith('\0'): | |
|
147 | # headerless bundle, clean things up | |
|
148 | def fixup(f, h): | |
|
149 | yield h | |
|
150 | for x in f: | |
|
151 | yield x | |
|
152 | fh = fixup(fh, header) | |
|
153 | header = "HG10UN" | |
|
154 | ||
|
155 | magic, version, alg = header[0:2], header[2:4], header[4:6] | |
|
156 | ||
|
157 | if magic != 'HG': | |
|
158 | raise util.Abort(_('%s: not a Mercurial bundle') % fname) | |
|
159 | if version != '10': | |
|
160 | raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) | |
|
161 | return util.chunkbuffer(decompressor(fh, alg)) |
@@ -294,13 +294,7 b' def unbundle(repo, proto, heads):' | |||
|
294 | 294 | |
|
295 | 295 | # push can proceed |
|
296 | 296 | fp.seek(0) |
|
297 | header = fp.read(6) | |
|
298 | if header.startswith('HG'): | |
|
299 | if not header.startswith('HG10'): | |
|
300 | raise ValueError('unknown bundle version') | |
|
301 | elif header not in changegroupmod.bundletypes: | |
|
302 | raise ValueError('unknown bundle compression type') | |
|
303 | gen = changegroupmod.unbundle(header, fp) | |
|
297 | gen = changegroupmod.readbundle(fp, None) | |
|
304 | 298 | |
|
305 | 299 | try: |
|
306 | 300 | r = repo.addchangegroup(gen, 'serve', proto._client(), |
General Comments 0
You need to be logged in to leave comments.
Login now