Mercurial > public > mercurial-scm > hg
comparison hgext/schemes.py @ 49688: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 | 642e31cb55f0 |
children | 1863584f2fba |
comparison
equal
deleted
inserted
replaced
49687:0d5b2e010614 | 49688:f73f02ef8cb6 |
---|---|
134 b'custom scheme %s:// conflicts with drive ' | 134 b'custom scheme %s:// conflicts with drive ' |
135 b'letter %s:\\\n' | 135 b'letter %s:\\\n' |
136 ) | 136 ) |
137 % (scheme, scheme.upper()) | 137 % (scheme, scheme.upper()) |
138 ) | 138 ) |
139 hg.schemes[scheme] = ShortRepository(url, scheme, t) | 139 url_scheme = urlutil.url(url).scheme |
140 if url_scheme in hg.peer_schemes: | |
141 hg.peer_schemes[scheme] = ShortRepository(url, scheme, t) | |
142 else: | |
143 hg.repo_schemes[scheme] = ShortRepository(url, scheme, t) | |
140 | 144 |
141 extensions.wrapfunction(urlutil, b'hasdriveletter', hasdriveletter) | 145 extensions.wrapfunction(urlutil, b'hasdriveletter', hasdriveletter) |
142 | 146 |
143 | 147 |
144 @command(b'debugexpandscheme', norepo=True) | 148 @command(b'debugexpandscheme', norepo=True) |
145 def expandscheme(ui, url, **opts): | 149 def expandscheme(ui, url, **opts): |
146 """given a repo path, provide the scheme-expanded path""" | 150 """given a repo path, provide the scheme-expanded path""" |
147 repo = hg._peerlookup(url) | 151 scheme = urlutil.url(url).scheme |
148 if isinstance(repo, ShortRepository): | 152 if scheme in hg.peer_schemes: |
149 url = repo.resolve(url) | 153 cls = hg.peer_schemes[scheme] |
154 else: | |
155 cls = hg.repo_schemes.get(scheme) | |
156 if cls is not None and isinstance(cls, ShortRepository): | |
157 url = cls.resolve(url) | |
150 ui.write(url + b'\n') | 158 ui.write(url + b'\n') |