Changeset 151300 in webkit
- Timestamp:
- Jun 6, 2013 4:37:24 PM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r151294 r151300 1 2013-06-06 Yuki Sekiguchi <yuki.sekiguchi@access-company.com> 2 3 svn-apply cannot apply patches which is generated by git to files that contain space characters in their path 4 https://bugs.webkit.org/show_bug.cgi?id=111066 5 6 Reviewed by Daniel Bates. 7 8 Fixes an issue where parseGitDiffHeader() would extract the wrong substring of the diff --git line as the target file path when the source file path contains a space character. 9 10 ParseGitDiffHeader() should support the path which line has space characters. 11 To support this, I changed parsing algorithm like the following: 12 - When the diff have prefix, we consider next characters after "b/" as part of a file path. 13 - When the diff have no prefix, we assume that both path have same directory prefix, and we split the diff line using the prefix. 14 15 We only support --src-prefix and --dst-prefix don't contain a non-word character (\W) and end with '/' because we cannot distinguish the prefix from directory path. 16 17 If the path has a tab, the patch(1) command thinks file path is characters before the tab. 18 I added a dummy tab and revision when we convert git diff to svn diff. 19 20 * Scripts/VCSUtils.pm: 21 (parseGitDiffHeader): 22 * Scripts/webkitperl/VCSUtils_unittest/parseDiff.pl: Update expectations for dummy revision. 23 * Scripts/webkitperl/VCSUtils_unittest/parseDiffWithMockFiles.pl: Ditto. 24 * Scripts/webkitperl/VCSUtils_unittest/parseGitDiffHeader.pl: Ditto. 25 - Added test case for files which have space in their path and --src-prefix and --dst-prefix option. 26 1 27 2013-06-06 Simon Fraser <simon.fraser@apple.com> 2 28 -
trunk/Tools/Scripts/VCSUtils.pm
r146249 r151300 108 108 my $changeLogTimeZone = "PST8PDT"; 109 109 110 my $gitDiffStartRegEx = qr#^diff --git (\w/)?(.+) (\w/)?([^\r\n]+)#; 110 my $gitDiffStartRegEx = qr#^diff --git [^\r\n]+#; 111 my $gitDiffStartWithPrefixRegEx = qr#^diff --git \w/(.+) \w/([^\r\n]+)#; # We suppose that --src-prefix and --dst-prefix don't contain a non-word character (\W) and end with '/'. 112 my $gitDiffStartWithoutPrefixNoSpaceRegEx = qr#^diff --git (\S+) (\S+)$#; 111 113 my $svnDiffStartRegEx = qr#^Index: ([^\r\n]+)#; 114 my $gitDiffStartWithoutPrefixSourceDirectoryPrefixRegExp = qr#^diff --git ([^/]+/)#; 112 115 my $svnPropertiesStartRegEx = qr#^Property changes on: ([^\r\n]+)#; # $1 is normally the same as the index path. 113 116 my $svnPropertyStartRegEx = qr#^(Modified|Name|Added|Deleted): ([^\r\n]+)#; # $2 is the name of the property. … … 614 617 615 618 return $fileMode % 2; 619 } 620 621 # Parse the Git diff header start line. 622 # 623 # Args: 624 # $line: "diff --git" line. 625 # 626 # Returns the path of the target file. 627 sub parseGitDiffStartLine($) 628 { 629 my $line = shift; 630 $_ = $line; 631 if (/$gitDiffStartWithPrefixRegEx/ || /$gitDiffStartWithoutPrefixNoSpaceRegEx/) { 632 return $2; 633 } 634 # Assume the diff was generated with --no-prefix (e.g. git diff --no-prefix). 635 if (!/$gitDiffStartWithoutPrefixSourceDirectoryPrefixRegExp/) { 636 # FIXME: Moving top directory file is not supported (e.g diff --git A.txt B.txt). 637 die("Could not find '/' in \"diff --git\" line: \"$line\"; only non-prefixed git diffs (i.e. not generated with --no-prefix) that move a top-level directory file are supported."); 638 } 639 my $pathPrefix = $1; 640 if (!/^diff --git \Q$pathPrefix\E.+ (\Q$pathPrefix\E.+)$/) { 641 # FIXME: Moving a file through sub directories of top directory is not supported (e.g diff --git A/B.txt C/B.txt). 642 die("Could not find '/' in \"diff --git\" line: \"$line\"; only non-prefixed git diffs (i.e. not generated with --no-prefix) that move a file between top-level directories are supported."); 643 } 644 return $1; 616 645 } 617 646 … … 657 686 my $indexPath; 658 687 if (/$gitDiffStartRegEx/) { 688 # Use $POSTMATCH to preserve the end-of-line character. 689 my $eol = $POSTMATCH; 690 659 691 # The first and second paths can differ in the case of copies 660 692 # and renames. We use the second file path because it is the 661 693 # destination path. 662 $indexPath = adjustPathForRecentRenamings( $4);663 # Use $POSTMATCH to preserve the end-of-line character. 664 $_ = "Index: $indexPath$ POSTMATCH"; # Convert to SVN format.694 $indexPath = adjustPathForRecentRenamings(parseGitDiffStartLine($_)); 695 696 $_ = "Index: $indexPath$eol"; # Convert to SVN format. 665 697 } else { 666 698 die("Could not parse leading \"diff --git\" line: \"$line\"."); … … 691 723 } elsif (/^similarity index (\d+)%/) { 692 724 $similarityIndex = $1; 693 } elsif (/^copy from ( \S+)/) {725 } elsif (/^copy from ([^\t\r\n]+)/) { 694 726 $copiedFromPath = $1; 695 } elsif (/^rename from ( \S+)/) {727 } elsif (/^rename from ([^\t\r\n]+)/) { 696 728 # FIXME: Record this as a move rather than as a copy-and-delete. 697 729 # This will simplify adding rename support to svn-unapply. … … 703 735 $shouldDeleteSource = 1; 704 736 } elsif (/^--- \S+/) { 705 $_ = "--- $indexPath"; # Convert to SVN format. 737 # Convert to SVN format. 738 # We emit the suffix "\t(revision 0)" to handle $indexPath which contains a space character. 739 # The patch(1) command thinks a file path is characters before a tab. 740 # This suffix make our diff more closely match the SVN diff format. 741 $_ = "--- $indexPath\t(revision 0)"; 706 742 } elsif (/^\+\+\+ \S+/) { 707 $_ = "+++ $indexPath"; # Convert to SVN format. 743 # Convert to SVN format. 744 # We emit the suffix "\t(working copy)" to handle $indexPath which contains a space character. 745 # The patch(1) command thinks a file path is characters before a tab. 746 # This suffix make our diff more closely match the SVN diff format. 747 $_ = "+++ $indexPath\t(working copy)"; 708 748 $foundHeaderEnding = 1; 709 749 } elsif (/^GIT binary patch$/ ) { -
trunk/Tools/Scripts/webkitperl/VCSUtils_unittest/parseDiff.pl
r87641 r151300 981 981 expectedReturn => [ 982 982 [{ 983 svnConvertedText => << 'END',983 svnConvertedText => <<"END", 984 984 Index: Makefile 985 985 index f5d5e74..3b6aa92 100644 986 --- Makefile 987 +++ Makefile 986 --- Makefile\t(revision 0) 987 +++ Makefile\t(working copy) 988 988 @@ -1,1 +1,1 @@ public: 989 989 END … … 1009 1009 expectedReturn => [ 1010 1010 [{ 1011 svnConvertedText => << 'END',1011 svnConvertedText => <<"END", 1012 1012 Index: foo 1013 1013 index 863339f..db418b2 100644 1014 --- foo 1015 +++ foo 1014 --- foo\t(revision 0) 1015 +++ foo\t(working copy) 1016 1016 @@ -1 +1,2 @@ 1017 1017 Passed … … 1040 1040 expectedReturn => [ 1041 1041 [{ 1042 svnConvertedText => << 'END',1042 svnConvertedText => <<"END", 1043 1043 Index: foo.h 1044 1044 new file mode 100644 1045 1045 index 0000000..3c9f114 1046 --- foo.h 1047 +++ foo.h 1046 --- foo.h\t(revision 0) 1047 +++ foo.h\t(working copy) 1048 1048 @@ -0,0 +1,34 @@ 1049 1049 +<html> … … 1072 1072 expectedReturn => [ 1073 1073 [{ 1074 svnConvertedText => << 'END',1074 svnConvertedText => <<"END", 1075 1075 Index: foo 1076 1076 deleted file mode 100644 1077 1077 index 1e50d1d..0000000 1078 --- foo 1079 +++ foo 1078 --- foo\t(revision 0) 1079 +++ foo\t(working copy) 1080 1080 @@ -1,1 +0,0 @@ 1081 1081 -line1 … … 1104 1104 expectedReturn => [ 1105 1105 [{ 1106 svnConvertedText => << 'END',1106 svnConvertedText => <<"END", 1107 1107 Index: Makefile 1108 1108 index f5d5e74..3b6aa92 100644 1109 --- Makefile 1110 +++ Makefile 1109 --- Makefile\t(revision 0) 1110 +++ Makefile\t(working copy) 1111 1111 @@ -1,1 +1,1 @@ public: 1112 1112 Index: Makefile_new … … 1200 1200 isGit => 1, 1201 1201 numTextChunks => 1, 1202 svnConvertedText => << 'END',1202 svnConvertedText => <<"END", 1203 1203 Index: foo_new 1204 1204 similarity index 99% … … 1206 1206 rename to foo_new 1207 1207 index 1e50d1d..1459d21 100644 1208 --- foo_new 1209 +++ foo_new 1208 --- foo_new\t(revision 0) 1209 +++ foo_new\t(working copy) 1210 1210 @@ -15,3 +15,4 @@ release r deployment dep deploy: 1211 1211 line1 -
trunk/Tools/Scripts/webkitperl/VCSUtils_unittest/parseDiffWithMockFiles.pl
r146249 r151300 72 72 EOF 73 73 74 my $svnConvertedGitDiffHeader = << EOF;74 my $svnConvertedGitDiffHeader = <<"EOF"; 75 75 Index: Makefile 76 76 index 756e864..04d2ae1 100644 77 --- Makefile 78 +++ Makefile 77 --- Makefile\t(revision 0) 78 +++ Makefile\t(working copy) 79 79 @@ -1,3 +1,4 @@ 80 80 EOF 81 81 82 my $svnConvertedGitDiffHeaderForNewFile = << EOF;82 my $svnConvertedGitDiffHeaderForNewFile = <<"EOF"; 83 83 Index: Makefile 84 84 new file mode 100644 85 85 index 0000000..756e864 86 --- Makefile 87 +++ Makefile 86 --- Makefile\t(revision 0) 87 +++ Makefile\t(working copy) 88 88 @@ -0,0 +1,17 @@ 89 89 EOF … … 355 355 Index: MakefileWithWindowsEOL 356 356 index e7e8475..ae16fc3 100644 357 --- MakefileWithWindowsEOL 358 +++ MakefileWithWindowsEOL 357 --- MakefileWithWindowsEOL\t(revision 0) 358 +++ MakefileWithWindowsEOL\t(working copy) 359 359 @@ -1,3 +1,4 @@\r 360 360 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools\r … … 387 387 [{ 388 388 # Same as input text 389 svnConvertedText => q (Index: MakefileWithMacEOL389 svnConvertedText => qq(Index: MakefileWithMacEOL 390 390 index e7e8475..ae16fc3 100644 391 --- MakefileWithMacEOL 392 +++ MakefileWithMacEOL 391 --- MakefileWithMacEOL\t(revision 0) 392 +++ MakefileWithMacEOL\t(working copy) 393 393 @@ -1,3 +1,4 @@\r MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools\r \r-all: 394 394 \\ No newline at end of file -
trunk/Tools/Scripts/webkitperl/VCSUtils_unittest/parseGitDiffHeader.pl
r59048 r151300 46 46 expectedReturn => [ 47 47 { 48 svnConvertedText => << 'END',48 svnConvertedText => <<"END", 49 49 Index: foo.h 50 50 index f5d5e74..3b6aa92 100644 51 --- foo.h 52 +++ foo.h 51 --- foo.h\t(revision 0) 52 +++ foo.h\t(working copy) 53 53 END 54 54 indexPath => "foo.h", 55 }, 56 "@@ -1 +1 @@\n"], 57 expectedNextLine => "-file contents\n", 58 }, 59 { 60 diffName => "Modified file using --src-prefix and --dst-prefix option", 61 inputText => <<'END', 62 diff --git s/foo.h d/foo.h 63 index f5d5e74..3b6aa92 100644 64 --- s/foo.h 65 +++ d/foo.h 66 @@ -1 +1 @@ 67 -file contents 68 +new file contents 69 END 70 expectedReturn => [ 71 { 72 svnConvertedText => <<"END", 73 Index: foo.h 74 index f5d5e74..3b6aa92 100644 75 --- foo.h\t(revision 0) 76 +++ foo.h\t(working copy) 77 END 78 indexPath => "foo.h", 79 }, 80 "@@ -1 +1 @@\n"], 81 expectedNextLine => "-file contents\n", 82 }, 83 { # New test 84 diffName => "Modified file which have space characters in path", 85 inputText => <<'END', 86 diff --git a/foo bar.h b/foo bar.h 87 index f5d5e74..3b6aa92 100644 88 --- a/foo bar.h 89 +++ b/foo bar.h 90 @@ -1 +1 @@ 91 -file contents 92 +new file contents 93 END 94 expectedReturn => [ 95 { 96 svnConvertedText => <<"END", 97 Index: foo bar.h 98 index f5d5e74..3b6aa92 100644 99 --- foo bar.h\t(revision 0) 100 +++ foo bar.h\t(working copy) 101 END 102 indexPath => "foo bar.h", 103 }, 104 "@@ -1 +1 @@\n"], 105 expectedNextLine => "-file contents\n", 106 }, 107 { # New test 108 diffName => "Modified file which have space characters in path using --no-prefix", 109 inputText => <<'END', 110 diff --git directory/foo bar.h directory/foo bar.h 111 index f5d5e74..3b6aa92 100644 112 --- directory/foo bar.h 113 +++ directory/foo bar.h 114 @@ -1 +1 @@ 115 -file contents 116 +new file contents 117 END 118 expectedReturn => [ 119 { 120 svnConvertedText => <<"END", 121 Index: directory/foo bar.h 122 index f5d5e74..3b6aa92 100644 123 --- directory/foo bar.h\t(revision 0) 124 +++ directory/foo bar.h\t(working copy) 125 END 126 indexPath => "directory/foo bar.h", 55 127 }, 56 128 "@@ -1 +1 @@\n"], … … 70 142 expectedReturn => [ 71 143 { 72 svnConvertedText => << 'END',144 svnConvertedText => <<"END", 73 145 Index: foo.h 74 146 new file mode 100644 75 147 index 0000000..3c9f114 76 --- foo.h 77 +++ foo.h 148 --- foo.h\t(revision 0) 149 +++ foo.h\t(working copy) 78 150 END 79 151 indexPath => "foo.h", … … 98 170 expectedReturn => [ 99 171 { 100 svnConvertedText => << 'END',172 svnConvertedText => <<"END", 101 173 Index: foo 102 174 deleted file mode 100644 103 175 index 1e50d1d..0000000 104 --- foo 105 +++ foo 176 --- foo\t(revision 0) 177 +++ foo\t(working copy) 106 178 END 107 179 indexPath => "foo", 180 isDeletion => 1, 181 }, 182 "@@ -1,1 +0,0 @@\n"], 183 expectedNextLine => "-line1\n", 184 }, 185 { 186 diffName => "delete file which have space characters in path using --no-prefix", 187 inputText => <<'END', 188 diff --git directory/foo bar.h directory/foo bar.h 189 deleted file mode 100644 190 index 1e50d1d..0000000 191 --- directory/foo bar.h 192 +++ /dev/null 193 @@ -1,1 +0,0 @@ 194 -line1 195 diff --git a/configure.ac b/configure.ac 196 index d45dd40..3494526 100644 197 END 198 expectedReturn => [ 199 { 200 svnConvertedText => <<"END", 201 Index: directory/foo bar.h 202 deleted file mode 100644 203 index 1e50d1d..0000000 204 --- directory/foo bar.h\t(revision 0) 205 +++ directory/foo bar.h\t(working copy) 206 END 207 indexPath => "directory/foo bar.h", 108 208 isDeletion => 1, 109 209 }, … … 123 223 expectedReturn => [ 124 224 { 125 svnConvertedText => << 'END',225 svnConvertedText => <<"END", 126 226 Index: foo.h 127 227 index c925780..9e65c43 100644 128 --- foo.h 129 +++ foo.h 228 --- foo.h\t(revision 0) 229 +++ foo.h\t(working copy) 130 230 END 131 231 indexPath => "foo.h", … … 157 257 copiedFromPath => "foo", 158 258 indexPath => "foo_new", 259 }, 260 "diff --git a/bar b/bar\n"], 261 expectedNextLine => "index d45dd40..3494526 100644\n", 262 }, 263 { 264 diffName => "copy file which have space characters in path using --no-prefix (with similarity index 100%)", 265 inputText => <<'END', 266 diff --git directory/foo bar.h directory/foo baz.h 267 similarity index 100% 268 copy from directory/foo bar.h 269 copy to directory/foo baz.h 270 diff --git a/bar b/bar 271 index d45dd40..3494526 100644 272 END 273 expectedReturn => [ 274 { 275 svnConvertedText => <<'END', 276 Index: directory/foo baz.h 277 similarity index 100% 278 copy from directory/foo bar.h 279 copy to directory/foo baz.h 280 END 281 copiedFromPath => "directory/foo bar.h", 282 indexPath => "directory/foo baz.h", 159 283 }, 160 284 "diff --git a/bar b/bar\n"], … … 206 330 copiedFromPath => "foo", 207 331 indexPath => "foo_new", 332 shouldDeleteSource => 1, 333 }, 334 "diff --git a/bar b/bar\n"], 335 expectedNextLine => "index d45dd40..3494526 100644\n", 336 }, 337 { 338 diffName => "rename file which have space characters in path using --no-prefix (with similarity index 100%)", 339 inputText => <<'END', 340 diff --git directory/foo bar.h directory/foo baz.h 341 similarity index 100% 342 rename from directory/foo bar.h 343 rename to directory/foo baz.h 344 diff --git a/bar b/bar 345 index d45dd40..3494526 100644 346 END 347 expectedReturn => [ 348 { 349 svnConvertedText => <<'END', 350 Index: directory/foo baz.h 351 similarity index 100% 352 rename from directory/foo bar.h 353 rename to directory/foo baz.h 354 END 355 copiedFromPath => "directory/foo bar.h", 356 indexPath => "directory/foo baz.h", 208 357 shouldDeleteSource => 1, 209 358 }, … … 231 380 expectedReturn => [ 232 381 { 233 svnConvertedText => << 'END',382 svnConvertedText => <<"END", 234 383 Index: foo_new 235 384 similarity index 99% … … 237 386 rename to foo_new 238 387 index 1e50d1d..1459d21 100644 239 --- foo_new 240 +++ foo_new 388 --- foo_new\t(revision 0) 389 +++ foo_new\t(working copy) 241 390 END 242 391 copiedFromPath => "foo", … … 360 509 expectedReturn => [ 361 510 { 362 svnConvertedText => << 'END',511 svnConvertedText => <<"END", 363 512 Index: foo 364 513 index d03e242..435ad3a 100755 365 --- foo 366 +++ foo 514 --- foo\t(revision 0) 515 +++ foo\t(working copy) 367 516 END 368 517 indexPath => "foo", … … 430 579 expectedReturn => [ 431 580 { 432 svnConvertedText => << 'END',581 svnConvertedText => <<"END", 433 582 Index: foo 434 583 new file mode 100755 435 584 index 0000000..d03e242 436 --- foo 437 +++ foo 585 --- foo\t(revision 0) 586 +++ foo\t(working copy) 438 587 END 439 588 executableBitDelta => 1, … … 459 608 expectedReturn => [ 460 609 { 461 svnConvertedText => << 'END',610 svnConvertedText => <<"END", 462 611 Index: foo 463 612 deleted file mode 100755 464 613 index d03e242..0000000 465 --- foo 466 +++ foo 614 --- foo\t(revision 0) 615 +++ foo\t(working copy) 467 616 END 468 617 executableBitDelta => -1, … … 473 622 expectedNextLine => "-file contents\n", 474 623 }, 624 { 625 # svn-apply rejected https://bug-111042-attachments.webkit.org/attachment.cgi?id=190663 626 diffName => "Modified file which have space characters in path. svn-apply rejected attachment #190663.", 627 inputText => <<'END', 628 diff --git a/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme b/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme 629 index 72d60effb9bbba0520e520ec3c1aa43f348c6997..b7924b96d5978c1ad1053dca7e554023235d9a16 100644 630 --- a/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme 631 +++ b/WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme 632 @@ -161,7 +161,7 @@ 633 <EnvironmentVariables> 634 <EnvironmentVariable 635 key = "DYLD_INSERT_LIBRARIES" 636 - value = "$(BUILT_PRODUCTS_DIR)/WebProcessShim.dylib" 637 + value = "$(BUILT_PRODUCTS_DIR)/SecItemShim.dylib" 638 isEnabled = "YES"> 639 </EnvironmentVariable> 640 </EnvironmentVariables> 641 END 642 expectedReturn => [ 643 { 644 svnConvertedText => <<"END", 645 Index: WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme 646 index 72d60effb9bbba0520e520ec3c1aa43f348c6997..b7924b96d5978c1ad1053dca7e554023235d9a16 100644 647 --- WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme\t(revision 0) 648 +++ WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme\t(working copy) 649 END 650 indexPath => "WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme", 651 }, 652 "@@ -161,7 +161,7 @@\n"], 653 expectedNextLine => " <EnvironmentVariables>\n", 654 }, 475 655 ); 476 656
Note: See TracChangeset
for help on using the changeset viewer.