Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 41284:b0e3f2d7c143
ui: move protectedstdio() context manager from procutil
This is a follow-up series for 23a00bc90a3c, "chgserver: do not send system()
back to client if stdio redirected." The function is renamed using ui terms.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 26 Sep 2018 21:29:13 +0900 |
parents | 44914de4e915 |
children | cf8677cd7286 |
comparison
equal
deleted
inserted
replaced
41283:4948b327d3b9 | 41284:b0e3f2d7c143 |
---|---|
1078 def _isatty(self, fh): | 1078 def _isatty(self, fh): |
1079 if self.configbool('ui', 'nontty'): | 1079 if self.configbool('ui', 'nontty'): |
1080 return False | 1080 return False |
1081 return procutil.isatty(fh) | 1081 return procutil.isatty(fh) |
1082 | 1082 |
1083 @contextlib.contextmanager | |
1084 def protectedfinout(self): | |
1085 """Run code block with protected standard streams""" | |
1086 fin, fout = procutil.protectstdio(self._fin, self._fout) | |
1087 try: | |
1088 yield fin, fout | |
1089 finally: | |
1090 procutil.restorestdio(self._fin, self._fout, fin, fout) | |
1091 | |
1083 def disablepager(self): | 1092 def disablepager(self): |
1084 self._disablepager = True | 1093 self._disablepager = True |
1085 | 1094 |
1086 def pager(self, command): | 1095 def pager(self, command): |
1087 """Start a pager for subsequent command output. | 1096 """Start a pager for subsequent command output. |