diff mercurial/ui.py @ 43265:82879e06c926

ui: option to preserve the progress bar Some interface like the fast-import format of git are meant for pipe processing. It can be still desirable to have progress bars in this case, but clearing the bar after each output operation is not desirable. Differential Revision: https://phab.mercurial-scm.org/D6843
author Joerg Sonnenberger <joerg@bec.de>
date Thu, 12 Sep 2019 03:40:54 +0200
parents 57efd5bd2ca2
children aaa046919043
line wrap: on
line diff
--- a/mercurial/ui.py	Thu Oct 10 22:11:39 2019 +0100
+++ b/mercurial/ui.py	Thu Sep 12 03:40:54 2019 +0200
@@ -1072,6 +1072,13 @@
         Label names take the form of "topic.type". For example, ui.debug()
         issues a label of "ui.debug".
 
+        Progress reports via stderr are normally cleared before writing as
+        stdout and stderr go to the same terminal. This can be skipped with
+        the optional keyword argument "keepprogressbar". The progress bar
+        will continue to occupy a partial line on stderr in that case.
+        This functionality is intended when Mercurial acts as data source
+        in a pipe.
+
         When labeling output for a specific command, a label of
         "cmdname.type" is recommended. For example, status issues
         a label of "status.modified" for modified files.
@@ -1087,8 +1094,9 @@
                 self._buffers[-1].extend(args)
             return
 
-        # inliend _writenobuf() for speed
-        self._progclear()
+        # inlined _writenobuf() for speed
+        if not opts.get(r'keepprogressbar', False):
+            self._progclear()
         msg = b''.join(args)
 
         # opencode timeblockedsection because this is a critical path
@@ -1126,7 +1134,8 @@
 
     def _writenobuf(self, dest, *args, **opts):
         # update write() as well if you touch this code
-        self._progclear()
+        if not opts.get(r'keepprogressbar', False):
+            self._progclear()
         msg = b''.join(args)
 
         # opencode timeblockedsection because this is a critical path