Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHG247e9bf4ecdc: py3: use util.forcebytestr() to convert IOErrors to bytes
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| yuja |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/largefiles/remotestore.py (8 lines) |
| def sendfile(self, filename, hash): | def sendfile(self, filename, hash): | ||||
| self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) | self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) | ||||
| try: | try: | ||||
| with lfutil.httpsendfile(self.ui, filename) as fd: | with lfutil.httpsendfile(self.ui, filename) as fd: | ||||
| return self._put(hash, fd) | return self._put(hash, fd) | ||||
| except IOError as e: | except IOError as e: | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _('remotestore: could not open file %s: %s') | _('remotestore: could not open file %s: %s') | ||||
| % (filename, str(e))) | % (filename, util.forcebytestr(e))) | ||||
| def _getfile(self, tmpfile, filename, hash): | def _getfile(self, tmpfile, filename, hash): | ||||
| try: | try: | ||||
| chunks = self._get(hash) | chunks = self._get(hash) | ||||
| except urlerr.httperror as e: | except urlerr.httperror as e: | ||||
| # 401s get converted to error.Aborts; everything else is fine being | # 401s get converted to error.Aborts; everything else is fine being | ||||
| # turned into a StoreError | # turned into a StoreError | ||||
| raise basestore.StoreError(filename, hash, self.url, str(e)) | raise basestore.StoreError(filename, hash, self.url, | ||||
| util.forcebytestr(e)) | |||||
| except urlerr.urlerror as e: | except urlerr.urlerror as e: | ||||
| # This usually indicates a connection problem, so don't | # This usually indicates a connection problem, so don't | ||||
| # keep trying with the other files... they will probably | # keep trying with the other files... they will probably | ||||
| # all fail too. | # all fail too. | ||||
| raise error.Abort('%s: %s' % | raise error.Abort('%s: %s' % | ||||
| (util.hidepassword(self.url), e.reason)) | (util.hidepassword(self.url), e.reason)) | ||||
| except IOError as e: | except IOError as e: | ||||
| raise basestore.StoreError(filename, hash, self.url, str(e)) | raise basestore.StoreError(filename, hash, self.url, | ||||
| util.forcebytestr(e)) | |||||
| return lfutil.copyandhash(chunks, tmpfile) | return lfutil.copyandhash(chunks, tmpfile) | ||||
| def _hashesavailablelocally(self, hashes): | def _hashesavailablelocally(self, hashes): | ||||
| existslocallymap = self._lstore.exists(hashes) | existslocallymap = self._lstore.exists(hashes) | ||||
| localhashes = [hash for hash in hashes if existslocallymap[hash]] | localhashes = [hash for hash in hashes if existslocallymap[hash]] | ||||
| return localhashes | return localhashes | ||||