Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hg.py @ 49801:f73f02ef8cb6
peer-or-repo: split the scheme between repo and peer
Some of the scheme will always produce a peer and some will always produce a
repository. So lets use different mapping to reduce the ambiguity.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 29 Nov 2022 21:48:08 +0100 |
parents | 0d5b2e010614 |
children | c37287340c00 |
comparison
equal
deleted
inserted
replaced
49800:0d5b2e010614 | 49801:f73f02ef8cb6 |
---|---|
141 else: | 141 else: |
142 cls = localrepo | 142 cls = localrepo |
143 return cls.instance(ui, path, *args, **kwargs) | 143 return cls.instance(ui, path, *args, **kwargs) |
144 | 144 |
145 | 145 |
146 schemes = { | 146 repo_schemes = { |
147 b'bundle': bundlerepo, | 147 b'bundle': bundlerepo, |
148 b'union': unionrepo, | 148 b'union': unionrepo, |
149 b'file': LocalFactory, | 149 b'file': LocalFactory, |
150 b'static-http': statichttprepo, | |
151 } | |
152 | |
153 peer_schemes = { | |
150 b'http': httppeer, | 154 b'http': httppeer, |
151 b'https': httppeer, | 155 b'https': httppeer, |
152 b'ssh': sshpeer, | 156 b'ssh': sshpeer, |
153 b'static-http': statichttprepo, | |
154 } | 157 } |
155 | 158 |
156 | 159 |
157 def _peerlookup(path): | 160 def _peerlookup(path): |
158 u = urlutil.url(path) | 161 u = urlutil.url(path) |
159 scheme = u.scheme or b'file' | 162 scheme = u.scheme or b'file' |
160 thing = schemes.get(scheme) or schemes[b'file'] | 163 if scheme in peer_schemes: |
161 return thing | 164 return peer_schemes[scheme] |
165 if scheme in repo_schemes: | |
166 return repo_schemes[scheme] | |
167 return LocalFactory | |
162 | 168 |
163 | 169 |
164 def islocal(repo): | 170 def islocal(repo): |
165 '''return true if repo (or path pointing to repo) is local''' | 171 '''return true if repo (or path pointing to repo) is local''' |
166 if isinstance(repo, bytes): | 172 if isinstance(repo, bytes): |