Changeset View
Changeset View
Standalone View
Standalone View
hgext/largefiles/storefactory.py
# 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. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
import re | import re | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial.pycompat import getattr | from mercurial.pycompat import getattr | ||||
from mercurial import ( | from mercurial import ( | ||||
error, | error, | ||||
hg, | hg, | ||||
util, | util, | ||||
) | ) | ||||
from mercurial.utils import ( | |||||
urlutil, | |||||
) | |||||
from . import ( | from . import ( | ||||
lfutil, | lfutil, | ||||
localstore, | localstore, | ||||
wirestore, | wirestore, | ||||
) | ) | ||||
# During clone this function is passed the src's ui object | # During clone this function is passed the src's ui object | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | def openstore(repo=None, remote=None, put=False, ui=None): | ||||
for classobj in storeproviders: | for classobj in storeproviders: | ||||
try: | try: | ||||
return classobj(ui, repo, remote) | return classobj(ui, repo, remote) | ||||
except lfutil.storeprotonotcapable: | except lfutil.storeprotonotcapable: | ||||
pass | pass | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'%s does not appear to be a largefile store') | _(b'%s does not appear to be a largefile store') | ||||
% util.hidepassword(path) | % urlutil.hidepassword(path) | ||||
) | ) | ||||
_storeprovider = { | _storeprovider = { | ||||
b'file': [localstore.localstore], | b'file': [localstore.localstore], | ||||
b'http': [wirestore.wirestore], | b'http': [wirestore.wirestore], | ||||
b'https': [wirestore.wirestore], | b'https': [wirestore.wirestore], | ||||
b'ssh': [wirestore.wirestore], | b'ssh': [wirestore.wirestore], | ||||
} | } | ||||
_scheme_re = re.compile(br'^([a-zA-Z0-9+-.]+)://') | _scheme_re = re.compile(br'^([a-zA-Z0-9+-.]+)://') | ||||
def getlfile(ui, hash): | def getlfile(ui, hash): | ||||
return util.chunkbuffer(openstore(ui=ui)._get(hash)) | return util.chunkbuffer(openstore(ui=ui)._get(hash)) |