comparison hgext/largefiles/remotestore.py @ 25079:bee00e0c2e45

largefiles: use try/except/finally
author Matt Mackall <mpm@selenic.com>
date Fri, 15 May 2015 09:55:15 -0500
parents 70252bdfd39c
children 328739ea70c3
comparison
equal deleted inserted replaced
25078:e8348f1cc228 25079:bee00e0c2e45
34 34
35 def sendfile(self, filename, hash): 35 def sendfile(self, filename, hash):
36 self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) 36 self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash))
37 fd = None 37 fd = None
38 try: 38 try:
39 try: 39 fd = lfutil.httpsendfile(self.ui, filename)
40 fd = lfutil.httpsendfile(self.ui, filename)
41 except IOError, e:
42 raise util.Abort(
43 _('remotestore: could not open file %s: %s')
44 % (filename, str(e)))
45 return self._put(hash, fd) 40 return self._put(hash, fd)
41 except IOError, e:
42 raise util.Abort(
43 _('remotestore: could not open file %s: %s')
44 % (filename, str(e)))
46 finally: 45 finally:
47 if fd: 46 if fd:
48 fd.close() 47 fd.close()
49 48
50 def _getfile(self, tmpfile, filename, hash): 49 def _getfile(self, tmpfile, filename, hash):