950 self._writenobuf(self._write, *args, **opts) |
950 self._writenobuf(self._write, *args, **opts) |
951 |
951 |
952 def _writenobuf(self, write, *args, **opts): |
952 def _writenobuf(self, write, *args, **opts): |
953 self._progclear() |
953 self._progclear() |
954 msg = b''.join(args) |
954 msg = b''.join(args) |
|
955 |
|
956 # opencode timeblockedsection because this is a critical path |
|
957 starttime = util.timer() |
955 try: |
958 try: |
956 if self._colormode == 'win32': |
959 if self._colormode == 'win32': |
957 # windows color printing is its own can of crab, defer to |
960 # windows color printing is its own can of crab, defer to |
958 # the color module and that is it. |
961 # the color module and that is it. |
959 color.win32print(self, write, msg, **opts) |
962 color.win32print(self, write, msg, **opts) |
961 if self._colormode is not None: |
964 if self._colormode is not None: |
962 label = opts.get(r'label', '') |
965 label = opts.get(r'label', '') |
963 msg = self.label(msg, label) |
966 msg = self.label(msg, label) |
964 write(msg) |
967 write(msg) |
965 finally: |
968 finally: |
966 pass |
969 self._blockedtimes['stdio_blocked'] += \ |
|
970 (util.timer() - starttime) * 1000 |
967 |
971 |
968 def _write(self, data): |
972 def _write(self, data): |
969 # opencode timeblockedsection because this is a critical path |
|
970 starttime = util.timer() |
|
971 try: |
973 try: |
972 self.fout.write(data) |
974 self.fout.write(data) |
973 except IOError as err: |
975 except IOError as err: |
974 raise error.StdioError(err) |
976 raise error.StdioError(err) |
975 finally: |
|
976 self._blockedtimes['stdio_blocked'] += \ |
|
977 (util.timer() - starttime) * 1000 |
|
978 |
977 |
979 def write_err(self, *args, **opts): |
978 def write_err(self, *args, **opts): |
980 if self._bufferstates and self._bufferstates[-1][0]: |
979 if self._bufferstates and self._bufferstates[-1][0]: |
981 self.write(*args, **opts) |
980 self.write(*args, **opts) |
982 else: |
981 else: |
983 self._writenobuf(self._write_err, *args, **opts) |
982 self._writenobuf(self._write_err, *args, **opts) |
984 |
983 |
985 def _write_err(self, data): |
984 def _write_err(self, data): |
986 try: |
985 try: |
987 with self.timeblockedsection('stdio'): |
986 if True: |
988 if not getattr(self.fout, 'closed', False): |
987 if not getattr(self.fout, 'closed', False): |
989 self.fout.flush() |
988 self.fout.flush() |
990 self.ferr.write(data) |
989 self.ferr.write(data) |
991 # stderr may be buffered under win32 when redirected to files, |
990 # stderr may be buffered under win32 when redirected to files, |
992 # including stdout. |
991 # including stdout. |