Patchwork D5530: progress: check what type of progress bar to use only once per topic

login
register
mail settings
Submitter phabricator
Date Jan. 9, 2019, 7:40 p.m.
Message ID <848ad3624f42e62756470790ae1dbe1a@localhost.localdomain>
Download mbox | patch
Permalink /patch/37578/
State Not Applicable
Headers show

Comments

phabricator - Jan. 9, 2019, 7:40 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG963462786f6e: progress: check what type of progress bar to use only once per topic (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5530?vs=13080&id=13098

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1422,6 +1422,24 @@ 
         self.unit = unit
         self.total = total
         self.debug = ui.configbool('progress', 'debug')
+        if getattr(ui._fmsgerr, 'structured', False):
+            # channel for machine-readable output with metadata, just send
+            # raw information
+            # TODO: consider porting some useful information (e.g. estimated
+            # time) from progbar. we might want to support update delay to
+            # reduce the cost of transferring progress messages.
+            def updatebar(item):
+                ui._fmsgerr.write(None, type=b'progress', topic=self.topic,
+                                  pos=self.pos, item=item, unit=self.unit,
+                                  total=self.total)
+        elif ui._progbar is not None:
+            def updatebar(item):
+                ui._progbar.progress(self.topic, self.pos, item=item,
+                                     unit=self.unit, total=self.total)
+        else:
+            def updatebar(item):
+                pass
+        self._updatebar = updatebar
 
     def __enter__(self):
         return self
@@ -1447,20 +1465,6 @@ 
         self.total = None
         self._updatebar("")
 
-    def _updatebar(self, item):
-        if getattr(self.ui._fmsgerr, 'structured', False):
-            # channel for machine-readable output with metadata, just send
-            # raw information
-            # TODO: consider porting some useful information (e.g. estimated
-            # time) from progbar. we might want to support update delay to
-            # reduce the cost of transferring progress messages.
-            self.ui._fmsgerr.write(None, type=b'progress', topic=self.topic,
-                                   pos=self.pos, item=item, unit=self.unit,
-                                   total=self.total)
-        elif self.ui._progbar is not None:
-            self.ui._progbar.progress(self.topic, self.pos, item=item,
-                                      unit=self.unit, total=self.total)
-
     def _printdebug(self, item):
         if self.unit:
             unit = ' ' + self.unit