##// END OF EJS Templates
path: introduce a `path://` syntax to reference other path name...
marmoute -
r47582:83b0a5c0 default
parent child Browse files
Show More
@@ -2197,6 +2197,9 b' class paths(dict):'
2197 2197 loc, sub_opts = ui.configsuboptions(b'paths', name)
2198 2198 self[name] = path(ui, name, rawloc=loc, suboptions=sub_opts)
2199 2199
2200 for name, p in sorted(self.items()):
2201 p.chain_path(ui, self)
2202
2200 2203 def getpath(self, ui, name, default=None):
2201 2204 """Return a ``path`` from a string, falling back to default.
2202 2205
@@ -2331,6 +2334,22 b' class path(object):'
2331 2334
2332 2335 self._apply_suboptions(ui, sub_opts)
2333 2336
2337 def chain_path(self, ui, paths):
2338 if self.url.scheme == b'path':
2339 assert self.url.path is None
2340 subpath = paths[self.url.host]
2341 self.url = subpath.url
2342 self.rawloc = subpath.rawloc
2343 self.loc = subpath.loc
2344 if self.branch is None:
2345 self.branch = subpath.branch
2346 else:
2347 base = self.rawloc.rsplit(b'#', 1)[0]
2348 self.rawloc = b'%s#%s' % (base, self.branch)
2349 suboptions = subpath._all_sub_opts.copy()
2350 suboptions.update(self._own_sub_opts)
2351 self._apply_suboptions(ui, suboptions)
2352
2334 2353 def _validate_path(self):
2335 2354 # When given a raw location but not a symbolic name, validate the
2336 2355 # location is valid.
@@ -211,3 +211,126 b" unknown sub-options aren't displayed"
211 211 000000000000
212 212
213 213 $ cd ..
214
215 Testing path referencing other paths
216 ====================================
217
218 basic setup
219 -----------
220
221 $ ls -1
222 a
223 b
224 gpath1
225 suboptions
226 $ hg init chained_path
227 $ cd chained_path
228 $ cat << EOF > .hg/hgrc
229 > [paths]
230 > default=../a
231 > other_default=path://default
232 > path_with_branch=../branchy#foo
233 > other_branch=path://path_with_branch
234 > other_branched=path://path_with_branch#default
235 > pushdest=../push-dest
236 > pushdest:pushrev=default
237 > pushdest2=path://pushdest
238 > pushdest-overwrite=path://pushdest
239 > pushdest-overwrite:pushrev=foo
240 > EOF
241
242 $ hg init ../branchy
243 $ hg init ../push-dest
244 $ hg debugbuilddag -R ../branchy '.:base+3<base@foo+5'
245 $ hg log -G -T '{branch}\n' -R ../branchy
246 o foo
247 |
248 o foo
249 |
250 o foo
251 |
252 o foo
253 |
254 o foo
255 |
256 | o default
257 | |
258 | o default
259 | |
260 | o default
261 |/
262 o default
263
264
265 $ hg paths
266 default = $TESTTMP/a
267 gpath1 = http://hg.example.com/
268 other_branch = $TESTTMP/branchy#foo
269 other_branched = $TESTTMP/branchy#default
270 other_default = $TESTTMP/a
271 path_with_branch = $TESTTMP/branchy#foo
272 pushdest = $TESTTMP/push-dest
273 pushdest:pushrev = default
274 pushdest-overwrite = $TESTTMP/push-dest
275 pushdest-overwrite:pushrev = foo
276 pushdest2 = $TESTTMP/push-dest
277 pushdest2:pushrev = default
278
279 test basic chaining
280 -------------------
281
282 $ hg path other_default
283 $TESTTMP/a
284 $ hg pull default
285 pulling from $TESTTMP/a
286 no changes found
287 $ hg pull other_default
288 pulling from $TESTTMP/a
289 no changes found
290
291 test inheritance of the #fragment part
292 --------------------------------------
293
294 $ hg pull path_with_branch
295 pulling from $TESTTMP/branchy
296 adding changesets
297 adding manifests
298 adding file changes
299 added 6 changesets with 0 changes to 0 files
300 new changesets 1ea73414a91b:bcebb50b77de
301 (run 'hg update' to get a working copy)
302 $ hg pull other_branch
303 pulling from $TESTTMP/branchy
304 no changes found
305 $ hg pull other_branched
306 pulling from $TESTTMP/branchy
307 searching for changes
308 adding changesets
309 adding manifests
310 adding file changes
311 added 3 changesets with 0 changes to 0 files (+1 heads)
312 new changesets 66f7d451a68b:2dc09a01254d
313 (run 'hg heads' to see heads)
314
315 test inheritance of the suboptions
316 ----------------------------------
317
318 $ hg push pushdest
319 pushing to $TESTTMP/push-dest
320 searching for changes
321 adding changesets
322 adding manifests
323 adding file changes
324 added 4 changesets with 0 changes to 0 files
325 $ hg push pushdest2
326 pushing to $TESTTMP/push-dest
327 searching for changes
328 no changes found
329 [1]
330 $ hg push pushdest-overwrite --new-branch
331 pushing to $TESTTMP/push-dest
332 searching for changes
333 adding changesets
334 adding manifests
335 adding file changes
336 added 5 changesets with 0 changes to 0 files (+1 heads)
General Comments 0
You need to be logged in to leave comments. Login now