##// END OF EJS Templates
httpconnection: use progress helper...
Martin von Zweigbergk -
r38412:5f9d436c default
parent child Browse files
Show More
@@ -38,21 +38,21 b' class httpsendfile(object):'
38 self.write = self._data.write
38 self.write = self._data.write
39 self.length = os.fstat(self._data.fileno()).st_size
39 self.length = os.fstat(self._data.fileno()).st_size
40 self._pos = 0
40 self._pos = 0
41 self._total = self.length // 1024 * 2
42
43 def read(self, *args, **kwargs):
44 ret = self._data.read(*args, **kwargs)
45 if not ret:
46 self.ui.progress(_('sending'), None)
47 return ret
48 self._pos += len(ret)
49 # We pass double the max for total because we currently have
41 # We pass double the max for total because we currently have
50 # to send the bundle twice in the case of a server that
42 # to send the bundle twice in the case of a server that
51 # requires authentication. Since we can't know until we try
43 # requires authentication. Since we can't know until we try
52 # once whether authentication will be required, just lie to
44 # once whether authentication will be required, just lie to
53 # the user and maybe the push succeeds suddenly at 50%.
45 # the user and maybe the push succeeds suddenly at 50%.
54 self.ui.progress(_('sending'), self._pos // 1024,
46 self._progress = ui.makeprogress(_('sending'), unit=_('kb'),
55 unit=_('kb'), total=self._total)
47 total=(self.length // 1024 * 2))
48
49 def read(self, *args, **kwargs):
50 ret = self._data.read(*args, **kwargs)
51 if not ret:
52 self._progress.complete()
53 return ret
54 self._pos += len(ret)
55 self._progress.update(self._pos // 1024)
56 return ret
56 return ret
57
57
58 def __enter__(self):
58 def __enter__(self):
General Comments 0
You need to be logged in to leave comments. Login now