Show More
@@ -160,7 +160,7 b' class httprepository(wireproto.wirerepos' | |||
|
160 | 160 | break |
|
161 | 161 | |
|
162 | 162 | tempname = changegroup.writebundle(cg, None, type) |
|
163 | fp = url.httpsendfile(tempname, "rb") | |
|
163 | fp = url.httpsendfile(self.ui, tempname, "rb") | |
|
164 | 164 | headers = {'Content-Type': 'application/mercurial-0.1'} |
|
165 | 165 | |
|
166 | 166 | try: |
@@ -258,18 +258,36 b' class httpsendfile(object):' | |||
|
258 | 258 | defines a __len__ attribute to feed the Content-Length header. |
|
259 | 259 | """ |
|
260 | 260 | |
|
261 | def __init__(self, *args, **kwargs): | |
|
261 | def __init__(self, ui, *args, **kwargs): | |
|
262 | 262 | # We can't just "self._data = open(*args, **kwargs)" here because there |
|
263 | 263 | # is an "open" function defined in this module that shadows the global |
|
264 | 264 | # one |
|
265 | self.ui = ui | |
|
265 | 266 | self._data = __builtin__.open(*args, **kwargs) |
|
266 | self.read = self._data.read | |
|
267 | 267 | self.seek = self._data.seek |
|
268 | 268 | self.close = self._data.close |
|
269 | 269 | self.write = self._data.write |
|
270 | self._len = os.fstat(self._data.fileno()).st_size | |
|
271 | self._pos = 0 | |
|
272 | self._total = len(self) / 1024 * 2 | |
|
273 | ||
|
274 | def read(self, *args, **kwargs): | |
|
275 | try: | |
|
276 | ret = self._data.read(*args, **kwargs) | |
|
277 | except EOFError: | |
|
278 | self.ui.progress(_('sending'), None) | |
|
279 | self._pos += len(ret) | |
|
280 | # We pass double the max for total because we currently have | |
|
281 | # to send the bundle twice in the case of a server that | |
|
282 | # requires authentication. Since we can't know until we try | |
|
283 | # once whether authentication will be required, just lie to | |
|
284 | # the user and maybe the push succeeds suddenly at 50%. | |
|
285 | self.ui.progress(_('sending'), self._pos / 1024, | |
|
286 | unit=_('kb'), total=self._total) | |
|
287 | return ret | |
|
270 | 288 | |
|
271 | 289 | def __len__(self): |
|
272 |
return |
|
|
290 | return self._len | |
|
273 | 291 | |
|
274 | 292 | def _gen_sendfile(connection): |
|
275 | 293 | def _sendfile(self, data): |
General Comments 0
You need to be logged in to leave comments.
Login now