# HG changeset patch # User Martin von Zweigbergk # Date 1529302266 25200 # Node ID 5f9d436cd3b714d68ba6aeb329229b5291224483 # Parent 81a4be7099fafefe775123bf29d96af69f146803 httpconnection: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3794 diff -r 81a4be7099fa -r 5f9d436cd3b7 mercurial/httpconnection.py --- a/mercurial/httpconnection.py Sun Jun 03 18:18:36 2018 +0900 +++ b/mercurial/httpconnection.py Sun Jun 17 23:11:06 2018 -0700 @@ -38,21 +38,21 @@ self.write = self._data.write self.length = os.fstat(self._data.fileno()).st_size self._pos = 0 - self._total = self.length // 1024 * 2 - - def read(self, *args, **kwargs): - ret = self._data.read(*args, **kwargs) - if not ret: - self.ui.progress(_('sending'), None) - return ret - self._pos += len(ret) # We pass double the max for total because we currently have # to send the bundle twice in the case of a server that # requires authentication. Since we can't know until we try # once whether authentication will be required, just lie to # the user and maybe the push succeeds suddenly at 50%. - self.ui.progress(_('sending'), self._pos // 1024, - unit=_('kb'), total=self._total) + self._progress = ui.makeprogress(_('sending'), unit=_('kb'), + total=(self.length // 1024 * 2)) + + def read(self, *args, **kwargs): + ret = self._data.read(*args, **kwargs) + if not ret: + self._progress.complete() + return ret + self._pos += len(ret) + self._progress.update(self._pos // 1024) return ret def __enter__(self):