--- a/hgext/schemes.py Sat Jun 11 14:40:25 2011 +0200
+++ b/hgext/schemes.py Sat Jun 11 14:14:52 2011 -0500
@@ -69,7 +69,7 @@
tail = ''
context = dict((str(i + 1), v) for i, v in enumerate(parts))
url = ''.join(self.templater.process(self.url, context)) + tail
- return hg._lookup(url).instance(ui, url, create)
+ return hg._peerlookup(url).instance(ui, url, create)
def hasdriveletter(orig, path):
for scheme in schemes:
@@ -93,6 +93,6 @@
and os.path.exists('%s:\\' % scheme)):
raise util.Abort(_('custom scheme %s:// conflicts with drive '
'letter %s:\\\n') % (scheme, scheme.upper()))
- hg.schemes[scheme] = ShortRepository(url, scheme, t)
+ hg._peerschemes[scheme] = ShortRepository(url, scheme, t)
extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter)
--- a/mercurial/hg.py Sat Jun 11 14:40:25 2011 +0200
+++ b/mercurial/hg.py Sat Jun 11 14:14:52 2011 -0500
@@ -61,7 +61,7 @@
u.fragment = None
return str(u), (branch, branches or [])
-schemes = {
+_reposchemes = {
'bundle': bundlerepo,
'file': _local,
'http': httprepo,
@@ -70,10 +70,10 @@
'static-http': statichttprepo,
}
-def _lookup(path):
+def _repolookup(path):
u = util.url(path)
scheme = u.scheme or 'file'
- thing = schemes.get(scheme) or schemes['file']
+ thing = _reposchemes.get(scheme) or _reposchemes['file']
try:
return thing(path)
except TypeError:
@@ -83,14 +83,14 @@
'''return true if repo or path is local'''
if isinstance(repo, str):
try:
- return _lookup(repo).islocal(repo)
+ return _repolookup(repo).islocal(repo)
except AttributeError:
return False
return repo.local()
def repository(ui, path='', create=False):
"""return a repository object for the specified path"""
- repo = _lookup(path).instance(ui, path, create)
+ repo = _repolookup(path).instance(ui, path, create)
ui = getattr(repo, "ui", ui)
for name, module in extensions.extensions():
hook = getattr(module, 'reposetup', None)
@@ -98,10 +98,28 @@
hook(ui, repo)
return repo
+_peerschemes = {
+ 'bundle': bundlerepo,
+ 'file': _local,
+ 'http': httprepo,
+ 'https': httprepo,
+ 'ssh': sshrepo,
+ 'static-http': statichttprepo,
+}
+
+def _peerlookup(path):
+ u = util.url(path)
+ scheme = u.scheme or 'file'
+ thing = _peerschemes.get(scheme) or _peerschemes['file']
+ try:
+ return thing(path)
+ except TypeError:
+ return thing
+
def peer(ui, opts, path, create=False):
'''return a repository peer for the specified path'''
rui = remoteui(ui, opts)
- return _lookup(path).instance(rui, path, create)
+ return _peerlookup(path).instance(rui, path, create)
def defaultdest(source):
'''return default destination of clone if none is given'''