# HG changeset patch # User Pierre-Yves David # Date 2023-03-21 14:29:35 # Node ID 7f0f3b274d1edf7f90e32c9dd70eea0b90c6ff6e # Parent e07dc1e7a45435e962e072b3831b3c2a7979710c ui: keep the progress bar around when writing if stdout is not a tty diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1107,10 +1107,16 @@ class ui: def fout(self): return self._fout + @util.propertycache + def _fout_is_a_tty(self): + self._isatty(self._fout) + @fout.setter def fout(self, f): self._fout = f self._fmsgout, self._fmsgerr = _selectmsgdests(self) + if '_fout_is_a_tty' in vars(self): + del self._fout_is_a_tty @property def ferr(self): @@ -1234,7 +1240,7 @@ class ui: return # inlined _writenobuf() for speed - if not opts.get('keepprogressbar', False): + if not opts.get('keepprogressbar', self._fout_is_a_tty): self._progclear() msg = b''.join(args) @@ -1273,7 +1279,7 @@ class ui: def _writenobuf(self, dest, *args: bytes, **opts: _MsgOpts) -> None: # update write() as well if you touch this code - if not opts.get('keepprogressbar', False): + if not opts.get('keepprogressbar', self._fout_is_a_tty): self._progclear() msg = b''.join(args)