Patchwork D6843: ui: option to preserve the progress bar

login
register
mail settings
Submitter phabricator
Date Sept. 12, 2019, 1:41 a.m.
Message ID <differential-rev-PHID-DREV-qwn3p3bod4noi3imbg5a-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41647/
State Superseded
Headers show

Comments

phabricator - Sept. 12, 2019, 1:41 a.m.
joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
phabricator - Sept. 23, 2019, 5:06 p.m.
durin42 added a comment.


  Shouldn't we print a newline to preserve the progress bar? I guess I'm not following the logic.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6843/new/

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

To: joerg.sonnenberger, #hg-reviewers
Cc: durin42, mercurial-devel
phabricator - Sept. 23, 2019, 10:22 p.m.
joerg.sonnenberger added a comment.


  The goal here is to allow something like "hg fast-export | git fast-import" to show a proper progress bar.
  At the moment every write via ui.write and friends will hide the progress bar and re-enable it, even when stdout doesn't affect the terminal state. This would also make sense for operations like "hg diff", e.g. when writing a large/complicated diff to a file.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6843/new/

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

To: joerg.sonnenberger, #hg-reviewers
Cc: durin42, mercurial-devel
phabricator - Oct. 5, 2019, 7:39 p.m.
This revision now requires changes to proceed.
indygreg added a comment.
indygreg requested changes to this revision.


  I think this is a useful feature. I've wanted this in automated environment so the last state from the progress bar is preserved, for example.
  
  But I agree with Augie that I believe we need to print a newline if we're keeping the progress bar because at the point we print the progress bar, the cursor is at the end of the progress bar.
  
  Also, the printing of the line needs to be abstracted and performed in the progress bar implementation. I would check the config option in `_progclear()` and pass the value to `clear()` and it can determine if it needs to print a `\n` or what.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6843/new/

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

To: joerg.sonnenberger, #hg-reviewers, indygreg
Cc: indygreg, durin42, mercurial-devel

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1023,8 +1023,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
@@ -1061,7 +1062,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