155 return url.open(ui, path) |
155 return url.open(ui, path) |
156 |
156 |
157 # a list of (ui, repo) functions called for wire peer initialization |
157 # a list of (ui, repo) functions called for wire peer initialization |
158 wirepeersetupfuncs = [] |
158 wirepeersetupfuncs = [] |
159 |
159 |
160 def _peerorrepo(ui, path, create=False, presetupfuncs=None): |
160 def _peerorrepo(ui, path, create=False, presetupfuncs=None, |
|
161 intents=None): |
161 """return a repository object for the specified path""" |
162 """return a repository object for the specified path""" |
162 obj = _peerlookup(path).instance(ui, path, create) |
163 obj = _peerlookup(path).instance(ui, path, create, intents=intents) |
163 ui = getattr(obj, "ui", ui) |
164 ui = getattr(obj, "ui", ui) |
164 for f in presetupfuncs or []: |
165 for f in presetupfuncs or []: |
165 f(ui, obj) |
166 f(ui, obj) |
166 for name, module in extensions.extensions(ui): |
167 for name, module in extensions.extensions(ui): |
167 hook = getattr(module, 'reposetup', None) |
168 hook = getattr(module, 'reposetup', None) |
170 if not obj.local(): |
171 if not obj.local(): |
171 for f in wirepeersetupfuncs: |
172 for f in wirepeersetupfuncs: |
172 f(ui, obj) |
173 f(ui, obj) |
173 return obj |
174 return obj |
174 |
175 |
175 def repository(ui, path='', create=False, presetupfuncs=None): |
176 def repository(ui, path='', create=False, presetupfuncs=None, intents=None): |
176 """return a repository object for the specified path""" |
177 """return a repository object for the specified path""" |
177 peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs) |
178 peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs, |
|
179 intents=intents) |
178 repo = peer.local() |
180 repo = peer.local() |
179 if not repo: |
181 if not repo: |
180 raise error.Abort(_("repository '%s' is not local") % |
182 raise error.Abort(_("repository '%s' is not local") % |
181 (path or peer.url())) |
183 (path or peer.url())) |
182 return repo.filtered('visible') |
184 return repo.filtered('visible') |
183 |
185 |
184 def peer(uiorrepo, opts, path, create=False): |
186 def peer(uiorrepo, opts, path, create=False, intents=None): |
185 '''return a repository peer for the specified path''' |
187 '''return a repository peer for the specified path''' |
186 rui = remoteui(uiorrepo, opts) |
188 rui = remoteui(uiorrepo, opts) |
187 return _peerorrepo(rui, path, create).peer() |
189 return _peerorrepo(rui, path, create, intents=intents).peer() |
188 |
190 |
189 def defaultdest(source): |
191 def defaultdest(source): |
190 '''return default destination of clone if none is given |
192 '''return default destination of clone if none is given |
191 |
193 |
192 >>> defaultdest(b'foo') |
194 >>> defaultdest(b'foo') |