Patchwork [3,of,7] ui: remove _write() and _write_err() functions

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 6, 2018, 2:21 p.m.
Message ID <a4353cb008c9ca70dc34.1541514092@mimosa>
Download mbox | patch
Permalink /patch/36432/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 6, 2018, 2:21 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1541235862 -32400
#      Sat Nov 03 18:04:22 2018 +0900
# Node ID a4353cb008c9ca70dc347b6c151f9252ba30d82e
# Parent  c90197c485ea4a9bf33259050ecbb0480f443003
ui: remove _write() and _write_err() functions

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -951,12 +951,6 @@  class ui(object):
 
     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
@@ -967,12 +961,12 @@  class ui(object):
             if self._colormode == 'win32':
                 # windows color printing is its own can of crab, defer to
                 # the color module and that is it.
-                color.win32print(self, write, msg, **opts)
+                color.win32print(self, dest.write, msg, **opts)
             else:
                 if self._colormode is not None:
                     label = opts.get(r'label', '')
                     msg = self.label(msg, label)
-                write(msg)
+                dest.write(msg)
             # stderr may be buffered under win32 when redirected to files,
             # including stdout.
             if dest is self.ferr and not getattr(self.ferr, 'closed', False):
@@ -987,18 +981,12 @@  class ui(object):
             self._blockedtimes['stdio_blocked'] += \
                 (util.timer() - starttime) * 1000
 
-    def _write(self, data):
-        self.fout.write(data)
-
     def write_err(self, *args, **opts):
         if self._bufferstates and self._bufferstates[-1][0]:
             self.write(*args, **opts)
         else:
             self._writenobuf(self.ferr, *args, **opts)
 
-    def _write_err(self, data):
-        self.ferr.write(data)
-
     def flush(self):
         # opencode timeblockedsection because this is a critical path
         starttime = util.timer()