Show More
@@ -231,9 +231,9 class ui(object): | |||
|
231 | 231 | self._uninterruptible = False |
|
232 | 232 | |
|
233 | 233 | if src: |
|
234 | self.fout = src.fout | |
|
235 | self.ferr = src.ferr | |
|
236 | self.fin = src.fin | |
|
234 | self._fout = src._fout | |
|
235 | self._ferr = src._ferr | |
|
236 | self._fin = src._fin | |
|
237 | 237 | self._finoutredirected = src._finoutredirected |
|
238 | 238 | self.pageractive = src.pageractive |
|
239 | 239 | self._disablepager = src._disablepager |
@@ -256,9 +256,9 class ui(object): | |||
|
256 | 256 | self.httppasswordmgrdb = src.httppasswordmgrdb |
|
257 | 257 | self._blockedtimes = src._blockedtimes |
|
258 | 258 | else: |
|
259 | self.fout = procutil.stdout | |
|
260 | self.ferr = procutil.stderr | |
|
261 | self.fin = procutil.stdin | |
|
259 | self._fout = procutil.stdout | |
|
260 | self._ferr = procutil.stderr | |
|
261 | self._fin = procutil.stdin | |
|
262 | 262 | self._finoutredirected = False |
|
263 | 263 | self.pageractive = False |
|
264 | 264 | self._disablepager = False |
@@ -884,6 +884,30 class ui(object): | |||
|
884 | 884 | def paths(self): |
|
885 | 885 | return paths(self) |
|
886 | 886 | |
|
887 | @property | |
|
888 | def fout(self): | |
|
889 | return self._fout | |
|
890 | ||
|
891 | @fout.setter | |
|
892 | def fout(self, f): | |
|
893 | self._fout = f | |
|
894 | ||
|
895 | @property | |
|
896 | def ferr(self): | |
|
897 | return self._ferr | |
|
898 | ||
|
899 | @ferr.setter | |
|
900 | def ferr(self, f): | |
|
901 | self._ferr = f | |
|
902 | ||
|
903 | @property | |
|
904 | def fin(self): | |
|
905 | return self._fin | |
|
906 | ||
|
907 | @fin.setter | |
|
908 | def fin(self, f): | |
|
909 | self._fin = f | |
|
910 | ||
|
887 | 911 | def pushbuffer(self, error=False, subproc=False, labeled=False): |
|
888 | 912 | """install a buffer to capture standard output of the ui object |
|
889 | 913 | |
@@ -914,9 +938,9 class ui(object): | |||
|
914 | 938 | return "".join(self._buffers.pop()) |
|
915 | 939 | |
|
916 | 940 | def _isbuffered(self, dest): |
|
917 | if dest is self.fout: | |
|
941 | if dest is self._fout: | |
|
918 | 942 | return bool(self._buffers) |
|
919 | if dest is self.ferr: | |
|
943 | if dest is self._ferr: | |
|
920 | 944 | return bool(self._bufferstates and self._bufferstates[-1][0]) |
|
921 | 945 | return False |
|
922 | 946 | |
@@ -947,10 +971,10 class ui(object): | |||
|
947 | 971 | "cmdname.type" is recommended. For example, status issues |
|
948 | 972 | a label of "status.modified" for modified files. |
|
949 | 973 | ''' |
|
950 | self._write(self.fout, *args, **opts) | |
|
974 | self._write(self._fout, *args, **opts) | |
|
951 | 975 | |
|
952 | 976 | def write_err(self, *args, **opts): |
|
953 | self._write(self.ferr, *args, **opts) | |
|
977 | self._write(self._ferr, *args, **opts) | |
|
954 | 978 | |
|
955 | 979 | def _write(self, dest, *args, **opts): |
|
956 | 980 | if self._isbuffered(dest): |
@@ -969,8 +993,8 class ui(object): | |||
|
969 | 993 | # opencode timeblockedsection because this is a critical path |
|
970 | 994 | starttime = util.timer() |
|
971 | 995 | try: |
|
972 | if dest is self.ferr and not getattr(self.fout, 'closed', False): | |
|
973 | self.fout.flush() | |
|
996 | if dest is self._ferr and not getattr(self._fout, 'closed', False): | |
|
997 | self._fout.flush() | |
|
974 | 998 | if self._colormode == 'win32': |
|
975 | 999 | # windows color printing is its own can of crab, defer to |
|
976 | 1000 | # the color module and that is it. |
@@ -982,10 +1006,10 class ui(object): | |||
|
982 | 1006 | dest.write(msg) |
|
983 | 1007 | # stderr may be buffered under win32 when redirected to files, |
|
984 | 1008 | # including stdout. |
|
985 | if dest is self.ferr and not getattr(self.ferr, 'closed', False): | |
|
1009 | if dest is self._ferr and not getattr(self._ferr, 'closed', False): | |
|
986 | 1010 | dest.flush() |
|
987 | 1011 | except IOError as err: |
|
988 | if (dest is self.ferr | |
|
1012 | if (dest is self._ferr | |
|
989 | 1013 | and err.errno in (errno.EPIPE, errno.EIO, errno.EBADF)): |
|
990 | 1014 | # no way to report the error, so ignore it |
|
991 | 1015 | return |
@@ -999,13 +1023,13 class ui(object): | |||
|
999 | 1023 | starttime = util.timer() |
|
1000 | 1024 | try: |
|
1001 | 1025 | try: |
|
1002 | self.fout.flush() | |
|
1026 | self._fout.flush() | |
|
1003 | 1027 | except IOError as err: |
|
1004 | 1028 | if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
|
1005 | 1029 | raise error.StdioError(err) |
|
1006 | 1030 | finally: |
|
1007 | 1031 | try: |
|
1008 | self.ferr.flush() | |
|
1032 | self._ferr.flush() | |
|
1009 | 1033 | except IOError as err: |
|
1010 | 1034 | if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
|
1011 | 1035 | raise error.StdioError(err) |
@@ -1255,7 +1279,7 class ui(object): | |||
|
1255 | 1279 | if i is None: |
|
1256 | 1280 | # some environments replace stdin without implementing isatty |
|
1257 | 1281 | # usually those are non-interactive |
|
1258 | return self._isatty(self.fin) | |
|
1282 | return self._isatty(self._fin) | |
|
1259 | 1283 | |
|
1260 | 1284 | return i |
|
1261 | 1285 | |
@@ -1293,7 +1317,7 class ui(object): | |||
|
1293 | 1317 | if i is None: |
|
1294 | 1318 | # some environments replace stdout without implementing isatty |
|
1295 | 1319 | # usually those are non-interactive |
|
1296 | return self._isatty(self.fout) | |
|
1320 | return self._isatty(self._fout) | |
|
1297 | 1321 | |
|
1298 | 1322 | return i |
|
1299 | 1323 | |
@@ -1302,9 +1326,9 class ui(object): | |||
|
1302 | 1326 | # because they have to be text streams with *no buffering*. Instead, |
|
1303 | 1327 | # we use rawinput() only if call_readline() will be invoked by |
|
1304 | 1328 | # PyOS_Readline(), so no I/O will be made at Python layer. |
|
1305 | usereadline = (self._isatty(self.fin) and self._isatty(self.fout) | |
|
1306 | and procutil.isstdin(self.fin) | |
|
1307 | and procutil.isstdout(self.fout)) | |
|
1329 | usereadline = (self._isatty(self._fin) and self._isatty(self._fout) | |
|
1330 | and procutil.isstdin(self._fin) | |
|
1331 | and procutil.isstdout(self._fout)) | |
|
1308 | 1332 | if usereadline: |
|
1309 | 1333 | try: |
|
1310 | 1334 | # magically add command line editing support, where |
@@ -1326,9 +1350,9 class ui(object): | |||
|
1326 | 1350 | if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'): |
|
1327 | 1351 | line = line[:-1] |
|
1328 | 1352 | else: |
|
1329 | self.fout.write(b' ') | |
|
1330 | self.fout.flush() | |
|
1331 | line = self.fin.readline() | |
|
1353 | self._fout.write(b' ') | |
|
1354 | self._fout.flush() | |
|
1355 | line = self._fin.readline() | |
|
1332 | 1356 | if not line: |
|
1333 | 1357 | raise EOFError |
|
1334 | 1358 | line = line.rstrip(pycompat.oslinesep) |
@@ -1343,7 +1367,7 class ui(object): | |||
|
1343 | 1367 | self.write(msg, ' ', label='ui.prompt') |
|
1344 | 1368 | self.write(default or '', "\n", label='ui.promptecho') |
|
1345 | 1369 | return default |
|
1346 | self._writenobuf(self.fout, msg, label='ui.prompt') | |
|
1370 | self._writenobuf(self._fout, msg, label='ui.prompt') | |
|
1347 | 1371 | self.flush() |
|
1348 | 1372 | try: |
|
1349 | 1373 | r = self._readline() |
@@ -1411,7 +1435,7 class ui(object): | |||
|
1411 | 1435 | # to interact with tty even if fin is not a tty. |
|
1412 | 1436 | with self.timeblockedsection('stdio'): |
|
1413 | 1437 | if self.configbool('ui', 'nontty'): |
|
1414 | l = self.fin.readline() | |
|
1438 | l = self._fin.readline() | |
|
1415 | 1439 | if not l: |
|
1416 | 1440 | raise EOFError |
|
1417 | 1441 | return l.rstrip('\n') |
@@ -1537,7 +1561,7 class ui(object): | |||
|
1537 | 1561 | # the tail end instead |
|
1538 | 1562 | cmdsuffix = cmd.translate(None, _keepalnum)[-85:] |
|
1539 | 1563 | blockedtag = 'unknown_system_' + cmdsuffix |
|
1540 | out = self.fout | |
|
1564 | out = self._fout | |
|
1541 | 1565 | if any(s[1] for s in self._bufferstates): |
|
1542 | 1566 | out = self |
|
1543 | 1567 | with self.timeblockedsection(blockedtag): |
@@ -1682,7 +1706,7 class ui(object): | |||
|
1682 | 1706 | msg = 'devel-warn: ' + msg |
|
1683 | 1707 | stacklevel += 1 # get in develwarn |
|
1684 | 1708 | if self.tracebackflag: |
|
1685 | util.debugstacktrace(msg, stacklevel, self.ferr, self.fout) | |
|
1709 | util.debugstacktrace(msg, stacklevel, self._ferr, self._fout) | |
|
1686 | 1710 | self.log('develwarn', '%s at:\n%s' % |
|
1687 | 1711 | (msg, ''.join(util.getstackframes(stacklevel)))) |
|
1688 | 1712 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now