comparison mercurial/changegroup.py @ 12043:bef5effb3db0

bundle: introduce bundle class
author Matt Mackall <mpm@selenic.com>
date Wed, 25 Aug 2010 16:53:06 -0500
parents 210049a8d16e
children bcc7139521b7
comparison
equal deleted inserted replaced
12042:210049a8d16e 12043:bef5effb3db0
136 yield zd.decompress(chunk) 136 yield zd.decompress(chunk)
137 else: 137 else:
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 class unbundle10(object):
142 def __init__(self, fh, alg):
143 self._stream = util.chunkbuffer(decompressor(fh, alg))
144 def read(self, l):
145 return self._stream.read(l)
146
141 def readbundle(fh, fname): 147 def readbundle(fh, fname):
142 header = fh.read(6) 148 header = fh.read(6)
143 149
144 if not fname: 150 if not fname:
145 fname = "stream" 151 fname = "stream"
156 162
157 if magic != 'HG': 163 if magic != 'HG':
158 raise util.Abort(_('%s: not a Mercurial bundle') % fname) 164 raise util.Abort(_('%s: not a Mercurial bundle') % fname)
159 if version != '10': 165 if version != '10':
160 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) 166 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
161 return util.chunkbuffer(decompressor(fh, alg)) 167 return unbundle10(fh, alg)