peer-or-repo: build a repo directly in the `repo` function
We skip the ambiguous _peerorrepo function to explicitly build a repo within
the dedicated function. The peer scheme are therefore no longer considered to
build the object.
--- a/mercurial/hg.py Tue Nov 29 22:04:23 2022 +0100
+++ b/mercurial/hg.py Tue Nov 29 22:21:19 2022 +0100
@@ -231,19 +231,22 @@
createopts=None,
):
"""return a repository object for the specified path"""
- peer = _peerorrepo(
+ scheme = urlutil.url(path).scheme
+ if scheme is None:
+ scheme = b'file'
+ cls = repo_schemes.get(scheme)
+ if cls is None:
+ if scheme in peer_schemes:
+ raise error.Abort(_(b"repository '%s' is not local") % path)
+ cls = LocalFactory
+ repo = cls.instance(
ui,
path,
create,
- presetupfuncs=presetupfuncs,
intents=intents,
createopts=createopts,
)
- repo = peer.local()
- if not repo:
- raise error.Abort(
- _(b"repository '%s' is not local") % (path or peer.url())
- )
+ _setup_repo_or_peer(ui, repo, presetupfuncs=presetupfuncs)
return repo.filtered(b'visible')