Changeset View
Changeset View
Standalone View
Standalone View
hgext/largefiles/remotestore.py
Show All 9 Lines | |||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial import ( | from mercurial import ( | ||||
error, | error, | ||||
pycompat, | pycompat, | ||||
util, | util, | ||||
) | ) | ||||
from mercurial.utils import stringutil | from mercurial.utils import ( | ||||
stringutil, | |||||
urlutil, | |||||
) | |||||
from . import ( | from . import ( | ||||
basestore, | basestore, | ||||
lfutil, | lfutil, | ||||
localstore, | localstore, | ||||
) | ) | ||||
urlerr = util.urlerr | urlerr = util.urlerr | ||||
urlreq = util.urlreq | urlreq = util.urlreq | ||||
class remotestore(basestore.basestore): | class remotestore(basestore.basestore): | ||||
'''a largefile store accessed over a network''' | '''a largefile store accessed over a network''' | ||||
def __init__(self, ui, repo, url): | def __init__(self, ui, repo, url): | ||||
super(remotestore, self).__init__(ui, repo, url) | super(remotestore, self).__init__(ui, repo, url) | ||||
self._lstore = None | self._lstore = None | ||||
if repo is not None: | if repo is not None: | ||||
self._lstore = localstore.localstore(self.ui, self.repo, self.repo) | self._lstore = localstore.localstore(self.ui, self.repo, self.repo) | ||||
def put(self, source, hash): | def put(self, source, hash): | ||||
if self.sendfile(source, hash): | if self.sendfile(source, hash): | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'remotestore: could not put %s to remote store %s') | _(b'remotestore: could not put %s to remote store %s') | ||||
% (source, util.hidepassword(self.url)) | % (source, urlutil.hidepassword(self.url)) | ||||
) | ) | ||||
self.ui.debug( | self.ui.debug( | ||||
_(b'remotestore: put %s to remote store %s\n') | _(b'remotestore: put %s to remote store %s\n') | ||||
% (source, util.hidepassword(self.url)) | % (source, urlutil.hidepassword(self.url)) | ||||
) | ) | ||||
def exists(self, hashes): | def exists(self, hashes): | ||||
return { | return { | ||||
h: s == 0 | h: s == 0 | ||||
for (h, s) in pycompat.iteritems( | for (h, s) in pycompat.iteritems( | ||||
self._stat(hashes) | self._stat(hashes) | ||||
) # dict-from-generator | ) # dict-from-generator | ||||
Show All 19 Lines | def _getfile(self, tmpfile, filename, hash): | ||||
raise basestore.StoreError( | raise basestore.StoreError( | ||||
filename, hash, self.url, stringutil.forcebytestr(e) | filename, hash, self.url, stringutil.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( | raise error.Abort( | ||||
b'%s: %s' % (util.hidepassword(self.url), e.reason) | b'%s: %s' % (urlutil.hidepassword(self.url), e.reason) | ||||
) | ) | ||||
except IOError as e: | except IOError as e: | ||||
raise basestore.StoreError( | raise basestore.StoreError( | ||||
filename, hash, self.url, stringutil.forcebytestr(e) | filename, hash, self.url, stringutil.forcebytestr(e) | ||||
) | ) | ||||
return lfutil.copyandhash(chunks, tmpfile) | return lfutil.copyandhash(chunks, tmpfile) | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |