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