comparison mercurial/sshrepo.py @ 16688:cfb6682961b8

cleanup: replace naked excepts with more specific ones
author Brodie Rao <brodie@sf.io>
date Sat, 12 May 2012 16:02:45 +0200
parents 525fdb738975
children
comparison
equal deleted inserted replaced
16687:e34106fa0dc3 16688:cfb6682961b8
27 27
28 class sshrepository(wireproto.wirerepository): 28 class sshrepository(wireproto.wirerepository):
29 def __init__(self, ui, path, create=False): 29 def __init__(self, ui, path, create=False):
30 self._url = path 30 self._url = path
31 self.ui = ui 31 self.ui = ui
32 self.pipeo = self.pipei = self.pipee = None
32 33
33 u = util.url(path, parsequery=False, parsefragment=False) 34 u = util.url(path, parsequery=False, parsefragment=False)
34 if u.scheme != 'ssh' or not u.host or u.path is None: 35 if u.scheme != 'ssh' or not u.host or u.path is None:
35 self._abort(error.RepoError(_("couldn't parse location %s") % path)) 36 self._abort(error.RepoError(_("couldn't parse location %s") % path))
36 37
109 def _abort(self, exception): 110 def _abort(self, exception):
110 self.cleanup() 111 self.cleanup()
111 raise exception 112 raise exception
112 113
113 def cleanup(self): 114 def cleanup(self):
115 if self.pipeo is None:
116 return
117 self.pipeo.close()
118 self.pipei.close()
114 try: 119 try:
115 self.pipeo.close()
116 self.pipei.close()
117 # read the error descriptor until EOF 120 # read the error descriptor until EOF
118 for l in self.pipee: 121 for l in self.pipee:
119 self.ui.status(_("remote: "), l) 122 self.ui.status(_("remote: "), l)
120 self.pipee.close() 123 except (IOError, ValueError):
121 except:
122 pass 124 pass
125 self.pipee.close()
123 126
124 __del__ = cleanup 127 __del__ = cleanup
125 128
126 def _callstream(self, cmd, **args): 129 def _callstream(self, cmd, **args):
127 self.ui.debug("sending %s command\n" % cmd) 130 self.ui.debug("sending %s command\n" % cmd)