Patchwork D3794: httpconnection: use progress helper

login
register
mail settings
Submitter phabricator
Date June 18, 2018, 8:26 p.m.
Message ID <c571c97546fe82e52972f6b04362c664@localhost.localdomain>
Download mbox | patch
Permalink /patch/32300/
State Not Applicable
Headers show

Comments

phabricator - June 18, 2018, 8:26 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5f9d436cd3b7: httpconnection: use progress helper (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3794?vs=9188&id=9196

REVISION DETAIL
  https://phab.mercurial-scm.org/D3794

AFFECTED FILES
  mercurial/httpconnection.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/httpconnection.py b/mercurial/httpconnection.py
--- a/mercurial/httpconnection.py
+++ b/mercurial/httpconnection.py
@@ -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):