[PATCH 2 of 4 V2] lfs: infer the blob store URL from paths.default

Matt Harbison mharbison72 at gmail.com
Wed Apr 11 07:57:56 EDT 2018


> On Apr 11, 2018, at 7:29 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> 
>> On Tue, 10 Apr 2018 16:09:24 -0400, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison at yahoo.com>
>> # Date 1523154140 14400
>> #      Sat Apr 07 22:22:20 2018 -0400
>> # Node ID b784de3b414876f25964778b02e684f9b0a3787f
>> # Parent  473a8954c957945d1642d08eeefc8fe706597b59
>> lfs: infer the blob store URL from paths.default
> 
>> def remote(repo):
>> -    """remotestore factory. return a store in _storemap depending on config"""
>> +    """remotestore factory. return a store in _storemap depending on config
>> +
>> +    If ``lfs.url`` is specified, use that remote endpoint.  Otherwise, try to
>> +    infer the endpoint, based on the remote repository using the same path
>> +    adjustments as git.  As an extension, 'http' is supported as well so that
>> +    ``hg serve`` works out of the box.
>> +
>> +    https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md
>> +    """
>>     url = util.url(repo.ui.config('lfs', 'url') or '')
>> +    if url.scheme is None:
> 
> Nit: I think this should be 'if not url_string_read_from_config'.
> 
>> +        # TODO: investigate 'paths.remote:lfsurl' style path customization,
>> +        # and fall back to inferring from 'paths.remote' if unspecified.
>> +        defaulturl = util.url(repo.ui.config('paths', 'default') or b'')
>> +
>> +        # TODO: support local paths as well.
>> +        # TODO: consider the ssh -> https transformation that git applies
>> +        if defaulturl.scheme in (b'http', b'https'):
>> +            defaulturl.path = defaulturl.path or b'' + b'.git/info/lfs'
> 
> .path might not have trailing '/'.
> 
>> +            url = util.url(bytes(defaulturl))
> 
> Nit: perhaps no need to reparse the url since defaulturl is a url object.

I don’t have the code in front of me, but I think there is an _originalpath member that doesn’t get updated when any of the components do.  It shouldn’t matter with the current code, but I wasn’t sure if that was ok to assume that in the future.

> Can you send a follow up?


More information about the Mercurial-devel mailing list