D3794: httpconnection: use progress helper

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Jun 18 16:26:08 EDT 2018


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

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):



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


More information about the Mercurial-devel mailing list