Debian Codegraph @

tests/test-paths.t

raw
1 $ hg init a
2 $ hg clone a b
3 updating to branch default
4 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
5 $ cd a
6
7 with no paths:
8
9 $ hg paths
10 $ hg paths unknown
11 not found!
12 [1]
13 $ hg paths -Tjson
14 [
15 ]
16
17 with paths:
18
19 $ echo '[paths]' >> .hg/hgrc
20 $ echo 'dupe = ../b#tip' >> .hg/hgrc
21 $ echo 'expand = $SOMETHING/bar' >> .hg/hgrc
22 $ hg in dupe
23 comparing with $TESTTMP/b
24 no changes found
25 [1]
26 $ cd ..
27 $ hg -R a in dupe
28 comparing with $TESTTMP/b
29 no changes found
30 [1]
31 $ cd a
32 $ hg paths
33 dupe = $TESTTMP/b#tip
34 expand = $TESTTMP/a/$SOMETHING/bar
35 $ SOMETHING=foo hg paths
36 dupe = $TESTTMP/b#tip
37 expand = $TESTTMP/a/foo/bar
38 #if msys
39 $ SOMETHING=//foo hg paths
40 dupe = $TESTTMP/b#tip
41 expand = /foo/bar
42 #else
43 $ SOMETHING=/foo hg paths
44 dupe = $TESTTMP/b#tip
45 expand = /foo/bar
46 #endif
47 $ hg paths -q
48 dupe
49 expand
50 $ hg paths dupe
51 $TESTTMP/b#tip
52 $ hg paths -q dupe
53 $ hg paths unknown
54 not found!
55 [1]
56 $ hg paths -q unknown
57 [1]
58
59 formatter output with paths:
60
61 $ echo 'dupe:pushurl = https://example.com/dupe' >> .hg/hgrc
62 $ hg paths -Tjson | sed 's|\\\\|\\|g'
63 [
64 {
65 "name": "dupe",
66 "pushurl": "https://example.com/dupe",
67 "url": "$TESTTMP/b#tip"
68 },
69 {
70 "name": "expand",
71 "url": "$TESTTMP/a/$SOMETHING/bar"
72 }
73 ]
74 $ hg paths -Tjson dupe | sed 's|\\\\|\\|g'
75 [
76 {
77 "name": "dupe",
78 "pushurl": "https://example.com/dupe",
79 "url": "$TESTTMP/b#tip"
80 }
81 ]
82 $ hg paths -Tjson -q unknown
83 [
84 ]
85 [1]
86
87 log template:
88
89 (behaves as a {name: path-string} dict by default)
90
91 $ hg log -rnull -T '{peerurls}\n'
92 dupe=$TESTTMP/b#tip expand=$TESTTMP/a/$SOMETHING/bar
93 $ hg log -rnull -T '{join(peerurls, "\n")}\n'
94 dupe=$TESTTMP/b#tip
95 expand=$TESTTMP/a/$SOMETHING/bar
96 $ hg log -rnull -T '{peerurls % "{name}: {url}\n"}'
97 dupe: $TESTTMP/b#tip
98 expand: $TESTTMP/a/$SOMETHING/bar
99 $ hg log -rnull -T '{get(peerurls, "dupe")}\n'
100 $TESTTMP/b#tip
101 #if windows
102 $ hg log -rnull -T '{peerurls % "{urls|json}\n"}'
103 [{"pushurl": "https://example.com/dupe", "url": "$STR_REPR_TESTTMP\\b#tip"}]
104 [{"url": "$STR_REPR_TESTTMP\\a\\$SOMETHING\\bar"}]
105 #else
106 $ hg log -rnull -T '{peerurls % "{urls|json}\n"}'
107 [{"pushurl": "https://example.com/dupe", "url": "$TESTTMP/b#tip"}]
108 [{"url": "$TESTTMP/a/$SOMETHING/bar"}]
109 #endif
110
111 (sub options can be populated by map/dot operation)
112
113 $ hg log -rnull \
114 > -T '{get(peerurls, "dupe") % "url: {url}\npushurl: {pushurl}\n"}'
115 url: $TESTTMP/b#tip
116 pushurl: https://example.com/dupe
117 $ hg log -rnull -T '{peerurls.dupe.pushurl}\n'
118 https://example.com/dupe
119
120 (in JSON, it's a dict of urls)
121
122 $ hg log -rnull -T '{peerurls|json}\n' | sed 's|\\\\|/|g'
123 {"dupe": "$TESTTMP/b#tip", "expand": "$TESTTMP/a/$SOMETHING/bar"}
124
125 password should be masked in plain output, but not in machine-readable/template
126 output:
127
128 $ echo 'insecure = http://foo:[email protected]/' >> .hg/hgrc
129 $ hg paths insecure
130 http://foo:***@example.com/
131 $ hg paths -Tjson insecure
132 [
133 {
134 "name": "insecure",
135 "url": "http://foo:[email protected]/"
136 }
137 ]
138 $ hg log -rnull -T '{get(peerurls, "insecure")}\n'
139 http://foo:[email protected]/
140
141 zeroconf wraps ui.configitems(), which shouldn't crash at least:
142
143 XXX: This occasionally crashes with 'TypeError: ord() expected string of length
144 1, but int found' when processing a packet response, so disable it for now.
145
146 #if missing-correct-output
147 $ hg paths --config extensions.zeroconf=
148 dupe = $TESTTMP/b#tip
149 dupe:pushurl = https://example.com/dupe
150 expand = $TESTTMP/a/$SOMETHING/bar
151 insecure = http://foo:***@example.com/
152 #endif
153
154
155 $ cd ..
156
157 sub-options for an undeclared path are ignored
158
159 $ hg init suboptions
160 $ cd suboptions
161
162 $ cat > .hg/hgrc << EOF
163 > [paths]
164 > path0 = https://example.com/path0
165 > path1:pushurl = https://example.com/path1
166 > EOF
167 $ hg paths
168 path0 = https://example.com/path0
169
170 unknown sub-options aren't displayed
171
172 $ cat > .hg/hgrc << EOF
173 > [paths]
174 > path0 = https://example.com/path0
175 > path0:foo = https://example.com/path1
176 > EOF
177
178 $ hg paths
179 path0 = https://example.com/path0
180
181 :pushurl must be a URL
182
183 $ cat > .hg/hgrc << EOF
184 > [paths]
185 > default = /path/to/nothing
186 > default:pushurl = /not/a/url
187 > EOF
188
189 $ hg paths
190 (paths.default:pushurl not a URL; ignoring: "/not/a/url")
191 default = /path/to/nothing
192
193 #fragment is not allowed in :pushurl
194
195 $ cat > .hg/hgrc << EOF
196 > [paths]
197 > default = https://example.com/repo
198 > invalid = https://example.com/repo
199 > invalid:pushurl = https://example.com/repo#branch
200 > EOF
201
202 $ hg paths
203 ("#fragment" in paths.invalid:pushurl not supported; ignoring)
204 default = https://example.com/repo
205 invalid = https://example.com/repo
206 invalid:pushurl = https://example.com/repo
207
208 $ cd ..
209
210 'file:' disables [paths] entries for clone destination
211
212 $ cat >> $HGRCPATH <<EOF
213 > [paths]
214 > gpath1 = http://hg.example.com
215 > EOF
216
217 $ hg clone a gpath1
218 abort: cannot create new http repository
219 [255]
220
221 $ hg clone a file:gpath1
222 updating to branch default
223 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
224 $ cd gpath1
225 $ hg -q id
226 000000000000
227
228 $ cd ..
229
230 Testing path referencing other paths
231 ====================================
232
233 basic setup
234 -----------
235
236 $ hg init chained_path
237 $ cd chained_path
238 $ cat << EOF > .hg/hgrc
239 > [paths]
240 > default=../a
241 > other_default=path://default
242 > path_with_branch=../branchy#foo
243 > other_branch=path://path_with_branch
244 > other_branched=path://path_with_branch#default
245 > pushdest=../push-dest
246 > pushdest:pushrev=default
247 > pushdest2=path://pushdest
248 > pushdest-overwrite=path://pushdest
249 > pushdest-overwrite:pushrev=foo
250 > EOF
251
252 $ hg init ../branchy
253 $ hg init ../push-dest
254 $ hg debugbuilddag -R ../branchy '.:base+3<base@foo+5'
255 $ hg log -G -T '{branch}\n' -R ../branchy
256 o foo
257 |
258 o foo
259 |
260 o foo
261 |
262 o foo
263 |
264 o foo
265 |
266 | o default
267 | |
268 | o default
269 | |
270 | o default
271 |/
272 o default
273
274
275 $ hg paths
276 default = $TESTTMP/a
277 gpath1 = http://hg.example.com/
278 other_branch = $TESTTMP/branchy#foo
279 other_branched = $TESTTMP/branchy#default
280 other_default = $TESTTMP/a
281 path_with_branch = $TESTTMP/branchy#foo
282 pushdest = $TESTTMP/push-dest
283 pushdest:pushrev = default
284 pushdest-overwrite = $TESTTMP/push-dest
285 pushdest-overwrite:pushrev = foo
286 pushdest2 = $TESTTMP/push-dest
287 pushdest2:pushrev = default
288
289 test basic chaining
290 -------------------
291
292 $ hg path other_default
293 $TESTTMP/a
294 $ hg pull default
295 pulling from $TESTTMP/a
296 no changes found
297 $ hg pull other_default
298 pulling from $TESTTMP/a
299 no changes found
300
301 test inheritance of the #fragment part
302 --------------------------------------
303
304 $ hg pull path_with_branch
305 pulling from $TESTTMP/branchy
306 adding changesets
307 adding manifests
308 adding file changes
309 added 6 changesets with 0 changes to 0 files
310 new changesets 1ea73414a91b:bcebb50b77de
311 (run 'hg update' to get a working copy)
312 $ hg pull other_branch
313 pulling from $TESTTMP/branchy
314 no changes found
315 $ hg pull other_branched
316 pulling from $TESTTMP/branchy
317 searching for changes
318 adding changesets
319 adding manifests
320 adding file changes
321 added 3 changesets with 0 changes to 0 files (+1 heads)
322 new changesets 66f7d451a68b:2dc09a01254d
323 (run 'hg heads' to see heads)
324
325 test inheritance of the suboptions
326 ----------------------------------
327
328 $ hg push pushdest
329 pushing to $TESTTMP/push-dest
330 searching for changes
331 adding changesets
332 adding manifests
333 adding file changes
334 added 4 changesets with 0 changes to 0 files
335 $ hg push pushdest2
336 pushing to $TESTTMP/push-dest
337 searching for changes
338 no changes found
339 [1]
340 $ hg push pushdest-overwrite --new-branch
341 pushing to $TESTTMP/push-dest
342 searching for changes
343 adding changesets
344 adding manifests
345 adding file changes
346 added 5 changesets with 0 changes to 0 files (+1 heads)
347
348 Test chaining path:// definition
349 --------------------------------
350
351 This is currently unsupported, but feel free to implement the necessary
352 dependency detection.
353
354 $ cat << EOF >> .hg/hgrc
355 > chain_path=path://other_default
356 > EOF
357
358 $ hg id
359 000000000000
360 $ hg path
361 abort: cannot use `path://other_default`, "other_default" is also defined as a `path://`
362 [255]
363 $ hg pull chain_path
364 abort: cannot use `path://other_default`, "other_default" is also defined as a `path://`
365 [255]
366
367 Doing an actual circle should always be an issue
368
369 $ cat << EOF >> .hg/hgrc
370 > rock=path://cissors
371 > cissors=path://paper
372 > paper=://rock
373 > EOF
374
375 $ hg id
376 000000000000
377 $ hg path
378 abort: cannot use `path://other_default`, "other_default" is also defined as a `path://`
379 [255]
380 $ hg pull chain_path
381 abort: cannot use `path://other_default`, "other_default" is also defined as a `path://`
382 [255]
383
384 Test basic error cases
385 ----------------------
386
387 $ cat << EOF > .hg/hgrc
388 > [paths]
389 > error-missing=path://unknown
390 > EOF
391 $ hg path
392 abort: cannot use `path://unknown`, "unknown" is not a known path
393 [255]
394 $ hg pull error-missing
395 abort: cannot use `path://unknown`, "unknown" is not a known path
396 [255]
397
398 Test path pointing to multiple urls
399 ===================================
400
401 Simple cases
402 ------------
403 - one layer
404 - one list
405 - no special option
406
407 $ cat << EOF > .hg/hgrc
408 > [paths]
409 > one-path=foo
410 > multiple-path=foo,bar,baz,https://example.org/
411 > multiple-path:multi-urls=yes
412 > EOF
413 $ hg path
414 gpath1 = http://hg.example.com/
415 multiple-path = $TESTTMP/chained_path/foo
416 multiple-path:multi-urls = yes
417 multiple-path = $TESTTMP/chained_path/bar
418 multiple-path:multi-urls = yes
419 multiple-path = $TESTTMP/chained_path/baz
420 multiple-path:multi-urls = yes
421 multiple-path = https://example.org/
422 multiple-path:multi-urls = yes
423 one-path = $TESTTMP/chained_path/foo
424
425 Reference to a list
426 -------------------
427
428 $ cat << EOF >> .hg/hgrc
429 > ref-to-multi=path://multiple-path
430 > EOF
431 $ hg path | grep ref-to-multi
432 ref-to-multi = $TESTTMP/chained_path/foo
433 ref-to-multi:multi-urls = yes
434 ref-to-multi = $TESTTMP/chained_path/bar
435 ref-to-multi:multi-urls = yes
436 ref-to-multi = $TESTTMP/chained_path/baz
437 ref-to-multi:multi-urls = yes
438 ref-to-multi = https://example.org/
439 ref-to-multi:multi-urls = yes
440
441 List with a reference
442 ---------------------
443
444 $ cat << EOF >> .hg/hgrc
445 > multi-with-ref=path://one-path, ssh://babar@savannah/celeste-ville
446 > multi-with-ref:multi-urls=yes
447 > EOF
448 $ hg path | grep multi-with-ref
449 multi-with-ref = $TESTTMP/chained_path/foo
450 multi-with-ref:multi-urls = yes
451 multi-with-ref = ssh://babar@savannah/celeste-ville
452 multi-with-ref:multi-urls = yes
453
454 List with a reference to a list
455 -------------------------------
456
457 $ cat << EOF >> .hg/hgrc
458 > multi-to-multi-ref = path://multiple-path, ssh://celeste@savannah/celeste-ville
459 > multi-to-multi-ref:multi-urls = yes
460 > EOF
461 $ hg path | grep multi-to-multi-ref
462 multi-to-multi-ref = $TESTTMP/chained_path/foo
463 multi-to-multi-ref:multi-urls = yes
464 multi-to-multi-ref = $TESTTMP/chained_path/bar
465 multi-to-multi-ref:multi-urls = yes
466 multi-to-multi-ref = $TESTTMP/chained_path/baz
467 multi-to-multi-ref:multi-urls = yes
468 multi-to-multi-ref = https://example.org/
469 multi-to-multi-ref:multi-urls = yes
470 multi-to-multi-ref = ssh://celeste@savannah/celeste-ville
471 multi-to-multi-ref:multi-urls = yes
472
473 individual suboptions are inherited
474 -----------------------------------
475
476 $ cat << EOF >> .hg/hgrc
477 > with-pushurl = foo
478 > with-pushurl:pushurl = http://foo.bar/
479 > with-pushrev = bar
480 > with-pushrev:pushrev = draft()
481 > with-both = toto
482 > with-both:pushurl = http://ta.ta
483 > with-both:pushrev = secret()
484 > ref-all-no-opts = path://with-pushurl, path://with-pushrev, path://with-both
485 > ref-all-no-opts:multi-urls = yes
486 > with-overwrite = path://with-pushurl, path://with-pushrev, path://with-both
487 > with-overwrite:multi-urls = yes
488 > with-overwrite:pushrev = public()
489 > EOF
490 $ hg path | grep with-pushurl
491 with-pushurl = $TESTTMP/chained_path/foo
492 with-pushurl:pushurl = http://foo.bar/
493 $ hg path | grep with-pushrev
494 with-pushrev = $TESTTMP/chained_path/bar
495 with-pushrev:pushrev = draft()
496 $ hg path | grep with-both
497 with-both = $TESTTMP/chained_path/toto
498 with-both:pushrev = secret()
499 with-both:pushurl = http://ta.ta/
500 $ hg path | grep ref-all-no-opts
501 ref-all-no-opts = $TESTTMP/chained_path/foo
502 ref-all-no-opts:multi-urls = yes
503 ref-all-no-opts:pushurl = http://foo.bar/
504 ref-all-no-opts = $TESTTMP/chained_path/bar
505 ref-all-no-opts:multi-urls = yes
506 ref-all-no-opts:pushrev = draft()
507 ref-all-no-opts = $TESTTMP/chained_path/toto
508 ref-all-no-opts:multi-urls = yes
509 ref-all-no-opts:pushrev = secret()
510 ref-all-no-opts:pushurl = http://ta.ta/
511 $ hg path | grep with-overwrite
512 with-overwrite = $TESTTMP/chained_path/foo
513 with-overwrite:multi-urls = yes
514 with-overwrite:pushrev = public()
515 with-overwrite:pushurl = http://foo.bar/
516 with-overwrite = $TESTTMP/chained_path/bar
517 with-overwrite:multi-urls = yes
518 with-overwrite:pushrev = public()
519 with-overwrite = $TESTTMP/chained_path/toto
520 with-overwrite:multi-urls = yes
521 with-overwrite:pushrev = public()
522 with-overwrite:pushurl = http://ta.ta/