##// END OF EJS Templates
changegroup: move chunk extraction into a getchunks method of unbundle10...
Pierre-Yves David -
r20999:1e28ec97 default
parent child Browse files
Show More
@@ -91,23 +91,8 b' def writebundle(cg, filename, bundletype'
91 91 # an empty chunkgroup is the end of the changegroup
92 92 # a changegroup has at least 2 chunkgroups (changelog and manifest).
93 93 # after that, an empty chunkgroup is the end of the changegroup
94 empty = False
95 count = 0
96 while not empty or count <= 2:
97 empty = True
98 count += 1
99 while True:
100 chunk = getchunk(cg)
101 if not chunk:
102 break
103 empty = False
104 fh.write(z.compress(chunkheader(len(chunk))))
105 pos = 0
106 while pos < len(chunk):
107 next = pos + 2**20
108 fh.write(z.compress(chunk[pos:next]))
109 pos = next
110 fh.write(z.compress(closechunk()))
94 for chunk in cg.getchunks():
95 fh.write(z.compress(chunk))
111 96 fh.write(z.flush())
112 97 cleanup = None
113 98 return filename
@@ -202,6 +187,34 b' class unbundle10(object):'
202 187 return {'node': node, 'p1': p1, 'p2': p2, 'cs': cs,
203 188 'deltabase': deltabase, 'delta': delta}
204 189
190 def getchunks(self):
191 """returns all the chunks contains in the bundle
192
193 Used when you need to forward the binary stream to a file or another
194 network API. To do so, it parse the changegroup data, otherwise it will
195 block in case of sshrepo because it don't know the end of the stream.
196 """
197 # an empty chunkgroup is the end of the changegroup
198 # a changegroup has at least 2 chunkgroups (changelog and manifest).
199 # after that, an empty chunkgroup is the end of the changegroup
200 empty = False
201 count = 0
202 while not empty or count <= 2:
203 empty = True
204 count += 1
205 while True:
206 chunk = getchunk(self)
207 if not chunk:
208 break
209 empty = False
210 yield chunkheader(len(chunk))
211 pos = 0
212 while pos < len(chunk):
213 next = pos + 2**20
214 yield chunk[pos:next]
215 pos = next
216 yield closechunk()
217
205 218 class headerlessfixup(object):
206 219 def __init__(self, fh, h):
207 220 self._h = h
General Comments 0
You need to be logged in to leave comments. Login now