hgext/largefiles/remotestore.py
changeset 25660 328739ea70c3
parent 25079 bee00e0c2e45
child 26587 56b2bcea2529
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
    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             fd = lfutil.httpsendfile(self.ui, filename)
    39             fd = lfutil.httpsendfile(self.ui, filename)
    40             return self._put(hash, fd)
    40             return self._put(hash, fd)
    41         except IOError, e:
    41         except IOError as e:
    42             raise util.Abort(
    42             raise util.Abort(
    43                 _('remotestore: could not open file %s: %s')
    43                 _('remotestore: could not open file %s: %s')
    44                 % (filename, str(e)))
    44                 % (filename, str(e)))
    45         finally:
    45         finally:
    46             if fd:
    46             if fd:
    47                 fd.close()
    47                 fd.close()
    48 
    48 
    49     def _getfile(self, tmpfile, filename, hash):
    49     def _getfile(self, tmpfile, filename, hash):
    50         try:
    50         try:
    51             chunks = self._get(hash)
    51             chunks = self._get(hash)
    52         except urllib2.HTTPError, e:
    52         except urllib2.HTTPError as e:
    53             # 401s get converted to util.Aborts; everything else is fine being
    53             # 401s get converted to util.Aborts; everything else is fine being
    54             # turned into a StoreError
    54             # turned into a StoreError
    55             raise basestore.StoreError(filename, hash, self.url, str(e))
    55             raise basestore.StoreError(filename, hash, self.url, str(e))
    56         except urllib2.URLError, e:
    56         except urllib2.URLError as e:
    57             # This usually indicates a connection problem, so don't
    57             # This usually indicates a connection problem, so don't
    58             # keep trying with the other files... they will probably
    58             # keep trying with the other files... they will probably
    59             # all fail too.
    59             # all fail too.
    60             raise util.Abort('%s: %s' %
    60             raise util.Abort('%s: %s' %
    61                              (util.hidepassword(self.url), e.reason))
    61                              (util.hidepassword(self.url), e.reason))
    62         except IOError, e:
    62         except IOError as e:
    63             raise basestore.StoreError(filename, hash, self.url, str(e))
    63             raise basestore.StoreError(filename, hash, self.url, str(e))
    64 
    64 
    65         return lfutil.copyandhash(chunks, tmpfile)
    65         return lfutil.copyandhash(chunks, tmpfile)
    66 
    66 
    67     def _verifyfile(self, cctx, cset, contents, standin, verified):
    67     def _verifyfile(self, cctx, cset, contents, standin, verified):