lfs: make blobstore.remote take a ui object instead of repo

Summary:
A remote blobstore should have nothing to do with a local repo. It only
cares about certain configs. Let's make it so.

This makes the next change cleaner.

Test Plan: Ran all tests.

Reviewers: phillco, #mercurial

Reviewed By: phillco

Differential Revision: https://phabricator.intern.facebook.com/D6698999

Signature: 6698999:1515630172:e759b5dabfe21f141e58e29c8b7cece576105be7
This commit is contained in:
Jun Wu 2018-01-10 16:07:13 -08:00
parent b364d9bb72
commit 4ebf0c5e7d
2 changed files with 9 additions and 10 deletions

View File

@ -114,7 +114,7 @@ def reposetup(ui, repo):
repo.svfs.options['lfsthreshold'] = threshold
repo.svfs.lfslocalblobstore = blobstore.local(repo)
repo.svfs.lfsremoteblobstore = blobstore.remote(repo)
repo.svfs.lfsremoteblobstore = blobstore.remote(repo.ui)
# Push hook
repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)

View File

@ -120,12 +120,11 @@ class local(object):
class _gitlfsremote(object):
def __init__(self, repo, url):
ui = repo.ui
def __init__(self, ui, url):
self.ui = ui
baseurl, authinfo = url.authinfo()
self.baseurl = baseurl.rstrip('/')
useragent = repo.ui.config('experimental', 'lfs.user-agent')
useragent = ui.config('experimental', 'lfs.user-agent')
if not useragent:
useragent = 'mercurial/%s git/2.15.1' % util.version()
self.urlopener = urlmod.opener(ui, authinfo, useragent)
@ -309,7 +308,7 @@ class _gitlfsremote(object):
class _dummyremote(object):
"""Dummy store storing blobs to temp directory."""
def __init__(self, repo, url):
def __init__(self, ui, url):
self.vfs = lfsvfs(url.path)
def writebatch(self, pointers, fromstore):
@ -326,7 +325,7 @@ class _dummyremote(object):
class _nullremote(object):
"""Null store storing blobs to /dev/null."""
def __init__(self, repo, url):
def __init__(self, ui, url):
pass
def writebatch(self, pointers, fromstore):
@ -338,7 +337,7 @@ class _nullremote(object):
class _promptremote(object):
"""Prompt user to set lfs.url when accessed."""
def __init__(self, repo, url):
def __init__(self, ui, url):
pass
def writebatch(self, pointers, fromstore, ui=None):
@ -358,15 +357,15 @@ _storemap = {
None: _promptremote,
}
def remote(repo):
def remote(ui):
"""remotestore factory. return a store in _storemap depending on config"""
defaulturl = ''
url = util.url(repo.ui.config('lfs', 'url', defaulturl))
url = util.url(ui.config('lfs', 'url', defaulturl))
scheme = url.scheme
if scheme not in _storemap:
raise error.Abort(_('lfs: unknown url scheme: %s') % scheme)
return _storemap[scheme](repo, url)
return _storemap[scheme](ui, url)
class LfsRemoteError(error.RevlogError):
pass