Changeset 53340 in webkit
- Timestamp:
- Jan 15, 2010 12:36:25 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r53317 r53340 1 2010-01-15 Chris Jerdonek <chris.jerdonek@gmail.com> 2 3 Reviewed by David Kilzer. 4 5 Altered parseDiffHeader() to skip unrecognized lines and 6 other minor clean-ups. 7 8 https://bugs.webkit.org/show_bug.cgi?id=33476 9 10 * Scripts/VCSUtils.pm: 11 - Changed parseDiffHeader() as follows: 12 - Skips over unrecognized lines. 13 - Addressed FIXME to remove substitution for "diff" line. 14 - Renamed "version" header hash key to "sourceRevision". 15 - Eliminated "copiedFromVersion" header hash key. 16 - Included "sourceRevision" also for copied files. 17 - Checks that copy revision number matches "sourceRevision". 18 - No longer returns $foundHeaderEnding. 19 - Dies if header ending not found. 20 - Diff header dividing line now always added. 21 22 * Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl: 23 - Made necessary changes in parseDiffHeader() unit tests. 24 - Shortened the file paths in some test cases. 25 1 26 2010-01-14 Yuzo Fujishima <yuzo@google.com> 2 27 -
trunk/WebKitTools/Scripts/VCSUtils.pm
r53076 r53340 371 371 } 372 372 if (m#^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}#) { 373 # FIXME: No need to return dividing line once parseDiffHeader() is used. 373 374 return "===================================================================$POSTMATCH"; 374 375 } … … 386 387 # parsed header block. 387 388 # 388 # This subroutine dies if given leading junk. 389 # This subroutine dies if given leading junk or if the end of the header 390 # block could not be detected. The last line of a header block is a 391 # line beginning with "+++". 389 392 # 390 393 # Args: … … 394 397 # $line: the line last read from $fileHandle 395 398 # 396 # Returns ($headerHashRef, $ foundHeaderEnding, $lastReadLine):399 # Returns ($headerHashRef, $lastReadLine): 397 400 # $headerHashRef: a hash reference representing a diff header 398 # copiedFromPath: the path in the "from" clause, if any.399 # copiedFromVersion: the revision number in the "from" clause, if any.401 # copiedFromPath: if a file copy, the path from which the file was 402 # copied. Otherwise, undefined. 400 403 # indexPath: the path in the "Index:" line. 404 # sourceRevision: the revision number of the source. This is the same 405 # as the revision number the file was copied from, in 406 # the case of a file copy. 401 407 # svnConvertedText: the header text converted to SVN format. 402 # Unrecognized Git lines are left alone. 403 # version: the revision number of the source. 404 # $foundHeaderEnding: whether the last header block line was found. 405 # This is a line beginning with "+++". 406 # $lastReadLine: the line last read from $fileHandle. If EOF has not 407 # been reached, this is the first line after the 408 # header ending. 408 # Unrecognized lines are discarded. 409 # $lastReadLine: the line last read from $fileHandle. This is the first 410 # line after the header ending. 409 411 sub parseDiffHeader($$) 410 412 { … … 426 428 my %header; 427 429 428 my $foundHeaderEnding = 0; 429 my $lastReadLine; 430 my $foundHeaderEnding; 431 my $lastReadLine; 432 my $sourceRevision; 430 433 my $svnConvertedText = $line; 431 434 while (<$fileHandle>) { … … 437 440 $_ = &$filter($_) if $filter; 438 441 439 # Fix paths on "diff", "---", and "+++" lines to match the 440 # leading index line. 441 s/\S+$/$indexPath/ if /^diff/; # FIXME: Can this ever occur? If so, include 442 # a unit test. Otherwise, remove it. 443 s/^--- \S+/--- $indexPath/; 444 if (/^--- .+\(from (\S+):(\d+)\)$/) { 445 $header{copiedFromPath} = $1; 446 $header{copiedFromVersion} = $2 if ($2 != 0); 447 } elsif (/^--- .+\(revision (\d+)\)$/) { 448 $header{version} = $1 if ($1 != 0); 442 # Fix paths on ""---" and "+++" lines to match the leading 443 # index line. 444 if (s/^--- \S+/--- $indexPath/) { 445 # --- 446 if (/^--- .+\(revision (\d+)\)/) { 447 $sourceRevision = $1 if ($1 != 0); 448 if (/\(from (\S+):(\d+)\)$/) { 449 # The "from" clause is created by svn-create-patch, in 450 # which case there is always also a "revision" clause. 451 $header{copiedFromPath} = $1; 452 die("Revision number \"$2\" in \"from\" clause does not match " . 453 "source revision number \"$sourceRevision\".") if ($2 != $sourceRevision); 454 } 455 } 456 $_ = "=" x 67 . "$eol$_"; # Prepend dividing line ===.... 449 457 } elsif (s/^\+\+\+ \S+/+++ $indexPath/) { 458 # +++ 450 459 $foundHeaderEnding = 1; 451 } 452 453 $svnConvertedText .= "$_$eol"; # Also restore EOL characters. 460 } else { 461 # Skip unrecognized lines. 462 next; 463 } 464 465 $svnConvertedText .= "$_$eol"; # Also restore end-of-line characters. 454 466 if ($foundHeaderEnding) { 455 467 $lastReadLine = <$fileHandle>; … … 458 470 } # $lastReadLine is undef if while loop ran out. 459 471 472 if (!$foundHeaderEnding) { 473 die("Did not find end of header block corresponding to index path \"$indexPath\"."); 474 } 475 460 476 $header{indexPath} = $indexPath; 477 $header{sourceRevision} = $sourceRevision; 461 478 $header{svnConvertedText} = $svnConvertedText; 462 479 463 return (\%header, $ foundHeaderEnding, $lastReadLine);480 return (\%header, $lastReadLine); 464 481 } 465 482 -
trunk/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl
r53076 r53340 39 39 my @headerKeys = ( # The $headerHashRef keys to check. 40 40 "copiedFromPath", 41 "copiedFromVersion",42 41 "indexPath", 42 "sourceRevision", 43 43 "svnConvertedText", 44 "version",45 44 ); 46 45 … … 55 54 my $line = <$fileHandle>; 56 55 57 my ($headerHashRef, $ foundHeaderEnding, $lastReadLine) = VCSUtils::parseDiffHeader($fileHandle, $line);56 my ($headerHashRef, $lastReadLine) = VCSUtils::parseDiffHeader($fileHandle, $line); 58 57 59 58 my $titleHeader = "parseDiffHeader(): [$diffTestHashRef->{diffName}] "; … … 65 64 } 66 65 67 is($foundHeaderEnding, $diffTestHashRef->{foundHeaderEnding}, "${titleHeader}foundHeaderEnding");68 66 is($lastReadLine, $diffTestHashRef->{lastReadLine}, "${titleHeader}lastReadLine"); 69 67 … … 72 70 } 73 71 74 my @diffTests = ({ 75 # New test: missing closing header line 76 diffName => "SVN: incomplete header", 77 inputText => <<'END', 78 Index: WebKitTools/Scripts/VCSUtils.pm 79 END 80 # Header keys to check 81 svnConvertedText => <<'END', 82 Index: WebKitTools/Scripts/VCSUtils.pm 83 END 84 copiedFromPath => undef, 85 copiedFromVersion => undef, 86 indexPath => "WebKitTools/Scripts/VCSUtils.pm", 87 version => undef, 88 # Other values to check 89 foundHeaderEnding => 0, 90 lastReadLine => undef, 91 nextLine => undef, 92 }, 72 my @diffTests = ( 93 73 { 94 74 # New test … … 110 90 END 111 91 copiedFromPath => undef, 112 copiedFromVersion => undef,113 92 indexPath => "WebKitTools/Scripts/VCSUtils.pm", 114 version => "53004", 115 # Other values to check 116 foundHeaderEnding => 1, 93 sourceRevision => "53004", 94 # Other values to check 117 95 lastReadLine => "@@ -32,6 +32,7 @@ use strict;\n", 118 96 nextLine => " use warnings;\n", … … 137 115 END 138 116 copiedFromPath => undef, 139 copiedFromVersion => undef,140 117 indexPath => "WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl", 141 version => undef, 142 # Other values to check 143 foundHeaderEnding => 1, 118 sourceRevision => undef, 119 # Other values to check 144 120 lastReadLine => "@@ -0,0 +1,262 @@\n", 145 121 nextLine => "+#!/usr/bin/perl -w\n", … … 149 125 diffName => "SVN: copy", 150 126 inputText => <<'END', 151 Index: WebKitTools/Scripts/webkitpy/move_test.py152 =================================================================== 153 --- WebKitTools/Scripts/webkitpy/move_test.py (revision 53047) (from WebKitTools/Scripts/webkitpy/__init__.py:53048)154 +++ WebKitTools/Scripts/webkitpy/move_test.py (working copy)127 Index: index_path.py 128 =================================================================== 129 --- index_path.py (revision 53048) (from copied_from_path.py:53048) 130 +++ index_path.py (working copy) 155 131 @@ -0,0 +1,7 @@ 156 +# Required for Python to search this directory for module files 157 END 158 # Header keys to check 159 svnConvertedText => <<'END', 160 Index: WebKitTools/Scripts/webkitpy/move_test.py 161 =================================================================== 162 --- WebKitTools/Scripts/webkitpy/move_test.py (revision 53047) (from WebKitTools/Scripts/webkitpy/__init__.py:53048) 163 +++ WebKitTools/Scripts/webkitpy/move_test.py (working copy) 164 END 165 copiedFromPath => "WebKitTools/Scripts/webkitpy/__init__.py", 166 copiedFromVersion => "53048", 167 indexPath => "WebKitTools/Scripts/webkitpy/move_test.py", 168 version => undef, 169 # Other values to check 170 foundHeaderEnding => 1, 132 +# Python file... 133 END 134 # Header keys to check 135 svnConvertedText => <<'END', 136 Index: index_path.py 137 =================================================================== 138 --- index_path.py (revision 53048) (from copied_from_path.py:53048) 139 +++ index_path.py (working copy) 140 END 141 copiedFromPath => "copied_from_path.py", 142 indexPath => "index_path.py", 143 sourceRevision => 53048, 144 # Other values to check 171 145 lastReadLine => "@@ -0,0 +1,7 @@\n", 172 nextLine => "+# Required for Python to search this directory for module files\n",146 nextLine => "+# Python file...\n", 173 147 }, 174 148 { … … 176 150 diffName => "SVN: \\r\\n lines", 177 151 inputText => <<END, # No single quotes to allow interpolation of "\r" 178 Index: WebKitTools/Scripts/webkitpy/move_test.py\r152 Index: index_path.py\r 179 153 ===================================================================\r 180 --- WebKitTools/Scripts/webkitpy/move_test.py (revision 53047) (from WebKitTools/Scripts/webkitpy/__init__.py:53048)\r181 +++ WebKitTools/Scripts/webkitpy/move_test.py (working copy)\r154 --- index_path.py (revision 53048) (from copied_from_path.py:53048)\r 155 +++ index_path.py (working copy)\r 182 156 @@ -0,0 +1,7 @@\r 183 +# Required for Python to search this directory for module files\r157 +# Python file...\r 184 158 END 185 159 # Header keys to check 186 160 svnConvertedText => <<END, # No single quotes to allow interpolation of "\r" 187 Index: WebKitTools/Scripts/webkitpy/move_test.py\r161 Index: index_path.py\r 188 162 ===================================================================\r 189 --- WebKitTools/Scripts/webkitpy/move_test.py (revision 53047) (from WebKitTools/Scripts/webkitpy/__init__.py:53048)\r 190 +++ WebKitTools/Scripts/webkitpy/move_test.py (working copy)\r 191 END 192 copiedFromPath => "WebKitTools/Scripts/webkitpy/__init__.py", 193 copiedFromVersion => "53048", 194 indexPath => "WebKitTools/Scripts/webkitpy/move_test.py", 195 version => undef, 196 # Other values to check 197 foundHeaderEnding => 1, 163 --- index_path.py (revision 53048) (from copied_from_path.py:53048)\r 164 +++ index_path.py (working copy)\r 165 END 166 copiedFromPath => "copied_from_path.py", 167 indexPath => "index_path.py", 168 sourceRevision => 53048, 169 # Other values to check 198 170 lastReadLine => "@@ -0,0 +1,7 @@\r\n", 199 nextLine => "+# Required for Python to search this directory for module files\r\n",171 nextLine => "+# Python file...\r\n", 200 172 }, 201 173 { … … 203 175 diffName => "SVN: path corrections", 204 176 inputText => <<'END', 205 Index: WebKitTools/Scripts/webkitpy/move_test.py206 =================================================================== 207 --- bad_path (revision 5304 7) (from WebKitTools/Scripts/webkitpy/__init__.py:53048)177 Index: index_path.py 178 =================================================================== 179 --- bad_path (revision 53048) (from copied_from_path.py:53048) 208 180 +++ bad_path (working copy) 209 181 @@ -0,0 +1,7 @@ 210 +# Required for Python to search this directory for module files 211 END 212 # Header keys to check 213 svnConvertedText => <<'END', 214 Index: WebKitTools/Scripts/webkitpy/move_test.py 215 =================================================================== 216 --- WebKitTools/Scripts/webkitpy/move_test.py (revision 53047) (from WebKitTools/Scripts/webkitpy/__init__.py:53048) 217 +++ WebKitTools/Scripts/webkitpy/move_test.py (working copy) 218 END 219 copiedFromPath => "WebKitTools/Scripts/webkitpy/__init__.py", 220 copiedFromVersion => "53048", 221 indexPath => "WebKitTools/Scripts/webkitpy/move_test.py", 222 version => undef, 223 # Other values to check 224 foundHeaderEnding => 1, 182 +# Python file... 183 END 184 # Header keys to check 185 svnConvertedText => <<'END', 186 Index: index_path.py 187 =================================================================== 188 --- index_path.py (revision 53048) (from copied_from_path.py:53048) 189 +++ index_path.py (working copy) 190 END 191 copiedFromPath => "copied_from_path.py", 192 indexPath => "index_path.py", 193 sourceRevision => 53048, 194 # Other values to check 225 195 lastReadLine => "@@ -0,0 +1,7 @@\n", 226 nextLine => "+# Required for Python to search this directory for module files\n",196 nextLine => "+# Python file...\n", 227 197 }, 228 198 { … … 244 214 END 245 215 copiedFromPath => undef, 246 copiedFromVersion => undef,247 216 indexPath => "WebCore/rendering/style/StyleFlexibleBoxData.h", 248 version => undef, 249 # Other values to check 250 foundHeaderEnding => 1, 217 sourceRevision => undef, 218 # Other values to check 251 219 lastReadLine => "@@ -47,7 +47,6 @@ public:\n", 252 220 nextLine => undef, … … 267 235 svnConvertedText => <<'END', 268 236 Index: LayoutTests/http/tests/security/listener/xss-inactive-closure.html 269 new file mode 100644 270 index 0000000..3c9f114 237 =================================================================== 271 238 --- LayoutTests/http/tests/security/listener/xss-inactive-closure.html 272 239 +++ LayoutTests/http/tests/security/listener/xss-inactive-closure.html 273 240 END 274 241 copiedFromPath => undef, 275 copiedFromVersion => undef,276 242 indexPath => "LayoutTests/http/tests/security/listener/xss-inactive-closure.html", 277 version => undef, 278 # Other values to check 279 foundHeaderEnding => 1, 243 sourceRevision => undef, 244 # Other values to check 280 245 lastReadLine => "@@ -0,0 +1,34 @@\n", 281 246 nextLine => "+<html>\n", … … 283 248 ); 284 249 285 plan(tests => @diffTests * 8); # Eightassertions per call to doDiffTest().250 plan(tests => @diffTests * 6); # Multiply by number of assertions per call to doDiffTest(). 286 251 287 252 foreach my $diffTestHashRef (@diffTests) {
Note: See TracChangeset
for help on using the changeset viewer.