Changeset 232228 in webkit
- Timestamp:
- May 27, 2018 9:50:42 AM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r232222 r232228 1 2018-05-27 David Kilzer <ddkilzer@apple.com> 2 3 svn-apply fails when a patch has an empty file 4 <https://webkit.org/b/29684> 5 6 Reviewed by Daniel Bates. 7 8 Prior to this change, applying the following patches resulted in: 9 - svn: add empty file (failure) 10 - svn: delete empty file (failure) 11 - svn: rename empty file (failure) 12 - git: add empty file (false-positive success) 13 - git: delete empty file (success) 14 - git: rename empty file (failure) 15 16 * Scripts/VCSUtils.pm: 17 (parseSvnDiffHeader): Handle the case when there is no patch 18 following the header. If the file exists and is empty, that 19 means it's a deletion. If the file does not exist, that means 20 it's an addition. Everything else is a fatal error. 21 * Scripts/svn-apply: 22 (patch): 23 - Only apply a patch for deletion if it has one or more text 24 chunks. 25 - Add a case to handle adding an empty file (an addition with no 26 text chunks), and verify the file doesn't exist yet. 27 - Any unhandled patch is a fatal error. 28 * Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl: 29 Add tests for adding an empty file and deleting an empty file. 30 * Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt: Add. 31 Used by parseSvnDiffHeader.pl unit test for "add an empty file" 32 test case. 33 1 34 2018-05-25 Aakash Jain <aakash_jain@apple.com> 2 35 -
trunk/Tools/Scripts/VCSUtils.pm
r216032 r232228 939 939 my $foundHeaderEnding; 940 940 my $isBinary; 941 my $isDeletion; 941 942 my $isNew; 942 943 my $sourceRevision; … … 993 994 994 995 if (!$foundHeaderEnding) { 995 die("Did not find end of header block corresponding to index path \"$indexPath\"."); 996 if (-z $indexPath) { 997 # Delete an empty file. 998 $isDeletion = 1; 999 } elsif (! -e $indexPath) { 1000 # Add an empty file. 1001 $isNew = 1; 1002 } else { 1003 die "Did not find end of header block corresponding to index path \"$indexPath\"."; 1004 } 996 1005 } 997 1006 … … 1001 1010 $header{indexPath} = $indexPath; 1002 1011 $header{isBinary} = $isBinary if $isBinary; 1012 $header{isDeletion} = $isDeletion if $isDeletion; 1003 1013 $header{isNew} = $isNew if $isNew; 1004 1014 $header{sourceRevision} = $sourceRevision if $sourceRevision; -
trunk/Tools/Scripts/svn-apply
r226395 r232228 364 364 } 365 365 } elsif ($deletion) { 366 applyPatch($patch, $fullPath, ["--force"]) if $patch;366 applyPatch($patch, $fullPath, ["--force"]) if ($patch && $hasTextChunks); 367 367 scmRemove($fullPath); 368 368 } elsif ($addition && $hasTextChunks) { … … 375 375 # What is this for? 376 376 system("svn", "stat", "$escapedFullPath") if isSVN() && -e "$fullPath.orig"; 377 } elsif ($addition && !$hasTextChunks) { 378 # Add empty file. 379 die "\"$fullPath\" already exists" if -e $fullPath; 380 open(my $FH, ">>", $fullPath) or die "Could not open \"$fullPath\" for writing: $!"; 381 close($FH); 382 scmAdd($fullPath); 383 } else { 384 die "Can't handle patch for \"$fullPath\"."; 377 385 } 378 386 } -
trunk/Tools/Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl
r226395 r232228 267 267 expectedNextLine => "Property changes on: test_file.swf\n", 268 268 }, 269 #### 270 # Empty file test cases 271 ## 272 { 273 # New test 274 diffName => "add an empty file", 275 inputText => <<'END', 276 Index: empty_file_that_should_never_exist 277 =================================================================== 278 END 279 expectedReturn => [ 280 { 281 svnConvertedText => <<'END', 282 Index: empty_file_that_should_never_exist 283 =================================================================== 284 END 285 indexPath => "empty_file_that_should_never_exist", 286 isNew => 1, 287 }, 288 undef], 289 expectedNextLine => undef, 290 }, 291 { 292 # New test 293 diffName => "delete an empty file", 294 inputText => <<'END', 295 Index: Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt 296 =================================================================== 297 END 298 expectedReturn => [ 299 { 300 svnConvertedText => <<'END', 301 Index: Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt 302 =================================================================== 303 END 304 indexPath => "Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt", 305 isDeletion => 1, 306 }, 307 undef], 308 expectedNextLine => undef, 309 }, 269 310 ); 270 311
Note: See TracChangeset
for help on using the changeset viewer.