# HG changeset patch # User Yuya Nishihara # Date 1541234170 -32400 # Node ID 49746e53ac929c2ff92990100c1462a67cda660a # Parent fd60c2afb48482186f33986880d64be79ace98b1 ui: simplify interface of low-level write() functions _write() and _write_err() will be replaced with fout.write() and ferr.write() respectively. This is the first step. diff -r fd60c2afb484 -r 49746e53ac92 mercurial/color.py --- a/mercurial/color.py Sat Nov 03 17:32:35 2018 +0900 +++ b/mercurial/color.py Sat Nov 03 17:36:10 2018 +0900 @@ -529,7 +529,7 @@ attr = mapcolor(int(sattr), attr) ui.flush() _kernel32.SetConsoleTextAttribute(stdout, attr) - writefunc(m.group(2), **opts) + writefunc(m.group(2)) m = re.match(ansire, m.group(3)) finally: # Explicitly reset original attributes diff -r fd60c2afb484 -r 49746e53ac92 mercurial/ui.py --- a/mercurial/ui.py Sat Nov 03 17:32:35 2018 +0900 +++ b/mercurial/ui.py Sat Nov 03 17:36:10 2018 +0900 @@ -960,13 +960,13 @@ if self._colormode is not None: label = opts.get(r'label', '') msgs = [self.label(a, label) for a in args] - write(*msgs, **opts) + write(b''.join(msgs)) - def _write(self, *msgs, **opts): + def _write(self, data): # opencode timeblockedsection because this is a critical path starttime = util.timer() try: - self.fout.write(''.join(msgs)) + self.fout.write(data) except IOError as err: raise error.StdioError(err) finally: @@ -979,13 +979,12 @@ else: self._writenobuf(self._write_err, *args, **opts) - def _write_err(self, *msgs, **opts): + def _write_err(self, data): try: with self.timeblockedsection('stdio'): if not getattr(self.fout, 'closed', False): self.fout.flush() - for a in msgs: - self.ferr.write(a) + self.ferr.write(data) # stderr may be buffered under win32 when redirected to files, # including stdout. if not getattr(self.ferr, 'closed', False):