# HG changeset patch # User Pierre-Yves David # Date 2022-12-02 17:04:51 # Node ID f075a9463ee7a55ef2c3ca51c292b5ed8ab62148 # Parent be3fcd9e5e52e6b9bf1243a3c782592dbe9c561a peer: use a dedicated name for the `peer` constructor We want to change the argument it takes, so we rather make them different function. diff --git a/hgext/schemes.py b/hgext/schemes.py --- a/hgext/schemes.py +++ b/hgext/schemes.py @@ -80,6 +80,15 @@ class ShortRepository: def __repr__(self): return b'' % self.scheme + def make_peer(self, ui, url, *args, **kwargs): + url = self.resolve(url) + u = urlutil.url(url) + scheme = u.scheme or b'file' + cls = hg.peer_schemes.get(scheme) + if cls is not None: + return cls.make_peer(ui, url, *args, **kwargs) + return None + def instance(self, ui, url, create, intents=None, createopts=None): url = self.resolve(url) u = urlutil.url(url) diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -168,11 +168,12 @@ def islocal(repo): scheme = u.scheme or b'file' if scheme in peer_schemes: cls = peer_schemes[scheme] + cls.make_peer # make sure we load the module elif scheme in repo_schemes: cls = repo_schemes[scheme] + cls.instance # make sure we load the module else: cls = LocalFactory - cls.instance # make sure we load the module if util.safehasattr(cls, 'islocal'): return cls.islocal(repo) # pytype: disable=module-attr return False @@ -253,7 +254,7 @@ def peer(uiorrepo, opts, path, create=Fa scheme = urlutil.url(path).scheme if scheme in peer_schemes: cls = peer_schemes[scheme] - peer = cls.instance( + peer = cls.make_peer( rui, path, create, diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -621,7 +621,7 @@ def makepeer(ui, path, opener=None, requ ) -def instance(ui, path, create, intents=None, createopts=None): +def make_peer(ui, path, create, intents=None, createopts=None): if create: raise error.Abort(_(b'cannot create new http repository')) try: @@ -635,7 +635,7 @@ def instance(ui, path, create, intents=N return inst except error.RepoError as httpexception: try: - r = statichttprepo.instance(ui, b"static-" + path, create) + r = statichttprepo.make_peer(ui, b"static-" + path, create) ui.note(_(b'(falling back to static-http)\n')) return r except error.RepoError: diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -607,7 +607,7 @@ def makepeer(ui, path, proc, stdin, stdo ) -def instance(ui, path, create, intents=None, createopts=None): +def make_peer(ui, path, create, intents=None, createopts=None): """Create an SSH peer. The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -259,7 +259,7 @@ class statichttprepository( pass # statichttprepository are read only -def instance(ui, path, create, intents=None, createopts=None): +def make_peer(ui, path, create, intents=None, createopts=None): if create: raise error.Abort(_(b'cannot create new static-http repository')) return statichttprepository(ui, path[7:]).peer()