Show More
@@ -93,6 +93,6 b' def extsetup(ui):' | |||||
93 | and os.path.exists('%s:\\' % scheme)): |
|
93 | and os.path.exists('%s:\\' % scheme)): | |
94 | raise util.Abort(_('custom scheme %s:// conflicts with drive ' |
|
94 | raise util.Abort(_('custom scheme %s:// conflicts with drive ' | |
95 | 'letter %s:\\\n') % (scheme, scheme.upper())) |
|
95 | 'letter %s:\\\n') % (scheme, scheme.upper())) | |
96 |
hg. |
|
96 | hg.peerschemes[scheme] = ShortRepository(url, scheme, t) | |
97 |
|
97 | |||
98 | extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter) |
|
98 | extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter) |
@@ -61,44 +61,7 b' def parseurl(path, branches=None):' | |||||
61 | u.fragment = None |
|
61 | u.fragment = None | |
62 | return str(u), (branch, branches or []) |
|
62 | return str(u), (branch, branches or []) | |
63 |
|
63 | |||
64 |
|
|
64 | peerschemes = { | |
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 = { |
|
|||
102 | 'bundle': bundlerepo, |
|
65 | 'bundle': bundlerepo, | |
103 | 'file': _local, |
|
66 | 'file': _local, | |
104 | 'http': httprepo, |
|
67 | 'http': httprepo, | |
@@ -110,12 +73,31 b" def repository(ui, path='', create=False" | |||||
110 | def _peerlookup(path): |
|
73 | def _peerlookup(path): | |
111 | u = util.url(path) |
|
74 | u = util.url(path) | |
112 | scheme = u.scheme or 'file' |
|
75 | scheme = u.scheme or 'file' | |
113 |
thing = |
|
76 | thing = peerschemes.get(scheme) or peerschemes['file'] | |
114 | try: |
|
77 | try: | |
115 | return thing(path) |
|
78 | return thing(path) | |
116 | except TypeError: |
|
79 | except TypeError: | |
117 | return thing |
|
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 | def peer(ui, opts, path, create=False): |
|
101 | def peer(ui, opts, path, create=False): | |
120 | '''return a repository peer for the specified path''' |
|
102 | '''return a repository peer for the specified path''' | |
121 | rui = remoteui(ui, opts) |
|
103 | rui = remoteui(ui, opts) |
General Comments 0
You need to be logged in to leave comments.
Login now