##// END OF EJS Templates
ui: factor out function that writes data to fout/ferr with labeling...
Yuya Nishihara -
r40555:fd60c2af default
parent child Browse files
Show More
@@ -947,20 +947,20 b' class ui(object):'
947 else:
947 else:
948 self._buffers[-1].extend(args)
948 self._buffers[-1].extend(args)
949 else:
949 else:
950 self._writenobuf(*args, **opts)
950 self._writenobuf(self._write, *args, **opts)
951
951
952 def _writenobuf(self, *args, **opts):
952 def _writenobuf(self, write, *args, **opts):
953 self._progclear()
953 self._progclear()
954 if self._colormode == 'win32':
954 if self._colormode == 'win32':
955 # windows color printing is its own can of crab, defer to
955 # windows color printing is its own can of crab, defer to
956 # the color module and that is it.
956 # the color module and that is it.
957 color.win32print(self, self._write, *args, **opts)
957 color.win32print(self, write, *args, **opts)
958 else:
958 else:
959 msgs = args
959 msgs = args
960 if self._colormode is not None:
960 if self._colormode is not None:
961 label = opts.get(r'label', '')
961 label = opts.get(r'label', '')
962 msgs = [self.label(a, label) for a in args]
962 msgs = [self.label(a, label) for a in args]
963 self._write(*msgs, **opts)
963 write(*msgs, **opts)
964
964
965 def _write(self, *msgs, **opts):
965 def _write(self, *msgs, **opts):
966 # opencode timeblockedsection because this is a critical path
966 # opencode timeblockedsection because this is a critical path
@@ -976,18 +976,8 b' class ui(object):'
976 def write_err(self, *args, **opts):
976 def write_err(self, *args, **opts):
977 if self._bufferstates and self._bufferstates[-1][0]:
977 if self._bufferstates and self._bufferstates[-1][0]:
978 self.write(*args, **opts)
978 self.write(*args, **opts)
979 return
980 self._progclear()
981 if self._colormode == 'win32':
982 # windows color printing is its own can of crab, defer to
983 # the color module and that is it.
984 color.win32print(self, self._write_err, *args, **opts)
985 else:
979 else:
986 msgs = args
980 self._writenobuf(self._write_err, *args, **opts)
987 if self._colormode is not None:
988 label = opts.get(r'label', '')
989 msgs = [self.label(a, label) for a in args]
990 self._write_err(*msgs, **opts)
991
981
992 def _write_err(self, *msgs, **opts):
982 def _write_err(self, *msgs, **opts):
993 try:
983 try:
@@ -1352,7 +1342,7 b' class ui(object):'
1352 if not self.interactive():
1342 if not self.interactive():
1353 self.write(msg, ' ', default or '', "\n")
1343 self.write(msg, ' ', default or '', "\n")
1354 return default
1344 return default
1355 self._writenobuf(msg, label='ui.prompt')
1345 self._writenobuf(self._write, msg, label='ui.prompt')
1356 self.flush()
1346 self.flush()
1357 try:
1347 try:
1358 r = self._readline()
1348 r = self._readline()
General Comments 0
You need to be logged in to leave comments. Login now