Show More
@@ -40,8 +40,9 b' You can override a predefined scheme by ' | |||||
40 | same name. |
|
40 | same name. | |
41 | """ |
|
41 | """ | |
42 |
|
42 | |||
43 | import re |
|
43 | import os, re | |
44 | from mercurial import hg, templater |
|
44 | from mercurial import extensions, hg, templater, url as urlmod, util | |
|
45 | from mercurial.i18n import _ | |||
45 |
|
46 | |||
46 |
|
47 | |||
47 | class ShortRepository(object): |
|
48 | class ShortRepository(object): | |
@@ -58,6 +59,7 b' class ShortRepository(object):' | |||||
58 | return '<ShortRepository: %s>' % self.scheme |
|
59 | return '<ShortRepository: %s>' % self.scheme | |
59 |
|
60 | |||
60 | def instance(self, ui, url, create): |
|
61 | def instance(self, ui, url, create): | |
|
62 | # Should this use urlmod.url(), or is manual parsing better? | |||
61 | url = url.split('://', 1)[1] |
|
63 | url = url.split('://', 1)[1] | |
62 | parts = url.split('/', self.parts) |
|
64 | parts = url.split('/', self.parts) | |
63 | if len(parts) > self.parts: |
|
65 | if len(parts) > self.parts: | |
@@ -69,6 +71,12 b' class ShortRepository(object):' | |||||
69 | url = ''.join(self.templater.process(self.url, context)) + tail |
|
71 | url = ''.join(self.templater.process(self.url, context)) + tail | |
70 | return hg._lookup(url).instance(ui, url, create) |
|
72 | return hg._lookup(url).instance(ui, url, create) | |
71 |
|
73 | |||
|
74 | def has_drive_letter(orig, path): | |||
|
75 | for scheme in schemes: | |||
|
76 | if path.startswith(scheme + ':'): | |||
|
77 | return False | |||
|
78 | return orig(path) | |||
|
79 | ||||
72 | schemes = { |
|
80 | schemes = { | |
73 | 'py': 'http://hg.python.org/', |
|
81 | 'py': 'http://hg.python.org/', | |
74 | 'bb': 'https://bitbucket.org/', |
|
82 | 'bb': 'https://bitbucket.org/', | |
@@ -81,4 +89,10 b' def extsetup(ui):' | |||||
81 | schemes.update(dict(ui.configitems('schemes'))) |
|
89 | schemes.update(dict(ui.configitems('schemes'))) | |
82 | t = templater.engine(lambda x: x) |
|
90 | t = templater.engine(lambda x: x) | |
83 | for scheme, url in schemes.items(): |
|
91 | for scheme, url in schemes.items(): | |
|
92 | if (os.name == 'nt' and len(scheme) == 1 and scheme.isalpha() | |||
|
93 | and os.path.exists('%s:\\' % scheme)): | |||
|
94 | raise util.Abort(_('custom scheme %s:// conflicts with drive ' | |||
|
95 | 'letter %s:\\\n') % (scheme, scheme.upper())) | |||
84 | hg.schemes[scheme] = ShortRepository(url, scheme, t) |
|
96 | hg.schemes[scheme] = ShortRepository(url, scheme, t) | |
|
97 | ||||
|
98 | extensions.wrapfunction(urlmod, 'has_drive_letter', has_drive_letter) |
General Comments 0
You need to be logged in to leave comments.
Login now