--- a/hgext/schemes.py Sun Oct 06 09:45:02 2019 -0400
+++ b/hgext/schemes.py Sun Oct 06 09:48:39 2019 -0400
@@ -61,7 +61,7 @@
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
-testedwith = 'ships-with-hg-core'
+testedwith = b'ships-with-hg-core'
_partre = re.compile(br'\{(\d+)\}')
@@ -77,7 +77,7 @@
self.parts = 0
def __repr__(self):
- return '<ShortRepository: %s>' % self.scheme
+ return b'<ShortRepository: %s>' % self.scheme
def instance(self, ui, url, create, intents=None, createopts=None):
url = self.resolve(url)
@@ -88,60 +88,63 @@
def resolve(self, url):
# Should this use the util.url class, or is manual parsing better?
try:
- url = url.split('://', 1)[1]
+ url = url.split(b'://', 1)[1]
except IndexError:
- raise error.Abort(_("no '://' in scheme url '%s'") % url)
- parts = url.split('/', self.parts)
+ raise error.Abort(_(b"no '://' in scheme url '%s'") % url)
+ parts = url.split(b'/', self.parts)
if len(parts) > self.parts:
tail = parts[-1]
parts = parts[:-1]
else:
- tail = ''
- context = dict(('%d' % (i + 1), v) for i, v in enumerate(parts))
- return ''.join(self.templater.process(self.url, context)) + tail
+ tail = b''
+ context = dict((b'%d' % (i + 1), v) for i, v in enumerate(parts))
+ return b''.join(self.templater.process(self.url, context)) + tail
def hasdriveletter(orig, path):
if path:
for scheme in schemes:
- if path.startswith(scheme + ':'):
+ if path.startswith(scheme + b':'):
return False
return orig(path)
schemes = {
- 'py': 'http://hg.python.org/',
- 'bb': 'https://bitbucket.org/',
- 'bb+ssh': 'ssh://hg@bitbucket.org/',
- 'gcode': 'https://{1}.googlecode.com/hg/',
- 'kiln': 'https://{1}.kilnhg.com/Repo/',
+ b'py': b'http://hg.python.org/',
+ b'bb': b'https://bitbucket.org/',
+ b'bb+ssh': b'ssh://hg@bitbucket.org/',
+ b'gcode': b'https://{1}.googlecode.com/hg/',
+ b'kiln': b'https://{1}.kilnhg.com/Repo/',
}
def extsetup(ui):
- schemes.update(dict(ui.configitems('schemes')))
+ schemes.update(dict(ui.configitems(b'schemes')))
t = templater.engine(templater.parse)
for scheme, url in schemes.items():
if (
pycompat.iswindows
and len(scheme) == 1
and scheme.isalpha()
- and os.path.exists('%s:\\' % scheme)
+ and os.path.exists(b'%s:\\' % scheme)
):
raise error.Abort(
- _('custom scheme %s:// conflicts with drive ' 'letter %s:\\\n')
+ _(
+ b'custom scheme %s:// conflicts with drive '
+ b'letter %s:\\\n'
+ )
% (scheme, scheme.upper())
)
hg.schemes[scheme] = ShortRepository(url, scheme, t)
- extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter)
+ extensions.wrapfunction(util, b'hasdriveletter', hasdriveletter)
-@command('debugexpandscheme', norepo=True)
+@command(b'debugexpandscheme', norepo=True)
def expandscheme(ui, url, **opts):
"""given a repo path, provide the scheme-expanded path
"""
repo = hg._peerlookup(url)
if isinstance(repo, ShortRepository):
url = repo.resolve(url)
- ui.write(url + '\n')
+ ui.write(url + b'\n')