equal
deleted
inserted
replaced
10 import struct, os, bz2, zlib, tempfile |
10 import struct, os, bz2, zlib, tempfile |
11 |
11 |
12 def getchunk(source): |
12 def getchunk(source): |
13 """return the next chunk from changegroup 'source' as a string""" |
13 """return the next chunk from changegroup 'source' as a string""" |
14 d = source.read(4) |
14 d = source.read(4) |
15 if not d: |
|
16 return "" |
|
17 l = struct.unpack(">l", d)[0] |
15 l = struct.unpack(">l", d)[0] |
18 if l <= 4: |
16 if l <= 4: |
19 return "" |
17 return "" |
20 d = source.read(l - 4) |
18 d = source.read(l - 4) |
21 if len(d) < l - 4: |
19 if len(d) < l - 4: |
146 def close(self): |
144 def close(self): |
147 return self._stream.close() |
145 return self._stream.close() |
148 |
146 |
149 def chunklength(self): |
147 def chunklength(self): |
150 d = self.read(4) |
148 d = self.read(4) |
151 if not d: |
|
152 return 0 |
|
153 l = max(0, struct.unpack(">l", d)[0] - 4) |
149 l = max(0, struct.unpack(">l", d)[0] - 4) |
154 if l and self.callback: |
150 if l and self.callback: |
155 self.callback() |
151 self.callback() |
156 return l |
152 return l |
157 |
153 |