1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
|
$ hg init repo
$ cd repo
New file:
$ hg import -d "1000000 0" -mnew - <<EOF
> diff --git a/new b/new
> new file mode 100644
> index 0000000..7898192
> --- /dev/null
> +++ b/new
> @@ -0,0 +1 @@
> +a
> EOF
applying patch from stdin
$ hg tip -q
0:ae3ee40d2079
New empty file:
$ hg import -d "1000000 0" -mempty - <<EOF
> diff --git a/empty b/empty
> new file mode 100644
> EOF
applying patch from stdin
$ hg tip -q
1:ab199dc869b5
$ hg locate empty
empty
chmod +x:
$ hg import -d "1000000 0" -msetx - <<EOF
> diff --git a/new b/new
> old mode 100644
> new mode 100755
> EOF
applying patch from stdin
#if execbit
$ hg tip -q
2:3a34410f282e
$ test -x new
$ hg rollback -q
#else
$ hg tip -q
1:ab199dc869b5
#endif
Copy and removing x bit:
$ hg import -f -d "1000000 0" -mcopy - <<EOF
> diff --git a/new b/copy
> old mode 100755
> new mode 100644
> similarity index 100%
> copy from new
> copy to copy
> diff --git a/new b/copyx
> similarity index 100%
> copy from new
> copy to copyx
> EOF
applying patch from stdin
$ test -f copy
#if execbit
$ test ! -x copy
$ test -x copyx
$ hg tip -q
2:21dfaae65c71
#else
$ hg tip -q
2:0efdaa8e3bf3
#endif
$ hg up -qCr1
$ hg rollback -q
Copy (like above but independent of execbit):
$ hg import -d "1000000 0" -mcopy - <<EOF
> diff --git a/new b/copy
> similarity index 100%
> copy from new
> copy to copy
> diff --git a/new b/copyx
> similarity index 100%
> copy from new
> copy to copyx
> EOF
applying patch from stdin
$ hg tip -q
2:0efdaa8e3bf3
$ test -f copy
$ cat copy
a
$ hg cat copy
a
Rename:
$ hg import -d "1000000 0" -mrename - <<EOF
> diff --git a/copy b/rename
> similarity index 100%
> rename from copy
> rename to rename
> EOF
applying patch from stdin
$ hg tip -q
3:b1f57753fad2
$ hg locate
copyx
empty
new
rename
Delete:
$ hg import -d "1000000 0" -mdelete - <<EOF
> diff --git a/copyx b/copyx
> deleted file mode 100755
> index 7898192..0000000
> --- a/copyx
> +++ /dev/null
> @@ -1 +0,0 @@
> -a
> EOF
applying patch from stdin
$ hg tip -q
4:1bd1da94b9b2
$ hg locate
empty
new
rename
$ test -f copyx
[1]
Regular diff:
$ hg import -d "1000000 0" -mregular - <<EOF
> diff --git a/rename b/rename
> index 7898192..72e1fe3 100644
> --- a/rename
> +++ b/rename
> @@ -1 +1,5 @@
> a
> +a
> +a
> +a
> +a
> EOF
applying patch from stdin
$ hg tip -q
5:46fe99cb3035
Copy and modify:
$ hg import -d "1000000 0" -mcopymod - <<EOF
> diff --git a/rename b/copy2
> similarity index 80%
> copy from rename
> copy to copy2
> index 72e1fe3..b53c148 100644
> --- a/rename
> +++ b/copy2
> @@ -1,5 +1,5 @@
> a
> a
> -a
> +b
> a
> a
> EOF
applying patch from stdin
$ hg tip -q
6:ffeb3197c12d
$ hg cat copy2
a
a
b
a
a
Rename and modify:
$ hg import -d "1000000 0" -mrenamemod - <<EOF
> diff --git a/copy2 b/rename2
> similarity index 80%
> rename from copy2
> rename to rename2
> index b53c148..8f81e29 100644
> --- a/copy2
> +++ b/rename2
> @@ -1,5 +1,5 @@
> a
> a
> b
> -a
> +c
> a
> EOF
applying patch from stdin
$ hg tip -q
7:401aede9e6bb
$ hg locate copy2
[1]
$ hg cat rename2
a
a
b
c
a
One file renamed multiple times:
$ hg import -d "1000000 0" -mmultirenames - <<EOF
> diff --git a/rename2 b/rename3
> rename from rename2
> rename to rename3
> diff --git a/rename2 b/rename3-2
> rename from rename2
> rename to rename3-2
> EOF
applying patch from stdin
$ hg tip -q
8:2ef727e684e8
$ hg log -vr. --template '{rev} {files} / {file_copies}\n'
8 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
$ hg locate rename2 rename3 rename3-2
rename3
rename3-2
$ hg cat rename3
a
a
b
c
a
$ hg cat rename3-2
a
a
b
c
a
$ echo foo > foo
$ hg add foo
$ hg ci -m 'add foo'
Binary files and regular patch hunks:
$ hg import -d "1000000 0" -m binaryregular - <<EOF
> diff --git a/binary b/binary
> new file mode 100644
> index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
> GIT binary patch
> literal 4
> Lc\${NkU|;|M00aO5
>
> diff --git a/foo b/foo2
> rename from foo
> rename to foo2
> EOF
applying patch from stdin
$ hg tip -q
10:27377172366e
$ cat foo2
foo
$ hg manifest --debug | grep binary
045c85ba38952325e126c70962cc0f9d9077bc67 644 binary
Multiple binary files:
$ hg import -d "1000000 0" -m multibinary - <<EOF
> diff --git a/mbinary1 b/mbinary1
> new file mode 100644
> index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
> GIT binary patch
> literal 4
> Lc\${NkU|;|M00aO5
>
> diff --git a/mbinary2 b/mbinary2
> new file mode 100644
> index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490
> GIT binary patch
> literal 5
> Mc\${NkU|\`?^000jF3jhEB
>
> EOF
applying patch from stdin
$ hg tip -q
11:18b73a84b4ab
$ hg manifest --debug | grep mbinary
045c85ba38952325e126c70962cc0f9d9077bc67 644 mbinary1
a874b471193996e7cb034bb301cac7bdaf3e3f46 644 mbinary2
Binary file and delta hunk (we build the patch using this sed hack to
avoid an unquoted ^, which check-code says breaks sh on Solaris):
$ sed 's/ caret /^/g;s/ dollarparen /$(/g' > quote-hack.patch <<'EOF'
> diff --git a/delta b/delta
> new file mode 100644
> index 0000000000000000000000000000000000000000..8c9b7831b231c2600843e303e66b521353a200b3
> GIT binary patch
> literal 3749
> zcmV;W4qEYvP)<h;3K|Lk000e1NJLTq006iE002D*0ssI2kt{U(0000PbVXQnQ*UN;
> zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU=M@d9MRCwC#oC!>o#}>x{(W-y~UN*tK
> z%A%sxiUy2Ys)0Vm#ueArYKoYqX;GuiqZpgirM6nCVoYk?YNAz3G~z;BZ~@~&OQEe4
> zmGvS5isFJI;Pd_7J+EKxyHZeu` caret t4r2>F;h-+VK3{_{WoGv8dSpFDYDrA%3UX03pt
> zOaVoi0*W#P6lDr1$`nwPDWE7*rhuYM0Y#YtiZTThWeO<D6i}2YpqR<%$s>bRRaI42
> zS3iFIxJ8Q=EnBv1Z7?pBw_bLjJb3V+tgP(Tty_2R-mR#p04x78n2n7MSOFyt4i1iv
> zjxH`PPEJmgD7U?IK&h;(EGQ@_DJc<@01=4fiNXHcKZ8LhZQ8T}E3U4tUS3}OrcgQW
> zWdX{K8#l7Ev&#$ysR)G#0*rC+<WGZ3?CtG4bm-ve>Dj$|_qJ`@D*stNP_AFUe&x!Q
> zJ9q9B7Z=ym)MyZ?Tg1ROunUYr81nV?B@!tYS~5_|%gfW#(_s<4UN1!Q?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%&|Ni~t
> zKJ(|#H`$<5W+6ZkBb213rXonKZLB+X> caret L}J@W6osP3piLD_5?R!`S}*{xLBzFiL4@
> zX+}l{`A%?f@T5tT%ztu60p;)be`fWC`tP@WpO=?cpf8Xuf1OSj6d3f@Ki(ovDYq%0
> z{4ZSe`kOay5@=lAT!}vFzxyemC{sXDrhuYM0Y#ZI1r%ipD9W11{w=@&xgJ}t2x;ep
> P00000NkvXXu0mjfZ5|Er
>
> literal 0
> HcmV?d00001
>
> EOF
$ hg import -d "1000000 0" -m delta quote-hack.patch
applying quote-hack.patch
$ rm quote-hack.patch
$ hg manifest --debug | grep delta
9600f98bb60ce732634d126aaa4ac1ec959c573e 644 delta
$ hg import -d "1000000 0" -m delta - <<'EOF'
> diff --git a/delta b/delta
> index 8c9b7831b231c2600843e303e66b521353a200b3..0021dd95bc0dba53c39ce81377126d43731d68df 100644
> GIT binary patch
> delta 49
> zcmZ1~yHs|=21Z8J$r~9bFdA-lVv=EEw4WT$qRf2QSa5SIOAHI6(&k4T8H|kLo4vWB
> FSO9ZT4bA`n
>
> delta 49
> zcmV-10M7rV9i<(xumJ(}ld%Di0Xefm0vrMXpOaq%BLm9I%d>?9Tm%6Vv*HM70RcC&
> HOA1;9yU-AD
>
> EOF
applying patch from stdin
$ hg manifest --debug | grep delta
56094bbea136dcf8dbd4088f6af469bde1a98b75 644 delta
Filenames with spaces:
$ sed 's,EOL$,,g' <<EOF | hg import -d "1000000 0" -m spaces -
> diff --git a/foo bar b/foo bar
> new file mode 100644
> index 0000000..257cc56
> --- /dev/null
> +++ b/foo bar EOL
> @@ -0,0 +1 @@
> +foo
> EOF
applying patch from stdin
$ hg tip -q
14:4b79479c9a6d
$ cat "foo bar"
foo
Copy then modify the original file:
$ hg import -d "1000000 0" -m copy-mod-orig - <<EOF
> diff --git a/foo2 b/foo2
> index 257cc56..fe08ec6 100644
> --- a/foo2
> +++ b/foo2
> @@ -1 +1,2 @@
> foo
> +new line
> diff --git a/foo2 b/foo3
> similarity index 100%
> copy from foo2
> copy to foo3
> EOF
applying patch from stdin
$ hg tip -q
15:9cbe44af4ae9
$ cat foo3
foo
Move text file and patch as binary
$ echo a > text2
$ hg ci -Am0
adding text2
$ hg import -d "1000000 0" -m rename-as-binary - <<"EOF"
> diff --git a/text2 b/binary2
> rename from text2
> rename to binary2
> index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757
> GIT binary patch
> literal 5
> Mc$`b*O5$Pw00T?_*Z=?k
>
> EOF
applying patch from stdin
$ cat binary2
a
b
\x00 (no-eol) (esc)
$ hg st --copies --change .
A binary2
text2
R text2
Invalid base85 content
$ hg rollback
repository tip rolled back to revision 16 (undo import)
working directory now based on revision 16
$ hg revert -aq
$ hg import -d "1000000 0" -m invalid-binary - <<"EOF"
> diff --git a/text2 b/binary2
> rename from text2
> rename to binary2
> index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757
> GIT binary patch
> literal 5
> Mc$`b*O.$Pw00T?_*Z=?k
>
> EOF
applying patch from stdin
abort: could not decode "binary2" binary patch: bad base85 character at position 6
[255]
$ hg revert -aq
$ hg import -d "1000000 0" -m rename-as-binary - <<"EOF"
> diff --git a/text2 b/binary2
> rename from text2
> rename to binary2
> index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757
> GIT binary patch
> literal 6
> Mc$`b*O5$Pw00T?_*Z=?k
>
> EOF
applying patch from stdin
abort: "binary2" length is 5 bytes, should be 6
[255]
$ hg revert -aq
$ hg import -d "1000000 0" -m rename-as-binary - <<"EOF"
> diff --git a/text2 b/binary2
> rename from text2
> rename to binary2
> index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757
> GIT binary patch
> Mc$`b*O5$Pw00T?_*Z=?k
>
> EOF
applying patch from stdin
abort: could not extract "binary2" binary data
[255]
Simulate a copy/paste turning LF into CRLF (issue2870)
$ hg revert -aq
$ cat > binary.diff <<"EOF"
> diff --git a/text2 b/binary2
> rename from text2
> rename to binary2
> index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757
> GIT binary patch
> literal 5
> Mc$`b*O5$Pw00T?_*Z=?k
>
> EOF
>>> fp = open('binary.diff', 'rb')
>>> data = fp.read()
>>> fp.close()
>>> open('binary.diff', 'wb').write(data.replace(b'\n', b'\r\n')) and None
$ rm binary2
$ hg import --no-commit binary.diff
applying binary.diff
$ cd ..
Consecutive import with renames (issue2459)
$ hg init issue2459
$ cd issue2459
$ hg import --no-commit --force - <<EOF
> diff --git a/a b/a
> new file mode 100644
> EOF
applying patch from stdin
$ hg import --no-commit --force - <<EOF
> diff --git a/a b/b
> rename from a
> rename to b
> EOF
applying patch from stdin
a has not been committed yet, so no copy data will be stored for b.
$ hg debugstate
a 0 -1 unset b
$ hg ci -m done
$ cd ..
Renames and strip
$ hg init renameandstrip
$ cd renameandstrip
$ echo a > a
$ hg ci -Am adda
adding a
$ hg import --no-commit -p2 - <<EOF
> diff --git a/foo/a b/foo/b
> rename from foo/a
> rename to foo/b
> EOF
applying patch from stdin
$ hg st --copies
A b
a
R a
Prefix with strip, renames, creates etc
$ hg revert -aC
forgetting b
undeleting a
$ rm b
$ mkdir -p dir/dir2
$ echo b > dir/dir2/b
$ echo c > dir/dir2/c
$ echo d > dir/d
$ hg ci -Am addbcd
adding dir/d
adding dir/dir2/b
adding dir/dir2/c
prefix '.' is the same as no prefix
$ hg import --no-commit --prefix . - <<EOF
> diff --git a/dir/a b/dir/a
> --- /dev/null
> +++ b/dir/a
> @@ -0,0 +1 @@
> +aaaa
> diff --git a/dir/d b/dir/d
> --- a/dir/d
> +++ b/dir/d
> @@ -1,1 +1,2 @@
> d
> +dddd
> EOF
applying patch from stdin
$ cat dir/a
aaaa
$ cat dir/d
d
dddd
$ hg revert -aC
forgetting dir/a
reverting dir/d
$ rm dir/a
prefix with default strip
$ hg import --no-commit --prefix dir/ - <<EOF
> diff --git a/a b/a
> --- /dev/null
> +++ b/a
> @@ -0,0 +1 @@
> +aaa
> diff --git a/d b/d
> --- a/d
> +++ b/d
> @@ -1,1 +1,2 @@
> d
> +dd
> EOF
applying patch from stdin
$ cat dir/a
aaa
$ cat dir/d
d
dd
$ hg revert -aC
forgetting dir/a
reverting dir/d
$ rm dir/a
(test that prefixes are relative to the cwd)
$ mkdir tmpdir
$ cd tmpdir
$ hg import --no-commit -p2 --prefix ../dir/ - <<EOF
> diff --git a/foo/a b/foo/a
> new file mode 100644
> --- /dev/null
> +++ b/foo/a
> @@ -0,0 +1 @@
> +a
> diff --git a/foo/dir2/b b/foo/dir2/b2
> rename from foo/dir2/b
> rename to foo/dir2/b2
> diff --git a/foo/dir2/c b/foo/dir2/c
> --- a/foo/dir2/c
> +++ b/foo/dir2/c
> @@ -0,0 +1 @@
> +cc
> diff --git a/foo/d b/foo/d
> deleted file mode 100644
> --- a/foo/d
> +++ /dev/null
> @@ -1,1 +0,0 @@
> -d
> EOF
applying patch from stdin
$ hg st --copies
M dir/dir2/c
A dir/a
A dir/dir2/b2
dir/dir2/b
R dir/d
R dir/dir2/b
$ cd ..
Renames, similarity and git diff
$ hg revert -aC
forgetting dir/a
forgetting dir/dir2/b2
reverting dir/dir2/c
undeleting dir/d
undeleting dir/dir2/b
$ rm dir/a dir/dir2/b2
$ hg import --similarity 90 --no-commit - <<EOF
> diff --git a/a b/b
> rename from a
> rename to b
> EOF
applying patch from stdin
$ hg st --copies
A b
a
R a
$ cd ..
Pure copy with existing destination
$ hg init copytoexisting
$ cd copytoexisting
$ echo a > a
$ echo b > b
$ hg ci -Am add
adding a
adding b
$ hg import --no-commit - <<EOF
> diff --git a/a b/b
> copy from a
> copy to b
> EOF
applying patch from stdin
abort: cannot create b: destination already exists
[255]
$ cat b
b
Copy and changes with existing destination
$ hg import --no-commit - <<EOF
> diff --git a/a b/b
> copy from a
> copy to b
> --- a/a
> +++ b/b
> @@ -1,1 +1,2 @@
> a
> +b
> EOF
applying patch from stdin
cannot create b: destination already exists
1 out of 1 hunks FAILED -- saving rejects to file b.rej
abort: patch failed to apply
[255]
$ cat b
b
#if symlink
$ ln -s b linkb
$ hg add linkb
$ hg ci -m addlinkb
$ hg import --no-commit - <<EOF
> diff --git a/linkb b/linkb
> deleted file mode 120000
> --- a/linkb
> +++ /dev/null
> @@ -1,1 +0,0 @@
> -badhunk
> \ No newline at end of file
> EOF
applying patch from stdin
patching file linkb
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file linkb.rej
abort: patch failed to apply
[255]
$ hg st
? b.rej
? linkb.rej
#endif
Test corner case involving copies and multiple hunks (issue3384)
$ hg revert -qa
$ hg import --no-commit - <<EOF
> diff --git a/a b/c
> copy from a
> copy to c
> --- a/a
> +++ b/c
> @@ -1,1 +1,2 @@
> a
> +a
> @@ -2,1 +2,2 @@
> a
> +a
> diff --git a/a b/a
> --- a/a
> +++ b/a
> @@ -1,1 +1,2 @@
> a
> +b
> EOF
applying patch from stdin
Test email metadata
$ hg revert -qa
$ hg --encoding utf-8 import - <<EOF
> From: =?utf-8?q?Rapha=C3=ABl_Hertzog_=3Chertzog=40debian=2Eorg=3E?=
> Subject: [PATCH] =?UTF-8?q?=C5=A7=E2=82=AC=C3=9F=E1=B9=AA?=
>
> diff --git a/a b/a
> --- a/a
> +++ b/a
> @@ -1,1 +1,2 @@
> a
> +a
> EOF
applying patch from stdin
$ hg --encoding utf-8 log -r .
changeset: *:* (glob)
tag: tip
user: Rapha\xc3\xabl Hertzog <hertzog@debian.org> (esc)
date: * (glob)
summary: \xc5\xa7\xe2\x82\xac\xc3\x9f\xe1\xb9\xaa (esc)
$ cd ..
|