From patchwork Wed Apr 11 23:31:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 4, V3] lfs: handle paths that don't end with '/' when inferring the blob store From: Matt Harbison X-Patchwork-Id: 30749 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Wed, 11 Apr 2018 19:31:45 -0400 # HG changeset patch # User Matt Harbison # Date 1523485409 14400 # Wed Apr 11 18:23:29 2018 -0400 # Node ID cf37bf9b296f3b9f4f248f0f8bf3deb563033b11 # Parent b6cfe8dcd4bb32aa963967eff4287a4643c850de lfs: handle paths that don't end with '/' when inferring the blob store While here, I also checked the lfs.url config directly instead of testing the scheme, as requested by Yuya. diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py --- a/hgext/lfs/blobstore.py +++ b/hgext/lfs/blobstore.py @@ -539,23 +539,28 @@ def remote(repo, remote=None): 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: + lfsurl = repo.ui.config('lfs', 'url') + url = util.url(lfsurl or '') + if lfsurl is None: if remote: - defaulturl = util.url(remote) + path = remote elif util.safehasattr(repo, '_subtoppath'): # The pull command sets this during the optional update phase, which # tells exactly where the pull originated, whether 'paths.default' # or explicit. - defaulturl = util.url(repo._subtoppath) + path = repo._subtoppath else: # 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'') + path = repo.ui.config('paths', 'default') or '' + + defaulturl = util.url(path) # TODO: support local paths as well. # TODO: consider the ssh -> https transformation that git applies if defaulturl.scheme in (b'http', b'https'): + if defaulturl.path and defaulturl.path[:-1] != b'/': + defaulturl.path += b'/' defaulturl.path = defaulturl.path or b'' + b'.git/info/lfs' url = util.url(bytes(defaulturl))