##// END OF EJS Templates
ui: simplify interface of low-level write() functions...
Yuya Nishihara -
r40556:49746e53 default
parent child Browse files
Show More
@@ -529,7 +529,7 b' if pycompat.iswindows:'
529 attr = mapcolor(int(sattr), attr)
529 attr = mapcolor(int(sattr), attr)
530 ui.flush()
530 ui.flush()
531 _kernel32.SetConsoleTextAttribute(stdout, attr)
531 _kernel32.SetConsoleTextAttribute(stdout, attr)
532 writefunc(m.group(2), **opts)
532 writefunc(m.group(2))
533 m = re.match(ansire, m.group(3))
533 m = re.match(ansire, m.group(3))
534 finally:
534 finally:
535 # Explicitly reset original attributes
535 # Explicitly reset original attributes
@@ -960,13 +960,13 b' class ui(object):'
960 if self._colormode is not None:
960 if self._colormode is not None:
961 label = opts.get(r'label', '')
961 label = opts.get(r'label', '')
962 msgs = [self.label(a, label) for a in args]
962 msgs = [self.label(a, label) for a in args]
963 write(*msgs, **opts)
963 write(b''.join(msgs))
964
964
965 def _write(self, *msgs, **opts):
965 def _write(self, data):
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(data)
970 except IOError as err:
970 except IOError as err:
971 raise error.StdioError(err)
971 raise error.StdioError(err)
972 finally:
972 finally:
@@ -979,13 +979,12 b' class ui(object):'
979 else:
979 else:
980 self._writenobuf(self._write_err, *args, **opts)
980 self._writenobuf(self._write_err, *args, **opts)
981
981
982 def _write_err(self, *msgs, **opts):
982 def _write_err(self, data):
983 try:
983 try:
984 with self.timeblockedsection('stdio'):
984 with self.timeblockedsection('stdio'):
985 if not getattr(self.fout, 'closed', False):
985 if not getattr(self.fout, 'closed', False):
986 self.fout.flush()
986 self.fout.flush()
987 for a in msgs:
987 self.ferr.write(data)
988 self.ferr.write(a)
989 # stderr may be buffered under win32 when redirected to files,
988 # stderr may be buffered under win32 when redirected to files,
990 # including stdout.
989 # including stdout.
991 if not getattr(self.ferr, 'closed', False):
990 if not getattr(self.ferr, 'closed', False):
General Comments 0
You need to be logged in to leave comments. Login now