Mercurial > hg-stable
changeset 37563:be1cc65bdb1c
lfs: infer the blob store URL from an explicit pull source
I don't see any easier way to do this because the update part of `hg pull -u`
happens outside exchange.pull(), and commands.postincoming() doesn't take a
path. So (ab)use the mechanism used by subrepos to redirect where subrepos are
pulled from when an explicit path is given. As a bonus, this should allow lfs
blobs to be pulled into a subrepo when it is checked out.
An explicit push path can be handled within exchange.push(). That can be done
next, outside of this dirty hack.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 08 Apr 2018 01:23:39 -0400 |
parents | e5cd8d1a094d |
children | 31a4ea773369 |
files | hgext/lfs/blobstore.py tests/test-lfs-serve.t |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Wed Apr 11 17:29:55 2018 -0400 +++ b/hgext/lfs/blobstore.py Sun Apr 08 01:23:39 2018 -0400 @@ -541,9 +541,15 @@ """ url = util.url(repo.ui.config('lfs', 'url') or '') if url.scheme is None: - # 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'') + if 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) + 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'') # TODO: support local paths as well. # TODO: consider the ssh -> https transformation that git applies
--- a/tests/test-lfs-serve.t Wed Apr 11 17:29:55 2018 -0400 +++ b/tests/test-lfs-serve.t Sun Apr 08 01:23:39 2018 -0400 @@ -253,7 +253,26 @@ $TESTTMP/server/.hg/requires:lfs $ hg init $TESTTMP/client6_pull - $ hg -R $TESTTMP/client6_pull pull -q http://localhost:$HGPORT + $ hg -R $TESTTMP/client6_pull pull -u -v http://localhost:$HGPORT + pulling from http://localhost:$HGPORT/ + requesting all changes + adding changesets + adding manifests + adding file changes + added 6 changesets with 5 changes to 5 files (+1 heads) + calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs + new changesets d437e1d24fbd:d3b84d50eacb + resolving manifests + lfs: assuming remote store: http://localhost:$HGPORT/.git/info/lfs + lfs: downloading a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de (25 bytes) + lfs: processed: a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de + getting lfs2.txt + lfs: found a82f1c5cea0d40e3bb3a849686bb4e6ae47ca27e614de55c1ed0325698ef68de in the local lfs store + getting nonlfs2.txt + getting nonlfs3.txt + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + updated to "d3b84d50eacb: lfs file with lfs client" + 1 other heads for branch "default" $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES $TESTTMP/client6_pull/.hg/requires:lfs $TESTTMP/server/.hg/requires:lfs