comparison mercurial/ui.py @ 40519:3c4b9dace7de

ui: consolidate places where _progclear() is called The progress bar has to be cleared when we start writing some data to the output stream. Let's make it always triggered immediately before switching by _colormode, so that we can easily factor out helper functions.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Nov 2018 16:04:16 +0900
parents 0d403e9f049a
children fd60c2afb484
comparison
equal deleted inserted replaced
40518:d11e2c5b287e 40519:3c4b9dace7de
948 self._buffers[-1].extend(args) 948 self._buffers[-1].extend(args)
949 else: 949 else:
950 self._writenobuf(*args, **opts) 950 self._writenobuf(*args, **opts)
951 951
952 def _writenobuf(self, *args, **opts): 952 def _writenobuf(self, *args, **opts):
953 self._progclear()
953 if self._colormode == 'win32': 954 if self._colormode == 'win32':
954 # windows color printing is its own can of crab, defer to 955 # windows color printing is its own can of crab, defer to
955 # the color module and that is it. 956 # the color module and that is it.
956 color.win32print(self, self._write, *args, **opts) 957 color.win32print(self, self._write, *args, **opts)
957 else: 958 else:
960 label = opts.get(r'label', '') 961 label = opts.get(r'label', '')
961 msgs = [self.label(a, label) for a in args] 962 msgs = [self.label(a, label) for a in args]
962 self._write(*msgs, **opts) 963 self._write(*msgs, **opts)
963 964
964 def _write(self, *msgs, **opts): 965 def _write(self, *msgs, **opts):
965 self._progclear()
966 # opencode timeblockedsection because this is a critical path 966 # opencode timeblockedsection because this is a critical path
967 starttime = util.timer() 967 starttime = util.timer()
968 try: 968 try:
969 self.fout.write(''.join(msgs)) 969 self.fout.write(''.join(msgs))
970 except IOError as err: 970 except IOError as err:
972 finally: 972 finally:
973 self._blockedtimes['stdio_blocked'] += \ 973 self._blockedtimes['stdio_blocked'] += \
974 (util.timer() - starttime) * 1000 974 (util.timer() - starttime) * 1000
975 975
976 def write_err(self, *args, **opts): 976 def write_err(self, *args, **opts):
977 self._progclear()
978 if self._bufferstates and self._bufferstates[-1][0]: 977 if self._bufferstates and self._bufferstates[-1][0]:
979 self.write(*args, **opts) 978 self.write(*args, **opts)
980 elif self._colormode == 'win32': 979 return
980 self._progclear()
981 if self._colormode == 'win32':
981 # windows color printing is its own can of crab, defer to 982 # windows color printing is its own can of crab, defer to
982 # the color module and that is it. 983 # the color module and that is it.
983 color.win32print(self, self._write_err, *args, **opts) 984 color.win32print(self, self._write_err, *args, **opts)
984 else: 985 else:
985 msgs = args 986 msgs = args