hgext/largefiles/remotestore.py
changeset 37084 f0b6fbea00cf
parent 36562 247e9bf4ecdc
child 43076 2372284d9457
equal deleted inserted replaced
37083:f99d64e8a4e4 37084:f0b6fbea00cf
    10 from mercurial.i18n import _
    10 from mercurial.i18n import _
    11 
    11 
    12 from mercurial import (
    12 from mercurial import (
    13     error,
    13     error,
    14     util,
    14     util,
       
    15 )
       
    16 
       
    17 from mercurial.utils import (
       
    18     stringutil,
    15 )
    19 )
    16 
    20 
    17 from . import (
    21 from . import (
    18     basestore,
    22     basestore,
    19     lfutil,
    23     lfutil,
    50             with lfutil.httpsendfile(self.ui, filename) as fd:
    54             with lfutil.httpsendfile(self.ui, filename) as fd:
    51                 return self._put(hash, fd)
    55                 return self._put(hash, fd)
    52         except IOError as e:
    56         except IOError as e:
    53             raise error.Abort(
    57             raise error.Abort(
    54                 _('remotestore: could not open file %s: %s')
    58                 _('remotestore: could not open file %s: %s')
    55                 % (filename, util.forcebytestr(e)))
    59                 % (filename, stringutil.forcebytestr(e)))
    56 
    60 
    57     def _getfile(self, tmpfile, filename, hash):
    61     def _getfile(self, tmpfile, filename, hash):
    58         try:
    62         try:
    59             chunks = self._get(hash)
    63             chunks = self._get(hash)
    60         except urlerr.httperror as e:
    64         except urlerr.httperror as e:
    61             # 401s get converted to error.Aborts; everything else is fine being
    65             # 401s get converted to error.Aborts; everything else is fine being
    62             # turned into a StoreError
    66             # turned into a StoreError
    63             raise basestore.StoreError(filename, hash, self.url,
    67             raise basestore.StoreError(filename, hash, self.url,
    64                                        util.forcebytestr(e))
    68                                        stringutil.forcebytestr(e))
    65         except urlerr.urlerror as e:
    69         except urlerr.urlerror as e:
    66             # This usually indicates a connection problem, so don't
    70             # This usually indicates a connection problem, so don't
    67             # keep trying with the other files... they will probably
    71             # keep trying with the other files... they will probably
    68             # all fail too.
    72             # all fail too.
    69             raise error.Abort('%s: %s' %
    73             raise error.Abort('%s: %s' %
    70                              (util.hidepassword(self.url), e.reason))
    74                              (util.hidepassword(self.url), e.reason))
    71         except IOError as e:
    75         except IOError as e:
    72             raise basestore.StoreError(filename, hash, self.url,
    76             raise basestore.StoreError(filename, hash, self.url,
    73                                        util.forcebytestr(e))
    77                                        stringutil.forcebytestr(e))
    74 
    78 
    75         return lfutil.copyandhash(chunks, tmpfile)
    79         return lfutil.copyandhash(chunks, tmpfile)
    76 
    80 
    77     def _hashesavailablelocally(self, hashes):
    81     def _hashesavailablelocally(self, hashes):
    78         existslocallymap = self._lstore.exists(hashes)
    82         existslocallymap = self._lstore.exists(hashes)