Changeset View
Changeset View
Standalone View
Standalone View
hgext/largefiles/basestore.py
# Copyright 2009-2010 Gregory P. Ward | # Copyright 2009-2010 Gregory P. Ward | ||||
# Copyright 2009-2010 Intelerad Medical Systems Incorporated | # Copyright 2009-2010 Intelerad Medical Systems Incorporated | ||||
# Copyright 2010-2011 Fog Creek Software | # Copyright 2010-2011 Fog Creek Software | ||||
# Copyright 2010-2011 Unity Technologies | # Copyright 2010-2011 Unity Technologies | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
'''base class for store implementations and store-related utility code''' | '''base class for store implementations and store-related utility code''' | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial import node, util | from mercurial import node, util | ||||
from mercurial.utils import ( | |||||
urlutil, | |||||
) | |||||
from . import lfutil | from . import lfutil | ||||
class StoreError(Exception): | class StoreError(Exception): | ||||
"""Raised when there is a problem getting files from or putting | """Raised when there is a problem getting files from or putting | ||||
files to a central store.""" | files to a central store.""" | ||||
def __init__(self, filename, hash, url, detail): | def __init__(self, filename, hash, url, detail): | ||||
self.filename = filename | self.filename = filename | ||||
self.hash = hash | self.hash = hash | ||||
self.url = url | self.url = url | ||||
self.detail = detail | self.detail = detail | ||||
def longmessage(self): | def longmessage(self): | ||||
return _(b"error getting id %s from url %s for file %s: %s\n") % ( | return _(b"error getting id %s from url %s for file %s: %s\n") % ( | ||||
self.hash, | self.hash, | ||||
util.hidepassword(self.url), | urlutil.hidepassword(self.url), | ||||
self.filename, | self.filename, | ||||
self.detail, | self.detail, | ||||
) | ) | ||||
def __str__(self): | def __str__(self): | ||||
return b"%s: %s" % (util.hidepassword(self.url), self.detail) | return b"%s: %s" % (urlutil.hidepassword(self.url), self.detail) | ||||
class basestore(object): | class basestore(object): | ||||
def __init__(self, ui, repo, url): | def __init__(self, ui, repo, url): | ||||
self.ui = ui | self.ui = ui | ||||
self.repo = repo | self.repo = repo | ||||
self.url = url | self.url = url | ||||
Show All 27 Lines | def get(self, files): | ||||
for filename, hash in files: | for filename, hash in files: | ||||
progress.update(at) | progress.update(at) | ||||
at += 1 | at += 1 | ||||
ui.note(_(b'getting %s:%s\n') % (filename, hash)) | ui.note(_(b'getting %s:%s\n') % (filename, hash)) | ||||
if not available.get(hash): | if not available.get(hash): | ||||
ui.warn( | ui.warn( | ||||
_(b'%s: largefile %s not available from %s\n') | _(b'%s: largefile %s not available from %s\n') | ||||
% (filename, hash, util.hidepassword(self.url)) | % (filename, hash, urlutil.hidepassword(self.url)) | ||||
) | ) | ||||
missing.append(filename) | missing.append(filename) | ||||
continue | continue | ||||
if self._gethash(filename, hash): | if self._gethash(filename, hash): | ||||
success.append((filename, hash)) | success.append((filename, hash)) | ||||
else: | else: | ||||
missing.append(filename) | missing.append(filename) | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |