##// END OF EJS Templates
hg: rearrange peer scheme lookup...
Matt Mackall -
r14605:9f1139cf default
parent child Browse files
Show More
@@ -93,6 +93,6 b' def extsetup(ui):'
93 93 and os.path.exists('%s:\\' % scheme)):
94 94 raise util.Abort(_('custom scheme %s:// conflicts with drive '
95 95 'letter %s:\\\n') % (scheme, scheme.upper()))
96 hg._peerschemes[scheme] = ShortRepository(url, scheme, t)
96 hg.peerschemes[scheme] = ShortRepository(url, scheme, t)
97 97
98 98 extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter)
@@ -61,44 +61,7 b' def parseurl(path, branches=None):'
61 61 u.fragment = None
62 62 return str(u), (branch, branches or [])
63 63
64 _reposchemes = {
65 'bundle': bundlerepo,
66 'file': _local,
67 'http': httprepo,
68 'https': httprepo,
69 'ssh': sshrepo,
70 'static-http': statichttprepo,
71 }
72
73 def _repolookup(path):
74 u = util.url(path)
75 scheme = u.scheme or 'file'
76 thing = _reposchemes.get(scheme) or _reposchemes['file']
77 try:
78 return thing(path)
79 except TypeError:
80 return thing
81
82 def islocal(repo):
83 '''return true if repo or path is local'''
84 if isinstance(repo, str):
85 try:
86 return _repolookup(repo).islocal(repo)
87 except AttributeError:
88 return False
89 return repo.local()
90
91 def repository(ui, path='', create=False):
92 """return a repository object for the specified path"""
93 repo = _repolookup(path).instance(ui, path, create)
94 ui = getattr(repo, "ui", ui)
95 for name, module in extensions.extensions():
96 hook = getattr(module, 'reposetup', None)
97 if hook:
98 hook(ui, repo)
99 return repo
100
101 _peerschemes = {
64 peerschemes = {
102 65 'bundle': bundlerepo,
103 66 'file': _local,
104 67 'http': httprepo,
@@ -110,12 +73,31 b" def repository(ui, path='', create=False"
110 73 def _peerlookup(path):
111 74 u = util.url(path)
112 75 scheme = u.scheme or 'file'
113 thing = _peerschemes.get(scheme) or _peerschemes['file']
76 thing = peerschemes.get(scheme) or peerschemes['file']
114 77 try:
115 78 return thing(path)
116 79 except TypeError:
117 80 return thing
118 81
82 def islocal(repo):
83 '''return true if repo or path is local'''
84 if isinstance(repo, str):
85 try:
86 return _peerlookup(repo).islocal(repo)
87 except AttributeError:
88 return False
89 return repo.local()
90
91 def repository(ui, path='', create=False):
92 """return a repository object for the specified path"""
93 repo = _peerlookup(path).instance(ui, path, create)
94 ui = getattr(repo, "ui", ui)
95 for name, module in extensions.extensions():
96 hook = getattr(module, 'reposetup', None)
97 if hook:
98 hook(ui, repo)
99 return repo
100
119 101 def peer(ui, opts, path, create=False):
120 102 '''return a repository peer for the specified path'''
121 103 rui = remoteui(ui, opts)
General Comments 0
You need to be logged in to leave comments. Login now