# HG changeset patch # User Yuya Nishihara # Date 2018-11-03 08:36:10 # 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 --git a/mercurial/color.py b/mercurial/color.py --- a/mercurial/color.py +++ b/mercurial/color.py @@ -529,7 +529,7 @@ if pycompat.iswindows: 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 --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -960,13 +960,13 @@ class ui(object): 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 @@ class ui(object): 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):