Mercurial > hg-stable
changeset 40588:c5e964f75bf7
ui: pass in file object to _writenobuf()
See the subsequent patches for why. The "if" block in _writenobuf() will
be removed soon.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 03 Nov 2018 17:56:17 +0900 |
parents | cbd251d479bb |
children | 04a9dd8da959 |
files | mercurial/ui.py |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Mon Nov 05 17:24:39 2018 +0100 +++ b/mercurial/ui.py Sat Nov 03 17:56:17 2018 +0900 @@ -947,10 +947,16 @@ else: self._buffers[-1].extend(args) else: - self._writenobuf(self._write, *args, **opts) + self._writenobuf(self.fout, *args, **opts) - def _writenobuf(self, write, *args, **opts): + def _writenobuf(self, dest, *args, **opts): self._progclear() + if dest is self.fout: + write = self._write + elif dest is self.ferr: + write = self._write_err + else: + raise error.ProgrammingError('unsupported file to write') msg = b''.join(args) # opencode timeblockedsection because this is a critical path @@ -979,7 +985,7 @@ if self._bufferstates and self._bufferstates[-1][0]: self.write(*args, **opts) else: - self._writenobuf(self._write_err, *args, **opts) + self._writenobuf(self.ferr, *args, **opts) def _write_err(self, data): try: @@ -1343,7 +1349,7 @@ if not self.interactive(): self.write(msg, ' ', default or '', "\n") return default - self._writenobuf(self._write, msg, label='ui.prompt') + self._writenobuf(self.fout, msg, label='ui.prompt') self.flush() try: r = self._readline()