Show More
@@ -80,6 +80,15 b' class ShortRepository:' | |||||
80 | def __repr__(self): |
|
80 | def __repr__(self): | |
81 | return b'<ShortRepository: %s>' % self.scheme |
|
81 | return b'<ShortRepository: %s>' % self.scheme | |
82 |
|
82 | |||
|
83 | def make_peer(self, ui, url, *args, **kwargs): | |||
|
84 | url = self.resolve(url) | |||
|
85 | u = urlutil.url(url) | |||
|
86 | scheme = u.scheme or b'file' | |||
|
87 | cls = hg.peer_schemes.get(scheme) | |||
|
88 | if cls is not None: | |||
|
89 | return cls.make_peer(ui, url, *args, **kwargs) | |||
|
90 | return None | |||
|
91 | ||||
83 | def instance(self, ui, url, create, intents=None, createopts=None): |
|
92 | def instance(self, ui, url, create, intents=None, createopts=None): | |
84 | url = self.resolve(url) |
|
93 | url = self.resolve(url) | |
85 | u = urlutil.url(url) |
|
94 | u = urlutil.url(url) |
@@ -168,11 +168,12 b' def islocal(repo):' | |||||
168 | scheme = u.scheme or b'file' |
|
168 | scheme = u.scheme or b'file' | |
169 | if scheme in peer_schemes: |
|
169 | if scheme in peer_schemes: | |
170 | cls = peer_schemes[scheme] |
|
170 | cls = peer_schemes[scheme] | |
|
171 | cls.make_peer # make sure we load the module | |||
171 | elif scheme in repo_schemes: |
|
172 | elif scheme in repo_schemes: | |
172 | cls = repo_schemes[scheme] |
|
173 | cls = repo_schemes[scheme] | |
|
174 | cls.instance # make sure we load the module | |||
173 | else: |
|
175 | else: | |
174 | cls = LocalFactory |
|
176 | cls = LocalFactory | |
175 | cls.instance # make sure we load the module |
|
|||
176 | if util.safehasattr(cls, 'islocal'): |
|
177 | if util.safehasattr(cls, 'islocal'): | |
177 | return cls.islocal(repo) # pytype: disable=module-attr |
|
178 | return cls.islocal(repo) # pytype: disable=module-attr | |
178 | return False |
|
179 | return False | |
@@ -253,7 +254,7 b' def peer(uiorrepo, opts, path, create=Fa' | |||||
253 | scheme = urlutil.url(path).scheme |
|
254 | scheme = urlutil.url(path).scheme | |
254 | if scheme in peer_schemes: |
|
255 | if scheme in peer_schemes: | |
255 | cls = peer_schemes[scheme] |
|
256 | cls = peer_schemes[scheme] | |
256 |
peer = cls. |
|
257 | peer = cls.make_peer( | |
257 | rui, |
|
258 | rui, | |
258 | path, |
|
259 | path, | |
259 | create, |
|
260 | create, |
@@ -621,7 +621,7 b' def makepeer(ui, path, opener=None, requ' | |||||
621 | ) |
|
621 | ) | |
622 |
|
622 | |||
623 |
|
623 | |||
624 |
def |
|
624 | def make_peer(ui, path, create, intents=None, createopts=None): | |
625 | if create: |
|
625 | if create: | |
626 | raise error.Abort(_(b'cannot create new http repository')) |
|
626 | raise error.Abort(_(b'cannot create new http repository')) | |
627 | try: |
|
627 | try: | |
@@ -635,7 +635,7 b' def instance(ui, path, create, intents=N' | |||||
635 | return inst |
|
635 | return inst | |
636 | except error.RepoError as httpexception: |
|
636 | except error.RepoError as httpexception: | |
637 | try: |
|
637 | try: | |
638 |
r = statichttprepo. |
|
638 | r = statichttprepo.make_peer(ui, b"static-" + path, create) | |
639 | ui.note(_(b'(falling back to static-http)\n')) |
|
639 | ui.note(_(b'(falling back to static-http)\n')) | |
640 | return r |
|
640 | return r | |
641 | except error.RepoError: |
|
641 | except error.RepoError: |
@@ -607,7 +607,7 b' def makepeer(ui, path, proc, stdin, stdo' | |||||
607 | ) |
|
607 | ) | |
608 |
|
608 | |||
609 |
|
609 | |||
610 |
def |
|
610 | def make_peer(ui, path, create, intents=None, createopts=None): | |
611 | """Create an SSH peer. |
|
611 | """Create an SSH peer. | |
612 |
|
612 | |||
613 | The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. |
|
613 | The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. |
@@ -259,7 +259,7 b' class statichttprepository(' | |||||
259 | pass # statichttprepository are read only |
|
259 | pass # statichttprepository are read only | |
260 |
|
260 | |||
261 |
|
261 | |||
262 |
def |
|
262 | def make_peer(ui, path, create, intents=None, createopts=None): | |
263 | if create: |
|
263 | if create: | |
264 | raise error.Abort(_(b'cannot create new static-http repository')) |
|
264 | raise error.Abort(_(b'cannot create new static-http repository')) | |
265 | return statichttprepository(ui, path[7:]).peer() |
|
265 | return statichttprepository(ui, path[7:]).peer() |
General Comments 0
You need to be logged in to leave comments.
Login now