mercurial/utils/procutil.py
changeset 41284 b0e3f2d7c143
parent 41079 8ecb17b7f432
child 41837 b275dbb60089
equal deleted inserted replaced
41283:4948b327d3b9 41284:b0e3f2d7c143
   296     uout.flush()
   296     uout.flush()
   297     for f, uif in [(fin, uin), (fout, uout)]:
   297     for f, uif in [(fin, uin), (fout, uout)]:
   298         if f is not uif:
   298         if f is not uif:
   299             os.dup2(f.fileno(), uif.fileno())
   299             os.dup2(f.fileno(), uif.fileno())
   300             f.close()
   300             f.close()
   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 
   301 
   311 def shellenviron(environ=None):
   302 def shellenviron(environ=None):
   312     """return environ with optional override, useful for shelling out"""
   303     """return environ with optional override, useful for shelling out"""
   313     def py2shell(val):
   304     def py2shell(val):
   314         'convert python object into string that is useful to shell'
   305         'convert python object into string that is useful to shell'