Show More
@@ -399,7 +399,7 b' class pipeservice(object):' | |||
|
399 | 399 | ui = self.ui |
|
400 | 400 | # redirect stdio to null device so that broken extensions or in-process |
|
401 | 401 | # hooks will never cause corruption of channel protocol. |
|
402 |
with |
|
|
402 | with ui.protectedfinout() as (fin, fout): | |
|
403 | 403 | sv = server(ui, self.repo, fin, fout) |
|
404 | 404 | try: |
|
405 | 405 | return sv.serve() |
@@ -1080,6 +1080,15 b' class ui(object):' | |||
|
1080 | 1080 | return False |
|
1081 | 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 | 1092 | def disablepager(self): |
|
1084 | 1093 | self._disablepager = True |
|
1085 | 1094 |
@@ -299,15 +299,6 b' def restorestdio(uin, uout, fin, fout):' | |||
|
299 | 299 | os.dup2(f.fileno(), uif.fileno()) |
|
300 | 300 | f.close() |
|
301 | 301 | |
|
302 | @contextlib.contextmanager | |
|
303 | def protectedstdio(uin, uout): | |
|
304 | """Run code block with protected standard streams""" | |
|
305 | fin, fout = protectstdio(uin, uout) | |
|
306 | try: | |
|
307 | yield fin, fout | |
|
308 | finally: | |
|
309 | restorestdio(uin, uout, fin, fout) | |
|
310 | ||
|
311 | 302 | def shellenviron(environ=None): |
|
312 | 303 | """return environ with optional override, useful for shelling out""" |
|
313 | 304 | def py2shell(val): |
General Comments 0
You need to be logged in to leave comments.
Login now