diff --git a/hgext/schemes.py b/hgext/schemes.py --- a/hgext/schemes.py +++ b/hgext/schemes.py @@ -93,6 +93,6 @@ def extsetup(ui): and os.path.exists('%s:\\' % scheme)): raise util.Abort(_('custom scheme %s:// conflicts with drive ' 'letter %s:\\\n') % (scheme, scheme.upper())) - hg._peerschemes[scheme] = ShortRepository(url, scheme, t) + hg.peerschemes[scheme] = ShortRepository(url, scheme, t) extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter) diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -61,44 +61,7 @@ def parseurl(path, branches=None): u.fragment = None return str(u), (branch, branches or []) -_reposchemes = { - 'bundle': bundlerepo, - 'file': _local, - 'http': httprepo, - 'https': httprepo, - 'ssh': sshrepo, - 'static-http': statichttprepo, -} - -def _repolookup(path): - u = util.url(path) - scheme = u.scheme or 'file' - thing = _reposchemes.get(scheme) or _reposchemes['file'] - try: - return thing(path) - except TypeError: - return thing - -def islocal(repo): - '''return true if repo or path is local''' - if isinstance(repo, str): - try: - 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 = _repolookup(path).instance(ui, path, create) - ui = getattr(repo, "ui", ui) - for name, module in extensions.extensions(): - hook = getattr(module, 'reposetup', None) - if hook: - hook(ui, repo) - return repo - -_peerschemes = { +peerschemes = { 'bundle': bundlerepo, 'file': _local, 'http': httprepo, @@ -110,12 +73,31 @@ def repository(ui, path='', create=False def _peerlookup(path): u = util.url(path) scheme = u.scheme or 'file' - thing = _peerschemes.get(scheme) or _peerschemes['file'] + thing = peerschemes.get(scheme) or peerschemes['file'] try: return thing(path) except TypeError: return thing +def islocal(repo): + '''return true if repo or path is local''' + if isinstance(repo, str): + try: + return _peerlookup(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 = _peerlookup(path).instance(ui, path, create) + ui = getattr(repo, "ui", ui) + for name, module in extensions.extensions(): + hook = getattr(module, 'reposetup', None) + if hook: + hook(ui, repo) + return repo + def peer(ui, opts, path, create=False): '''return a repository peer for the specified path''' rui = remoteui(ui, opts)