Mercurial > hg
comparison hgext/lfs/blobstore.py @ 37564:31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Unlike pull, the blobs are uploaded within the exchange.push() window, so simply
wrap it and swap in a properly configured remote store. The '_subtoppath' field
shouldn't be available during this window, but give the passed path priority for
clarity.
At one point I hit an AttributeError in one of the convert tests when trying to
save the original remote blobstore when the swap was run unconditionally. I
wrapped it in a util.safehasattr(), but then today I wasn't able to reproduce
it. But now the whole thing is tucked under the requirement guard because
without the requirement, there are no blobs in the repo, even if the extension
is loaded.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 08 Apr 2018 14:22:12 -0400 |
parents | be1cc65bdb1c |
children | 9c7a25ef5b49 |
comparison
equal
deleted
inserted
replaced
37563:be1cc65bdb1c | 37564:31a4ea773369 |
---|---|
527 realoid = hashlib.sha256(content).hexdigest() | 527 realoid = hashlib.sha256(content).hexdigest() |
528 if realoid != oid: | 528 if realoid != oid: |
529 raise error.Abort(_('detected corrupt lfs object: %s') % oid, | 529 raise error.Abort(_('detected corrupt lfs object: %s') % oid, |
530 hint=_('run hg verify')) | 530 hint=_('run hg verify')) |
531 | 531 |
532 def remote(repo): | 532 def remote(repo, remote=None): |
533 """remotestore factory. return a store in _storemap depending on config | 533 """remotestore factory. return a store in _storemap depending on config |
534 | 534 |
535 If ``lfs.url`` is specified, use that remote endpoint. Otherwise, try to | 535 If ``lfs.url`` is specified, use that remote endpoint. Otherwise, try to |
536 infer the endpoint, based on the remote repository using the same path | 536 infer the endpoint, based on the remote repository using the same path |
537 adjustments as git. As an extension, 'http' is supported as well so that | 537 adjustments as git. As an extension, 'http' is supported as well so that |
539 | 539 |
540 https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md | 540 https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md |
541 """ | 541 """ |
542 url = util.url(repo.ui.config('lfs', 'url') or '') | 542 url = util.url(repo.ui.config('lfs', 'url') or '') |
543 if url.scheme is None: | 543 if url.scheme is None: |
544 if util.safehasattr(repo, '_subtoppath'): | 544 if remote: |
545 defaulturl = util.url(remote) | |
546 elif util.safehasattr(repo, '_subtoppath'): | |
545 # The pull command sets this during the optional update phase, which | 547 # The pull command sets this during the optional update phase, which |
546 # tells exactly where the pull originated, whether 'paths.default' | 548 # tells exactly where the pull originated, whether 'paths.default' |
547 # or explicit. | 549 # or explicit. |
548 defaulturl = util.url(repo._subtoppath) | 550 defaulturl = util.url(repo._subtoppath) |
549 else: | 551 else: |