mercurial/sshpeer.py
changeset 35933 805edf16e8e0
parent 35932 31449baf0936
child 35934 94ba29934f00
equal deleted inserted replaced
35932:31449baf0936 35933:805edf16e8e0
   112         return self._main.close()
   112         return self._main.close()
   113 
   113 
   114     def flush(self):
   114     def flush(self):
   115         return self._main.flush()
   115         return self._main.flush()
   116 
   116 
       
   117 def _cleanuppipes(ui, pipei, pipeo, pipee):
       
   118     """Clean up pipes used by an SSH connection."""
       
   119     if pipeo:
       
   120         pipeo.close()
       
   121     if pipei:
       
   122         pipei.close()
       
   123 
       
   124     if pipee:
       
   125         # Try to read from the err descriptor until EOF.
       
   126         try:
       
   127             for l in pipee:
       
   128                 ui.status(_('remote: '), l)
       
   129         except (IOError, ValueError):
       
   130             pass
       
   131 
       
   132         pipee.close()
       
   133 
   117 class sshpeer(wireproto.wirepeer):
   134 class sshpeer(wireproto.wirepeer):
   118     def __init__(self, ui, path, create=False, sshstate=None):
   135     def __init__(self, ui, path, create=False, sshstate=None):
   119         self._url = path
   136         self._url = path
   120         self._ui = ui
   137         self._ui = ui
   121         self._pipeo = self._pipei = self._pipee = None
   138         self._pipeo = self._pipei = self._pipee = None
   219     def _abort(self, exception):
   236     def _abort(self, exception):
   220         self._cleanup()
   237         self._cleanup()
   221         raise exception
   238         raise exception
   222 
   239 
   223     def _cleanup(self):
   240     def _cleanup(self):
   224         if self._pipeo is None:
   241         _cleanuppipes(self.ui, self._pipei, self._pipeo, self._pipee)
   225             return
       
   226         self._pipeo.close()
       
   227         self._pipei.close()
       
   228         try:
       
   229             # read the error descriptor until EOF
       
   230             for l in self._pipee:
       
   231                 self.ui.status(_("remote: "), l)
       
   232         except (IOError, ValueError):
       
   233             pass
       
   234         self._pipee.close()
       
   235 
   242 
   236     __del__ = _cleanup
   243     __del__ = _cleanup
   237 
   244 
   238     def _submitbatch(self, req):
   245     def _submitbatch(self, req):
   239         rsp = self._callstream("batch", cmds=wireproto.encodebatchcmds(req))
   246         rsp = self._callstream("batch", cmds=wireproto.encodebatchcmds(req))