##// END OF EJS Templates
clone: add tests for unsafe ssh url (SEC)
Sean Farley -
r33709:f9134e96 stable
parent child Browse files
Show More
@@ -1,1094 +1,1116 b''
1 1 Prepare repo a:
2 2
3 3 $ hg init a
4 4 $ cd a
5 5 $ echo a > a
6 6 $ hg add a
7 7 $ hg commit -m test
8 8 $ echo first line > b
9 9 $ hg add b
10 10
11 11 Create a non-inlined filelog:
12 12
13 13 $ $PYTHON -c 'file("data1", "wb").write("".join("%s\n" % x for x in range(10000)))'
14 14 $ for j in 0 1 2 3 4 5 6 7 8 9; do
15 15 > cat data1 >> b
16 16 > hg commit -m test
17 17 > done
18 18
19 19 List files in store/data (should show a 'b.d'):
20 20
21 21 $ for i in .hg/store/data/*; do
22 22 > echo $i
23 23 > done
24 24 .hg/store/data/a.i
25 25 .hg/store/data/b.d
26 26 .hg/store/data/b.i
27 27
28 28 Trigger branchcache creation:
29 29
30 30 $ hg branches
31 31 default 10:a7949464abda
32 32 $ ls .hg/cache
33 33 branch2-served
34 34 checkisexec (execbit !)
35 35 checklink (symlink !)
36 36 checklink-target (symlink !)
37 37 checknoexec (execbit !)
38 38 rbc-names-v1
39 39 rbc-revs-v1
40 40
41 41 Default operation:
42 42
43 43 $ hg clone . ../b
44 44 updating to branch default
45 45 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 46 $ cd ../b
47 47
48 48 Ensure branchcache got copied over:
49 49
50 50 $ ls .hg/cache
51 51 branch2-served
52 52 checkisexec (execbit !)
53 53 checklink (symlink !)
54 54 checklink-target (symlink !)
55 55
56 56 $ cat a
57 57 a
58 58 $ hg verify
59 59 checking changesets
60 60 checking manifests
61 61 crosschecking files in changesets and manifests
62 62 checking files
63 63 2 files, 11 changesets, 11 total revisions
64 64
65 65 Invalid dest '' must abort:
66 66
67 67 $ hg clone . ''
68 68 abort: empty destination path is not valid
69 69 [255]
70 70
71 71 No update, with debug option:
72 72
73 73 #if hardlink
74 74 $ hg --debug clone -U . ../c --config progress.debug=true
75 75 linking: 1
76 76 linking: 2
77 77 linking: 3
78 78 linking: 4
79 79 linking: 5
80 80 linking: 6
81 81 linking: 7
82 82 linking: 8
83 83 linked 8 files
84 84 #else
85 85 $ hg --debug clone -U . ../c --config progress.debug=true
86 86 linking: 1
87 87 copying: 2
88 88 copying: 3
89 89 copying: 4
90 90 copying: 5
91 91 copying: 6
92 92 copying: 7
93 93 copying: 8
94 94 copied 8 files
95 95 #endif
96 96 $ cd ../c
97 97
98 98 Ensure branchcache got copied over:
99 99
100 100 $ ls .hg/cache
101 101 branch2-served
102 102
103 103 $ cat a 2>/dev/null || echo "a not present"
104 104 a not present
105 105 $ hg verify
106 106 checking changesets
107 107 checking manifests
108 108 crosschecking files in changesets and manifests
109 109 checking files
110 110 2 files, 11 changesets, 11 total revisions
111 111
112 112 Default destination:
113 113
114 114 $ mkdir ../d
115 115 $ cd ../d
116 116 $ hg clone ../a
117 117 destination directory: a
118 118 updating to branch default
119 119 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
120 120 $ cd a
121 121 $ hg cat a
122 122 a
123 123 $ cd ../..
124 124
125 125 Check that we drop the 'file:' from the path before writing the .hgrc:
126 126
127 127 $ hg clone file:a e
128 128 updating to branch default
129 129 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
130 130 $ grep 'file:' e/.hg/hgrc
131 131 [1]
132 132
133 133 Check that path aliases are expanded:
134 134
135 135 $ hg clone -q -U --config 'paths.foobar=a#0' foobar f
136 136 $ hg -R f showconfig paths.default
137 137 $TESTTMP/a#0 (glob)
138 138
139 139 Use --pull:
140 140
141 141 $ hg clone --pull a g
142 142 requesting all changes
143 143 adding changesets
144 144 adding manifests
145 145 adding file changes
146 146 added 11 changesets with 11 changes to 2 files
147 147 updating to branch default
148 148 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
149 149 $ hg -R g verify
150 150 checking changesets
151 151 checking manifests
152 152 crosschecking files in changesets and manifests
153 153 checking files
154 154 2 files, 11 changesets, 11 total revisions
155 155
156 156 Invalid dest '' with --pull must abort (issue2528):
157 157
158 158 $ hg clone --pull a ''
159 159 abort: empty destination path is not valid
160 160 [255]
161 161
162 162 Clone to '.':
163 163
164 164 $ mkdir h
165 165 $ cd h
166 166 $ hg clone ../a .
167 167 updating to branch default
168 168 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 169 $ cd ..
170 170
171 171
172 172 *** Tests for option -u ***
173 173
174 174 Adding some more history to repo a:
175 175
176 176 $ cd a
177 177 $ hg tag ref1
178 178 $ echo the quick brown fox >a
179 179 $ hg ci -m "hacked default"
180 180 $ hg up ref1
181 181 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
182 182 $ hg branch stable
183 183 marked working directory as branch stable
184 184 (branches are permanent and global, did you want a bookmark?)
185 185 $ echo some text >a
186 186 $ hg ci -m "starting branch stable"
187 187 $ hg tag ref2
188 188 $ echo some more text >a
189 189 $ hg ci -m "another change for branch stable"
190 190 $ hg up ref2
191 191 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
192 192 $ hg parents
193 193 changeset: 13:e8ece76546a6
194 194 branch: stable
195 195 tag: ref2
196 196 parent: 10:a7949464abda
197 197 user: test
198 198 date: Thu Jan 01 00:00:00 1970 +0000
199 199 summary: starting branch stable
200 200
201 201
202 202 Repo a has two heads:
203 203
204 204 $ hg heads
205 205 changeset: 15:0aae7cf88f0d
206 206 branch: stable
207 207 tag: tip
208 208 user: test
209 209 date: Thu Jan 01 00:00:00 1970 +0000
210 210 summary: another change for branch stable
211 211
212 212 changeset: 12:f21241060d6a
213 213 user: test
214 214 date: Thu Jan 01 00:00:00 1970 +0000
215 215 summary: hacked default
216 216
217 217
218 218 $ cd ..
219 219
220 220
221 221 Testing --noupdate with --updaterev (must abort):
222 222
223 223 $ hg clone --noupdate --updaterev 1 a ua
224 224 abort: cannot specify both --noupdate and --updaterev
225 225 [255]
226 226
227 227
228 228 Testing clone -u:
229 229
230 230 $ hg clone -u . a ua
231 231 updating to branch stable
232 232 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
233 233
234 234 Repo ua has both heads:
235 235
236 236 $ hg -R ua heads
237 237 changeset: 15:0aae7cf88f0d
238 238 branch: stable
239 239 tag: tip
240 240 user: test
241 241 date: Thu Jan 01 00:00:00 1970 +0000
242 242 summary: another change for branch stable
243 243
244 244 changeset: 12:f21241060d6a
245 245 user: test
246 246 date: Thu Jan 01 00:00:00 1970 +0000
247 247 summary: hacked default
248 248
249 249
250 250 Same revision checked out in repo a and ua:
251 251
252 252 $ hg -R a parents --template "{node|short}\n"
253 253 e8ece76546a6
254 254 $ hg -R ua parents --template "{node|short}\n"
255 255 e8ece76546a6
256 256
257 257 $ rm -r ua
258 258
259 259
260 260 Testing clone --pull -u:
261 261
262 262 $ hg clone --pull -u . a ua
263 263 requesting all changes
264 264 adding changesets
265 265 adding manifests
266 266 adding file changes
267 267 added 16 changesets with 16 changes to 3 files (+1 heads)
268 268 updating to branch stable
269 269 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
270 270
271 271 Repo ua has both heads:
272 272
273 273 $ hg -R ua heads
274 274 changeset: 15:0aae7cf88f0d
275 275 branch: stable
276 276 tag: tip
277 277 user: test
278 278 date: Thu Jan 01 00:00:00 1970 +0000
279 279 summary: another change for branch stable
280 280
281 281 changeset: 12:f21241060d6a
282 282 user: test
283 283 date: Thu Jan 01 00:00:00 1970 +0000
284 284 summary: hacked default
285 285
286 286
287 287 Same revision checked out in repo a and ua:
288 288
289 289 $ hg -R a parents --template "{node|short}\n"
290 290 e8ece76546a6
291 291 $ hg -R ua parents --template "{node|short}\n"
292 292 e8ece76546a6
293 293
294 294 $ rm -r ua
295 295
296 296
297 297 Testing clone -u <branch>:
298 298
299 299 $ hg clone -u stable a ua
300 300 updating to branch stable
301 301 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
302 302
303 303 Repo ua has both heads:
304 304
305 305 $ hg -R ua heads
306 306 changeset: 15:0aae7cf88f0d
307 307 branch: stable
308 308 tag: tip
309 309 user: test
310 310 date: Thu Jan 01 00:00:00 1970 +0000
311 311 summary: another change for branch stable
312 312
313 313 changeset: 12:f21241060d6a
314 314 user: test
315 315 date: Thu Jan 01 00:00:00 1970 +0000
316 316 summary: hacked default
317 317
318 318
319 319 Branch 'stable' is checked out:
320 320
321 321 $ hg -R ua parents
322 322 changeset: 15:0aae7cf88f0d
323 323 branch: stable
324 324 tag: tip
325 325 user: test
326 326 date: Thu Jan 01 00:00:00 1970 +0000
327 327 summary: another change for branch stable
328 328
329 329
330 330 $ rm -r ua
331 331
332 332
333 333 Testing default checkout:
334 334
335 335 $ hg clone a ua
336 336 updating to branch default
337 337 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
338 338
339 339 Repo ua has both heads:
340 340
341 341 $ hg -R ua heads
342 342 changeset: 15:0aae7cf88f0d
343 343 branch: stable
344 344 tag: tip
345 345 user: test
346 346 date: Thu Jan 01 00:00:00 1970 +0000
347 347 summary: another change for branch stable
348 348
349 349 changeset: 12:f21241060d6a
350 350 user: test
351 351 date: Thu Jan 01 00:00:00 1970 +0000
352 352 summary: hacked default
353 353
354 354
355 355 Branch 'default' is checked out:
356 356
357 357 $ hg -R ua parents
358 358 changeset: 12:f21241060d6a
359 359 user: test
360 360 date: Thu Jan 01 00:00:00 1970 +0000
361 361 summary: hacked default
362 362
363 363 Test clone with a branch named "@" (issue3677)
364 364
365 365 $ hg -R ua branch @
366 366 marked working directory as branch @
367 367 $ hg -R ua commit -m 'created branch @'
368 368 $ hg clone ua atbranch
369 369 updating to branch default
370 370 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
371 371 $ hg -R atbranch heads
372 372 changeset: 16:798b6d97153e
373 373 branch: @
374 374 tag: tip
375 375 parent: 12:f21241060d6a
376 376 user: test
377 377 date: Thu Jan 01 00:00:00 1970 +0000
378 378 summary: created branch @
379 379
380 380 changeset: 15:0aae7cf88f0d
381 381 branch: stable
382 382 user: test
383 383 date: Thu Jan 01 00:00:00 1970 +0000
384 384 summary: another change for branch stable
385 385
386 386 changeset: 12:f21241060d6a
387 387 user: test
388 388 date: Thu Jan 01 00:00:00 1970 +0000
389 389 summary: hacked default
390 390
391 391 $ hg -R atbranch parents
392 392 changeset: 12:f21241060d6a
393 393 user: test
394 394 date: Thu Jan 01 00:00:00 1970 +0000
395 395 summary: hacked default
396 396
397 397
398 398 $ rm -r ua atbranch
399 399
400 400
401 401 Testing #<branch>:
402 402
403 403 $ hg clone -u . a#stable ua
404 404 adding changesets
405 405 adding manifests
406 406 adding file changes
407 407 added 14 changesets with 14 changes to 3 files
408 408 updating to branch stable
409 409 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
410 410
411 411 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
412 412
413 413 $ hg -R ua heads
414 414 changeset: 13:0aae7cf88f0d
415 415 branch: stable
416 416 tag: tip
417 417 user: test
418 418 date: Thu Jan 01 00:00:00 1970 +0000
419 419 summary: another change for branch stable
420 420
421 421 changeset: 10:a7949464abda
422 422 user: test
423 423 date: Thu Jan 01 00:00:00 1970 +0000
424 424 summary: test
425 425
426 426
427 427 Same revision checked out in repo a and ua:
428 428
429 429 $ hg -R a parents --template "{node|short}\n"
430 430 e8ece76546a6
431 431 $ hg -R ua parents --template "{node|short}\n"
432 432 e8ece76546a6
433 433
434 434 $ rm -r ua
435 435
436 436
437 437 Testing -u -r <branch>:
438 438
439 439 $ hg clone -u . -r stable a ua
440 440 adding changesets
441 441 adding manifests
442 442 adding file changes
443 443 added 14 changesets with 14 changes to 3 files
444 444 updating to branch stable
445 445 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
446 446
447 447 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
448 448
449 449 $ hg -R ua heads
450 450 changeset: 13:0aae7cf88f0d
451 451 branch: stable
452 452 tag: tip
453 453 user: test
454 454 date: Thu Jan 01 00:00:00 1970 +0000
455 455 summary: another change for branch stable
456 456
457 457 changeset: 10:a7949464abda
458 458 user: test
459 459 date: Thu Jan 01 00:00:00 1970 +0000
460 460 summary: test
461 461
462 462
463 463 Same revision checked out in repo a and ua:
464 464
465 465 $ hg -R a parents --template "{node|short}\n"
466 466 e8ece76546a6
467 467 $ hg -R ua parents --template "{node|short}\n"
468 468 e8ece76546a6
469 469
470 470 $ rm -r ua
471 471
472 472
473 473 Testing -r <branch>:
474 474
475 475 $ hg clone -r stable a ua
476 476 adding changesets
477 477 adding manifests
478 478 adding file changes
479 479 added 14 changesets with 14 changes to 3 files
480 480 updating to branch stable
481 481 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
482 482
483 483 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
484 484
485 485 $ hg -R ua heads
486 486 changeset: 13:0aae7cf88f0d
487 487 branch: stable
488 488 tag: tip
489 489 user: test
490 490 date: Thu Jan 01 00:00:00 1970 +0000
491 491 summary: another change for branch stable
492 492
493 493 changeset: 10:a7949464abda
494 494 user: test
495 495 date: Thu Jan 01 00:00:00 1970 +0000
496 496 summary: test
497 497
498 498
499 499 Branch 'stable' is checked out:
500 500
501 501 $ hg -R ua parents
502 502 changeset: 13:0aae7cf88f0d
503 503 branch: stable
504 504 tag: tip
505 505 user: test
506 506 date: Thu Jan 01 00:00:00 1970 +0000
507 507 summary: another change for branch stable
508 508
509 509
510 510 $ rm -r ua
511 511
512 512
513 513 Issue2267: Error in 1.6 hg.py: TypeError: 'NoneType' object is not
514 514 iterable in addbranchrevs()
515 515
516 516 $ cat <<EOF > simpleclone.py
517 517 > from mercurial import ui, hg
518 518 > myui = ui.ui.load()
519 519 > repo = hg.repository(myui, 'a')
520 520 > hg.clone(myui, {}, repo, dest="ua")
521 521 > EOF
522 522
523 523 $ python simpleclone.py
524 524 updating to branch default
525 525 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
526 526
527 527 $ rm -r ua
528 528
529 529 $ cat <<EOF > branchclone.py
530 530 > from mercurial import ui, hg, extensions
531 531 > myui = ui.ui.load()
532 532 > extensions.loadall(myui)
533 533 > repo = hg.repository(myui, 'a')
534 534 > hg.clone(myui, {}, repo, dest="ua", branch=["stable",])
535 535 > EOF
536 536
537 537 $ python branchclone.py
538 538 adding changesets
539 539 adding manifests
540 540 adding file changes
541 541 added 14 changesets with 14 changes to 3 files
542 542 updating to branch stable
543 543 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
544 544 $ rm -r ua
545 545
546 546
547 547 Test clone with special '@' bookmark:
548 548 $ cd a
549 549 $ hg bookmark -r a7949464abda @ # branch point of stable from default
550 550 $ hg clone . ../i
551 551 updating to bookmark @
552 552 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
553 553 $ hg id -i ../i
554 554 a7949464abda
555 555 $ rm -r ../i
556 556
557 557 $ hg bookmark -f -r stable @
558 558 $ hg bookmarks
559 559 @ 15:0aae7cf88f0d
560 560 $ hg clone . ../i
561 561 updating to bookmark @ on branch stable
562 562 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
563 563 $ hg id -i ../i
564 564 0aae7cf88f0d
565 565 $ cd "$TESTTMP"
566 566
567 567
568 568 Testing failures:
569 569
570 570 $ mkdir fail
571 571 $ cd fail
572 572
573 573 No local source
574 574
575 575 $ hg clone a b
576 576 abort: repository a not found!
577 577 [255]
578 578
579 579 No remote source
580 580
581 581 #if windows
582 582 $ hg clone http://$LOCALIP:3121/a b
583 583 abort: error: * (glob)
584 584 [255]
585 585 #else
586 586 $ hg clone http://$LOCALIP:3121/a b
587 587 abort: error: *refused* (glob)
588 588 [255]
589 589 #endif
590 590 $ rm -rf b # work around bug with http clone
591 591
592 592
593 593 #if unix-permissions no-root
594 594
595 595 Inaccessible source
596 596
597 597 $ mkdir a
598 598 $ chmod 000 a
599 599 $ hg clone a b
600 600 abort: repository a not found!
601 601 [255]
602 602
603 603 Inaccessible destination
604 604
605 605 $ hg init b
606 606 $ cd b
607 607 $ hg clone . ../a
608 608 abort: Permission denied: '../a'
609 609 [255]
610 610 $ cd ..
611 611 $ chmod 700 a
612 612 $ rm -r a b
613 613
614 614 #endif
615 615
616 616
617 617 #if fifo
618 618
619 619 Source of wrong type
620 620
621 621 $ mkfifo a
622 622 $ hg clone a b
623 623 abort: repository a not found!
624 624 [255]
625 625 $ rm a
626 626
627 627 #endif
628 628
629 629 Default destination, same directory
630 630
631 631 $ hg init q
632 632 $ hg clone q
633 633 destination directory: q
634 634 abort: destination 'q' is not empty
635 635 [255]
636 636
637 637 destination directory not empty
638 638
639 639 $ mkdir a
640 640 $ echo stuff > a/a
641 641 $ hg clone q a
642 642 abort: destination 'a' is not empty
643 643 [255]
644 644
645 645
646 646 #if unix-permissions no-root
647 647
648 648 leave existing directory in place after clone failure
649 649
650 650 $ hg init c
651 651 $ cd c
652 652 $ echo c > c
653 653 $ hg commit -A -m test
654 654 adding c
655 655 $ chmod -rx .hg/store/data
656 656 $ cd ..
657 657 $ mkdir d
658 658 $ hg clone c d 2> err
659 659 [255]
660 660 $ test -d d
661 661 $ test -d d/.hg
662 662 [1]
663 663
664 664 re-enable perm to allow deletion
665 665
666 666 $ chmod +rx c/.hg/store/data
667 667
668 668 #endif
669 669
670 670 $ cd ..
671 671
672 672 Test clone from the repository in (emulated) revlog format 0 (issue4203):
673 673
674 674 $ mkdir issue4203
675 675 $ mkdir -p src/.hg
676 676 $ echo foo > src/foo
677 677 $ hg -R src add src/foo
678 678 $ hg -R src commit -m '#0'
679 679 $ hg -R src log -q
680 680 0:e1bab28bca43
681 681 $ hg clone -U -q src dst
682 682 $ hg -R dst log -q
683 683 0:e1bab28bca43
684 684
685 685 Create repositories to test auto sharing functionality
686 686
687 687 $ cat >> $HGRCPATH << EOF
688 688 > [extensions]
689 689 > share=
690 690 > EOF
691 691
692 692 $ hg init empty
693 693 $ hg init source1a
694 694 $ cd source1a
695 695 $ echo initial1 > foo
696 696 $ hg -q commit -A -m initial
697 697 $ echo second > foo
698 698 $ hg commit -m second
699 699 $ cd ..
700 700
701 701 $ hg init filteredrev0
702 702 $ cd filteredrev0
703 703 $ cat >> .hg/hgrc << EOF
704 704 > [experimental]
705 705 > evolution=createmarkers
706 706 > EOF
707 707 $ echo initial1 > foo
708 708 $ hg -q commit -A -m initial0
709 709 $ hg -q up -r null
710 710 $ echo initial2 > foo
711 711 $ hg -q commit -A -m initial1
712 712 $ hg debugobsolete c05d5c47a5cf81401869999f3d05f7d699d2b29a e082c1832e09a7d1e78b7fd49a592d372de854c8
713 713 $ cd ..
714 714
715 715 $ hg -q clone --pull source1a source1b
716 716 $ cd source1a
717 717 $ hg bookmark bookA
718 718 $ echo 1a > foo
719 719 $ hg commit -m 1a
720 720 $ cd ../source1b
721 721 $ hg -q up -r 0
722 722 $ echo head1 > foo
723 723 $ hg commit -m head1
724 724 created new head
725 725 $ hg bookmark head1
726 726 $ hg -q up -r 0
727 727 $ echo head2 > foo
728 728 $ hg commit -m head2
729 729 created new head
730 730 $ hg bookmark head2
731 731 $ hg -q up -r 0
732 732 $ hg branch branch1
733 733 marked working directory as branch branch1
734 734 (branches are permanent and global, did you want a bookmark?)
735 735 $ echo branch1 > foo
736 736 $ hg commit -m branch1
737 737 $ hg -q up -r 0
738 738 $ hg branch branch2
739 739 marked working directory as branch branch2
740 740 $ echo branch2 > foo
741 741 $ hg commit -m branch2
742 742 $ cd ..
743 743 $ hg init source2
744 744 $ cd source2
745 745 $ echo initial2 > foo
746 746 $ hg -q commit -A -m initial2
747 747 $ echo second > foo
748 748 $ hg commit -m second
749 749 $ cd ..
750 750
751 751 Clone with auto share from an empty repo should not result in share
752 752
753 753 $ mkdir share
754 754 $ hg --config share.pool=share clone empty share-empty
755 755 (not using pooled storage: remote appears to be empty)
756 756 updating to branch default
757 757 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
758 758 $ ls share
759 759 $ test -d share-empty/.hg/store
760 760 $ test -f share-empty/.hg/sharedpath
761 761 [1]
762 762
763 763 Clone with auto share from a repo with filtered revision 0 should not result in share
764 764
765 765 $ hg --config share.pool=share clone filteredrev0 share-filtered
766 766 (not using pooled storage: unable to resolve identity of remote)
767 767 requesting all changes
768 768 adding changesets
769 769 adding manifests
770 770 adding file changes
771 771 added 1 changesets with 1 changes to 1 files
772 772 updating to branch default
773 773 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
774 774
775 775 Clone from repo with content should result in shared store being created
776 776
777 777 $ hg --config share.pool=share clone source1a share-dest1a
778 778 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
779 779 requesting all changes
780 780 adding changesets
781 781 adding manifests
782 782 adding file changes
783 783 added 3 changesets with 3 changes to 1 files
784 784 searching for changes
785 785 no changes found
786 786 adding remote bookmark bookA
787 787 updating working directory
788 788 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
789 789
790 790 The shared repo should have been created
791 791
792 792 $ ls share
793 793 b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
794 794
795 795 The destination should point to it
796 796
797 797 $ cat share-dest1a/.hg/sharedpath; echo
798 798 $TESTTMP/share/b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1/.hg (glob)
799 799
800 800 The destination should have bookmarks
801 801
802 802 $ hg -R share-dest1a bookmarks
803 803 bookA 2:e5bfe23c0b47
804 804
805 805 The default path should be the remote, not the share
806 806
807 807 $ hg -R share-dest1a config paths.default
808 808 $TESTTMP/source1a (glob)
809 809
810 810 Clone with existing share dir should result in pull + share
811 811
812 812 $ hg --config share.pool=share clone source1b share-dest1b
813 813 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
814 814 searching for changes
815 815 adding changesets
816 816 adding manifests
817 817 adding file changes
818 818 added 4 changesets with 4 changes to 1 files (+4 heads)
819 819 adding remote bookmark head1
820 820 adding remote bookmark head2
821 821 updating working directory
822 822 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
823 823
824 824 $ ls share
825 825 b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
826 826
827 827 $ cat share-dest1b/.hg/sharedpath; echo
828 828 $TESTTMP/share/b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1/.hg (glob)
829 829
830 830 We only get bookmarks from the remote, not everything in the share
831 831
832 832 $ hg -R share-dest1b bookmarks
833 833 head1 3:4a8dc1ab4c13
834 834 head2 4:99f71071f117
835 835
836 836 Default path should be source, not share.
837 837
838 838 $ hg -R share-dest1b config paths.default
839 839 $TESTTMP/source1b (glob)
840 840
841 841 Checked out revision should be head of default branch
842 842
843 843 $ hg -R share-dest1b log -r .
844 844 changeset: 4:99f71071f117
845 845 bookmark: head2
846 846 parent: 0:b5f04eac9d8f
847 847 user: test
848 848 date: Thu Jan 01 00:00:00 1970 +0000
849 849 summary: head2
850 850
851 851
852 852 Clone from unrelated repo should result in new share
853 853
854 854 $ hg --config share.pool=share clone source2 share-dest2
855 855 (sharing from new pooled repository 22aeff664783fd44c6d9b435618173c118c3448e)
856 856 requesting all changes
857 857 adding changesets
858 858 adding manifests
859 859 adding file changes
860 860 added 2 changesets with 2 changes to 1 files
861 861 searching for changes
862 862 no changes found
863 863 updating working directory
864 864 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
865 865
866 866 $ ls share
867 867 22aeff664783fd44c6d9b435618173c118c3448e
868 868 b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
869 869
870 870 remote naming mode works as advertised
871 871
872 872 $ hg --config share.pool=shareremote --config share.poolnaming=remote clone source1a share-remote1a
873 873 (sharing from new pooled repository 195bb1fcdb595c14a6c13e0269129ed78f6debde)
874 874 requesting all changes
875 875 adding changesets
876 876 adding manifests
877 877 adding file changes
878 878 added 3 changesets with 3 changes to 1 files
879 879 searching for changes
880 880 no changes found
881 881 adding remote bookmark bookA
882 882 updating working directory
883 883 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
884 884
885 885 $ ls shareremote
886 886 195bb1fcdb595c14a6c13e0269129ed78f6debde
887 887
888 888 $ hg --config share.pool=shareremote --config share.poolnaming=remote clone source1b share-remote1b
889 889 (sharing from new pooled repository c0d4f83847ca2a873741feb7048a45085fd47c46)
890 890 requesting all changes
891 891 adding changesets
892 892 adding manifests
893 893 adding file changes
894 894 added 6 changesets with 6 changes to 1 files (+4 heads)
895 895 searching for changes
896 896 no changes found
897 897 adding remote bookmark head1
898 898 adding remote bookmark head2
899 899 updating working directory
900 900 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
901 901
902 902 $ ls shareremote
903 903 195bb1fcdb595c14a6c13e0269129ed78f6debde
904 904 c0d4f83847ca2a873741feb7048a45085fd47c46
905 905
906 906 request to clone a single revision is respected in sharing mode
907 907
908 908 $ hg --config share.pool=sharerevs clone -r 4a8dc1ab4c13 source1b share-1arev
909 909 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
910 910 adding changesets
911 911 adding manifests
912 912 adding file changes
913 913 added 2 changesets with 2 changes to 1 files
914 914 no changes found
915 915 adding remote bookmark head1
916 916 updating working directory
917 917 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
918 918
919 919 $ hg -R share-1arev log -G
920 920 @ changeset: 1:4a8dc1ab4c13
921 921 | bookmark: head1
922 922 | tag: tip
923 923 | user: test
924 924 | date: Thu Jan 01 00:00:00 1970 +0000
925 925 | summary: head1
926 926 |
927 927 o changeset: 0:b5f04eac9d8f
928 928 user: test
929 929 date: Thu Jan 01 00:00:00 1970 +0000
930 930 summary: initial
931 931
932 932
933 933 making another clone should only pull down requested rev
934 934
935 935 $ hg --config share.pool=sharerevs clone -r 99f71071f117 source1b share-1brev
936 936 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
937 937 searching for changes
938 938 adding changesets
939 939 adding manifests
940 940 adding file changes
941 941 added 1 changesets with 1 changes to 1 files (+1 heads)
942 942 adding remote bookmark head1
943 943 adding remote bookmark head2
944 944 updating working directory
945 945 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
946 946
947 947 $ hg -R share-1brev log -G
948 948 @ changeset: 2:99f71071f117
949 949 | bookmark: head2
950 950 | tag: tip
951 951 | parent: 0:b5f04eac9d8f
952 952 | user: test
953 953 | date: Thu Jan 01 00:00:00 1970 +0000
954 954 | summary: head2
955 955 |
956 956 | o changeset: 1:4a8dc1ab4c13
957 957 |/ bookmark: head1
958 958 | user: test
959 959 | date: Thu Jan 01 00:00:00 1970 +0000
960 960 | summary: head1
961 961 |
962 962 o changeset: 0:b5f04eac9d8f
963 963 user: test
964 964 date: Thu Jan 01 00:00:00 1970 +0000
965 965 summary: initial
966 966
967 967
968 968 Request to clone a single branch is respected in sharing mode
969 969
970 970 $ hg --config share.pool=sharebranch clone -b branch1 source1b share-1bbranch1
971 971 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
972 972 adding changesets
973 973 adding manifests
974 974 adding file changes
975 975 added 2 changesets with 2 changes to 1 files
976 976 no changes found
977 977 updating working directory
978 978 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
979 979
980 980 $ hg -R share-1bbranch1 log -G
981 981 o changeset: 1:5f92a6c1a1b1
982 982 | branch: branch1
983 983 | tag: tip
984 984 | user: test
985 985 | date: Thu Jan 01 00:00:00 1970 +0000
986 986 | summary: branch1
987 987 |
988 988 @ changeset: 0:b5f04eac9d8f
989 989 user: test
990 990 date: Thu Jan 01 00:00:00 1970 +0000
991 991 summary: initial
992 992
993 993
994 994 $ hg --config share.pool=sharebranch clone -b branch2 source1b share-1bbranch2
995 995 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
996 996 searching for changes
997 997 adding changesets
998 998 adding manifests
999 999 adding file changes
1000 1000 added 1 changesets with 1 changes to 1 files (+1 heads)
1001 1001 updating working directory
1002 1002 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1003 1003
1004 1004 $ hg -R share-1bbranch2 log -G
1005 1005 o changeset: 2:6bacf4683960
1006 1006 | branch: branch2
1007 1007 | tag: tip
1008 1008 | parent: 0:b5f04eac9d8f
1009 1009 | user: test
1010 1010 | date: Thu Jan 01 00:00:00 1970 +0000
1011 1011 | summary: branch2
1012 1012 |
1013 1013 | o changeset: 1:5f92a6c1a1b1
1014 1014 |/ branch: branch1
1015 1015 | user: test
1016 1016 | date: Thu Jan 01 00:00:00 1970 +0000
1017 1017 | summary: branch1
1018 1018 |
1019 1019 @ changeset: 0:b5f04eac9d8f
1020 1020 user: test
1021 1021 date: Thu Jan 01 00:00:00 1970 +0000
1022 1022 summary: initial
1023 1023
1024 1024
1025 1025 -U is respected in share clone mode
1026 1026
1027 1027 $ hg --config share.pool=share clone -U source1a share-1anowc
1028 1028 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
1029 1029 searching for changes
1030 1030 no changes found
1031 1031 adding remote bookmark bookA
1032 1032
1033 1033 $ ls share-1anowc
1034 1034
1035 1035 Test that auto sharing doesn't cause failure of "hg clone local remote"
1036 1036
1037 1037 $ cd $TESTTMP
1038 1038 $ hg -R a id -r 0
1039 1039 acb14030fe0a
1040 1040 $ hg id -R remote -r 0
1041 1041 abort: repository remote not found!
1042 1042 [255]
1043 1043 $ hg --config share.pool=share -q clone -e "python \"$TESTDIR/dummyssh\"" a ssh://user@dummy/remote
1044 1044 $ hg -R remote id -r 0
1045 1045 acb14030fe0a
1046 1046
1047 1047 Cloning into pooled storage doesn't race (issue5104)
1048 1048
1049 1049 $ HGPOSTLOCKDELAY=2.0 hg --config share.pool=racepool --config extensions.lockdelay=$TESTDIR/lockdelay.py clone source1a share-destrace1 > race1.log 2>&1 &
1050 1050 $ HGPRELOCKDELAY=1.0 hg --config share.pool=racepool --config extensions.lockdelay=$TESTDIR/lockdelay.py clone source1a share-destrace2 > race2.log 2>&1
1051 1051 $ wait
1052 1052
1053 1053 $ hg -R share-destrace1 log -r tip
1054 1054 changeset: 2:e5bfe23c0b47
1055 1055 bookmark: bookA
1056 1056 tag: tip
1057 1057 user: test
1058 1058 date: Thu Jan 01 00:00:00 1970 +0000
1059 1059 summary: 1a
1060 1060
1061 1061
1062 1062 $ hg -R share-destrace2 log -r tip
1063 1063 changeset: 2:e5bfe23c0b47
1064 1064 bookmark: bookA
1065 1065 tag: tip
1066 1066 user: test
1067 1067 date: Thu Jan 01 00:00:00 1970 +0000
1068 1068 summary: 1a
1069 1069
1070 1070 One repo should be new, the other should be shared from the pool. We
1071 1071 don't care which is which, so we just make sure we always print the
1072 1072 one containing "new pooled" first, then one one containing "existing
1073 1073 pooled".
1074 1074
1075 1075 $ (grep 'new pooled' race1.log > /dev/null && cat race1.log || cat race2.log) | grep -v lock
1076 1076 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
1077 1077 requesting all changes
1078 1078 adding changesets
1079 1079 adding manifests
1080 1080 adding file changes
1081 1081 added 3 changesets with 3 changes to 1 files
1082 1082 searching for changes
1083 1083 no changes found
1084 1084 adding remote bookmark bookA
1085 1085 updating working directory
1086 1086 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1087 1087
1088 1088 $ (grep 'existing pooled' race1.log > /dev/null && cat race1.log || cat race2.log) | grep -v lock
1089 1089 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
1090 1090 searching for changes
1091 1091 no changes found
1092 1092 adding remote bookmark bookA
1093 1093 updating working directory
1094 1094 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1095
1096 SEC: check for unsafe ssh url
1097
1098 $ hg clone 'ssh://-oProxyCommand=touch${IFS}owned/path'
1099 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
1100 [255]
1101 $ hg clone 'ssh://%2DoProxyCommand=touch${IFS}owned/path'
1102 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path'
1103 [255]
1104 $ hg clone 'ssh://fakehost|shellcommand/path'
1105 abort: potentially unsafe url: 'ssh://fakehost|shellcommand/path'
1106 [255]
1107 $ hg clone 'ssh://fakehost%7Cshellcommand/path'
1108 abort: potentially unsafe url: 'ssh://fakehost|shellcommand/path'
1109 [255]
1110
1111 $ hg clone 'ssh://-oProxyCommand=touch owned%20foo@example.com/nonexistent/path'
1112 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch owned foo@example.com/nonexistent/path'
1113 [255]
1114 We should not have created a file named owned - if it exists, the
1115 attack succeeded.
1116 $ if test -f owned; then echo 'you got owned'; fi
General Comments 0
You need to be logged in to leave comments. Login now