mercurial/ui.py
changeset 41284 b0e3f2d7c143
parent 41225 44914de4e915
child 41285 cf8677cd7286
--- a/mercurial/ui.py	Thu Jan 10 21:29:24 2019 +0900
+++ b/mercurial/ui.py	Wed Sep 26 21:29:13 2018 +0900
@@ -1080,6 +1080,15 @@
             return False
         return procutil.isatty(fh)
 
+    @contextlib.contextmanager
+    def protectedfinout(self):
+        """Run code block with protected standard streams"""
+        fin, fout = procutil.protectstdio(self._fin, self._fout)
+        try:
+            yield fin, fout
+        finally:
+            procutil.restorestdio(self._fin, self._fout, fin, fout)
+
     def disablepager(self):
         self._disablepager = True