summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/svn-apply
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-12-15 10:12:09 +0000
committerSteve Block <steveblock@google.com>2009-12-17 17:41:10 +0000
commit643ca7872b450ea4efacab6188849e5aac2ba161 (patch)
tree6982576c228bcd1a7efe98afed544d840751094c /WebKitTools/Scripts/svn-apply
parentd026980fde6eb3b01c1fe49441174e89cd1be298 (diff)
downloadexternal_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.zip
external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.gz
external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.bz2
Merge webkit.org at r51976 : Initial merge by git.
Change-Id: Ib0e7e2f0fb4bee5a186610272edf3186f0986b43
Diffstat (limited to 'WebKitTools/Scripts/svn-apply')
-rwxr-xr-xWebKitTools/Scripts/svn-apply52
1 files changed, 41 insertions, 11 deletions
diff --git a/WebKitTools/Scripts/svn-apply b/WebKitTools/Scripts/svn-apply
index 7d14e3a..0373aa5 100755
--- a/WebKitTools/Scripts/svn-apply
+++ b/WebKitTools/Scripts/svn-apply
@@ -55,7 +55,7 @@
# Notice a patch that's being applied at the "wrong level" and make it work anyway.
# Do a dry run on the whole patch and don't do anything if part of the patch is
# going to fail (probably too strict unless we exclude ChangeLog).
-# Handle git-diff patches with binary changes
+# Handle git-diff patches with binary delta
use strict;
use warnings;
@@ -75,11 +75,11 @@ sub addDirectoriesIfNeeded($);
sub applyPatch($$;$);
sub checksum($);
sub handleBinaryChange($$);
+sub handleGitBinaryChange($$);
sub isDirectoryEmptyForRemoval($);
sub patch($);
sub removeDirectoriesIfNeeded();
sub setChangeLogDateAndReviewer($$);
-sub removeEOL($);
# These should be replaced by an scm class/module:
sub scmKnowsOfFile($);
@@ -277,6 +277,39 @@ sub handleBinaryChange($$)
}
}
+sub handleGitBinaryChange($$)
+{
+ my ($fullPath, $contents) = @_;
+
+ my ($binaryChunkType, $binaryChunk, $reverseBinaryChunkType, $reverseBinaryChunk) = decodeGitBinaryPatch($contents, $fullPath);
+ # FIXME: support "delta" type.
+ die "only literal type is supported now" if ($binaryChunkType ne "literal" || $reverseBinaryChunkType ne "literal");
+
+ my $isFileAddition = $contents =~ /\nnew file mode \d+\n/;
+ my $isFileDeletion = $contents =~ /\ndeleted file mode \d+\n/;
+
+ my $originalContents = "";
+ if (open FILE, $fullPath) {
+ die "$fullPath already exists" if $isFileAddition;
+
+ $originalContents = join("", <FILE>);
+ close FILE;
+ }
+ die "Original content of $fullPath mismatches" if $originalContents ne $reverseBinaryChunk;
+
+ if ($isFileDeletion) {
+ scmRemove($fullPath);
+ } else {
+ # Addition or Modification
+ open FILE, ">", $fullPath or die "Failed to open $fullPath.";
+ print FILE $binaryChunk;
+ close FILE;
+ if ($isFileAddition) {
+ scmAdd($fullPath);
+ }
+ }
+}
+
sub isDirectoryEmptyForRemoval($)
{
my ($dir) = @_;
@@ -311,12 +344,14 @@ sub patch($)
my $deletion = 0;
my $addition = 0;
my $isBinary = 0;
+ my $isGitBinary = 0;
$addition = 1 if ($patch =~ /\n--- .+\(revision 0\)\r?\n/ || $patch =~ /\n@@ -0,0 .* @@/) && !exists($copiedFiles{$fullPath});
$deletion = 1 if $patch =~ /\n@@ .* \+0,0 @@/;
$isBinary = 1 if $patch =~ /\nCannot display: file marked as a binary type\./;
+ $isGitBinary = 1 if $patch =~ /\nGIT binary patch\n/;
- if (!$addition && !$deletion && !$isBinary) {
+ if (!$addition && !$deletion && !$isBinary && !$isGitBinary) {
# Standard patch, patch tool can handle this.
if (basename($fullPath) eq "ChangeLog") {
my $changeLogDotOrigExisted = -f "${fullPath}.orig";
@@ -333,6 +368,9 @@ sub patch($)
if ($isBinary) {
# Binary change
handleBinaryChange($fullPath, $patch);
+ } elsif ($isGitBinary) {
+ # Git binary change
+ handleGitBinaryChange($fullPath, $patch);
} elsif ($deletion) {
# Deletion
applyPatch($patch, $fullPath, ["--force"]);
@@ -378,14 +416,6 @@ sub setChangeLogDateAndReviewer($$)
return $patch;
}
-sub removeEOL($)
-{
- my ($line) = @_;
-
- $line =~ s/[\r\n]+$//g;
- return $line;
-}
-
# This could be made into a more general "status" call, except svn and git
# have different ideas about "moving" files which might get confusing.
sub scmWillDeleteFile($)