WebKit Bugzilla
Attachment 341417 Details for
Bug 29684
: svn-apply fails when a patch has an empty file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v1
bug-29684-20180526215210.patch (text/plain), 6.26 KB, created by
David Kilzer (:ddkilzer)
on 2018-05-26 21:52:08 PDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
David Kilzer (:ddkilzer)
Created:
2018-05-26 21:52:08 PDT
Size:
6.26 KB
patch
obsolete
>Subversion Revision: 231909 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index bf2e7d35c148dc8046467d297b560e859f637350..74f25353031629ff245c82eefb3e83006732e43d 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,36 @@ >+2018-05-26 David Kilzer <ddkilzer@apple.com> >+ >+ svn-apply fails when a patch has an empty file >+ <https://webkit.org/b/29684> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Prior to this change, applying the following patches resulted in: >+ - svn: add empty file (failure) >+ - svn: delete empty file (failure) >+ - svn: rename empty file (failure) >+ - git: add empty file (false-positive success) >+ - git: delete empty file (success) >+ - git: rename empty file (failure) >+ >+ * Scripts/VCSUtils.pm: >+ (parseSvnDiffHeader): Handle the case when there is no patch >+ following the header. If the file exists and is empty, that >+ means it's a deletion. If the file does not exist, that means >+ it's an addition. Everything else is a fatal error. >+ * Scripts/svn-apply: >+ (patch): >+ - Only apply a patch for deletion if it has one or more text >+ chunks. >+ - Add a case to handle adding an empty file (an addition with no >+ text chunks), and verify the file doesn't exist yet. >+ - Any unhandled patch is a fatal error. >+ * Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl: >+ Add tests for adding an empty file and deleting an empty file. >+ * Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt: Add. >+ Used by parseSvnDiffHeader.pl unit test for "add an empty file" >+ test case. >+ > 2018-05-17 Valerie R Young <valerie@bocoup.com> > > test262/Runner.pm: look for jsc in path if cannot call webkit-build-directory >diff --git a/Tools/Scripts/VCSUtils.pm b/Tools/Scripts/VCSUtils.pm >index 4c48c801087c164c029828d7e7afbb6a65e9c08f..5fe4594f602dca9fe6d48ac6f8c60805322e4b24 100644 >--- a/Tools/Scripts/VCSUtils.pm >+++ b/Tools/Scripts/VCSUtils.pm >@@ -938,6 +938,7 @@ sub parseSvnDiffHeader($$) > my $copiedFromPath; > my $foundHeaderEnding; > my $isBinary; >+ my $isDeletion; > my $isNew; > my $sourceRevision; > my $svnConvertedText; >@@ -992,7 +993,15 @@ sub parseSvnDiffHeader($$) > } > > if (!$foundHeaderEnding) { >- die("Did not find end of header block corresponding to index path \"$indexPath\"."); >+ if (-z $indexPath) { >+ # Delete an empty file. >+ $isDeletion = 1; >+ } elsif (! -e $indexPath) { >+ # Add an empty file. >+ $isNew = 1; >+ } else { >+ die "Did not find end of header block corresponding to index path \"$indexPath\"."; >+ } > } > > my %header; >@@ -1000,6 +1009,7 @@ sub parseSvnDiffHeader($$) > $header{copiedFromPath} = $copiedFromPath if $copiedFromPath; > $header{indexPath} = $indexPath; > $header{isBinary} = $isBinary if $isBinary; >+ $header{isDeletion} = $isDeletion if $isDeletion; > $header{isNew} = $isNew if $isNew; > $header{sourceRevision} = $sourceRevision if $sourceRevision; > $header{svnConvertedText} = $svnConvertedText; >diff --git a/Tools/Scripts/svn-apply b/Tools/Scripts/svn-apply >index c3c972f56178fae92b68742370e79d4a5b24b3ed..d84021696296b3da206f51a96bc2811cb44ab592 100755 >--- a/Tools/Scripts/svn-apply >+++ b/Tools/Scripts/svn-apply >@@ -363,7 +363,7 @@ sub patch($) > handleBinaryChange($fullPath, $patch) if $patch; > } > } elsif ($deletion) { >- applyPatch($patch, $fullPath, ["--force"]) if $patch; >+ applyPatch($patch, $fullPath, ["--force"]) if ($patch && $hasTextChunks); > scmRemove($fullPath); > } elsif ($addition && $hasTextChunks) { > # Addition >@@ -374,6 +374,14 @@ sub patch($) > my $escapedFullPath = escapeSubversionPath("$fullPath.orig"); > # What is this for? > system("svn", "stat", "$escapedFullPath") if isSVN() && -e "$fullPath.orig"; >+ } elsif ($addition && !$hasTextChunks) { >+ # Add empty file. >+ die "\"$fullPath\" already exists" if -e $fullPath; >+ open(my $FH, ">>", $fullPath) or die "Could not open \"$fullPath\" for writing: $!"; >+ close($FH); >+ scmAdd($fullPath); >+ } else { >+ die "Can't handle patch for \"$fullPath\"."; > } > } > >diff --git a/Tools/Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl b/Tools/Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl >index 5fc901e5b27f7cb027356c5e823684b5a1021287..f850b0004da30321de363a684288fa10b0390380 100644 >--- a/Tools/Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl >+++ b/Tools/Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffHeader.pl >@@ -266,6 +266,47 @@ END > "\n"], > expectedNextLine => "Property changes on: test_file.swf\n", > }, >+#### >+# Empty file test cases >+## >+{ >+ # New test >+ diffName => "add an empty file", >+ inputText => <<'END', >+Index: empty_file_that_should_never_exist >+=================================================================== >+END >+ expectedReturn => [ >+{ >+ svnConvertedText => <<'END', >+Index: empty_file_that_should_never_exist >+=================================================================== >+END >+ indexPath => "empty_file_that_should_never_exist", >+ isNew => 1, >+}, >+undef], >+ expectedNextLine => undef, >+}, >+{ >+ # New test >+ diffName => "delete an empty file", >+ inputText => <<'END', >+Index: Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt >+=================================================================== >+END >+ expectedReturn => [ >+{ >+ svnConvertedText => <<'END', >+Index: Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt >+=================================================================== >+END >+ indexPath => "Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt", >+ isDeletion => 1, >+}, >+undef], >+ expectedNextLine => undef, >+}, > ); > > my $testCasesCount = @testCaseHashRefs; >diff --git a/Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt b/Tools/Scripts/webkitperl/VCSUtils_unittest/resources/empty.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 29684
:
341399
|
341400
|
341401
|
341402
|
341403
|
341404
| 341417