Commit 43944576 authored by ddkilzer's avatar ddkilzer
Browse files

WebKitTools:

        Reviewed by Darin.

        - http://bugzilla.opendarwin.org/show_bug.cgi?id=9693
          svn-apply should set ChangeLog date correctly when applying patches

        * Scripts/svn-apply: Set the ChangeLog entry date using a configurable timezone
        before applying the patch.
        * Scripts/svn-unapply: Reset the ChangeLog entry date before unapplying the patch.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e9653596
2006-07-09 David Kilzer <ddkilzer@kilzer.net>
Reviewed by Darin.
- http://bugzilla.opendarwin.org/show_bug.cgi?id=9693
svn-apply should set ChangeLog date correctly when applying patches
* Scripts/svn-apply: Set the ChangeLog entry date using a configurable timezone
before applying the patch.
* Scripts/svn-unapply: Reset the ChangeLog entry date before unapplying the patch.
2006-07-09 Darin Adler <darin@apple.com>
* Scripts/do-webcore-rename: Final version of this round of renaming for posterity.
......
......@@ -40,7 +40,8 @@
# Paths from Index: lines are used rather than the paths on the patch lines, which
# makes patches generated by "cvs diff" work (increasingly unimportant since we
# use Subversion now).
# ChangeLog patches use --fuzz=3 to prevent rejects.
# ChangeLog patches use --fuzz=3 to prevent rejects, and the entry date is set in
# the patch to today's date using $changeLogTimeZone.
# Handles binary files (requires patches made by svn-create-patch).
#
# Missing features:
......@@ -60,6 +61,7 @@ use File::Basename;
use File::Spec;
use Getopt::Long;
use MIME::Base64;
use POSIX qw(strftime);
sub addDirectoriesIfNeeded($);
sub applyPatch($$;$);
......@@ -67,8 +69,12 @@ sub handleBinaryChange($$);
sub isDirectoryEmptyForRemoval($);
sub patch($);
sub removeDirectoriesIfNeeded();
sub setChangeLogDate($);
sub svnStatus($);
# Project time zone for Cupertino, CA, US
my $changeLogTimeZone = "PST8PDT";
my $merge = 0;
my $showHelp = 0;
if (!GetOptions("merge!" => \$merge, "help!" => \$showHelp) || $showHelp) {
......@@ -228,7 +234,7 @@ sub patch($)
# Standard patch, patch tool can handle this.
if (basename($fullPath) eq "ChangeLog") {
my $changeLogDotOrigExisted = -f "${fullPath}.orig";
applyPatch($patch, $fullPath, ["--fuzz=3"]);
applyPatch(setChangeLogDate($patch), $fullPath, ["--fuzz=3"]);
unlink("${fullPath}.orig") if (! $changeLogDotOrigExisted);
} else {
applyPatch($patch, $fullPath);
......@@ -279,6 +285,22 @@ sub removeDirectoriesIfNeeded()
}
}
sub setChangeLogDate($)
{
my $patch = shift;
my $savedTimeZone = $ENV{'TZ'};
# Set TZ temporarily so that localtime() is in that time zone
$ENV{'TZ'} = $changeLogTimeZone;
my $newDate = strftime("%Y-%m-%d", localtime());
if (defined $savedTimeZone) {
$ENV{'TZ'} = $savedTimeZone;
} else {
delete $ENV{'TZ'};
}
$patch =~ s/(\n\+)\d{4}-[^-]{2}-[^-]{2}( )/$1$newDate$2/;
return $patch;
}
sub svnStatus($)
{
my ($fullPath) = @_;
......
......@@ -37,7 +37,8 @@
# Paths from Index: lines are used rather than the paths on the patch lines, which
# makes patches generated by "cvs diff" work (increasingly unimportant since we
# use Subversion now).
# ChangeLog patches use --fuzz=3 to prevent rejects.
# ChangeLog patches use --fuzz=3 to prevent rejects, and the entry date is reset in
# the patch before it is applied (svn-apply sets it when applying a patch).
# Handles binary files (requires patches made by svn-create-patch).
#
# Missing features:
......@@ -54,6 +55,7 @@ use strict;
use warnings;
use Cwd;
use Fcntl qw(:DEFAULT :seek);
use File::Basename;
use File::Spec;
use Getopt::Long;
......@@ -62,6 +64,7 @@ sub patch($);
sub revertDirectories();
sub svnStatus($);
sub unapplyPatch($$;$);
sub unsetChangeLogDate($$);
my $showHelp = 0;
if (!GetOptions("help!" => \$showHelp) || $showHelp) {
......@@ -120,7 +123,7 @@ sub patch($)
# Standard patch, patch tool can handle this.
if (basename($fullPath) eq "ChangeLog") {
my $changeLogDotOrigExisted = -f "${fullPath}.orig";
unapplyPatch($patch, $fullPath, ["--fuzz=3"]);
unapplyPatch(unsetChangeLogDate($fullPath, $patch), $fullPath, ["--fuzz=3"]);
unlink("${fullPath}.orig") if (! $changeLogDotOrigExisted);
} else {
unapplyPatch($patch, $fullPath);
......@@ -181,7 +184,21 @@ sub unapplyPatch($$;$)
my ($patch, $fullPath, $options) = @_;
$options = [] if (! $options);
my $command = "patch " . join(" ", "-p0", "-R", @{$options});
open PATCH, "| $command" or die "Failed to patch $fullPath\n";
open PATCH, "| $command" or die "Failed to patch $fullPath: $!";
print PATCH $patch;
close PATCH;
}
sub unsetChangeLogDate($$)
{
my $fullPath = shift;
my $patch = shift;
my $newDate;
sysopen(CHANGELOG, $fullPath, O_RDONLY) or die "Failed to open $fullPath: $!";
sysseek(CHANGELOG, 0, SEEK_SET);
my $byteCount = sysread(CHANGELOG, $newDate, 10);
die "Failed reading $fullPath: $!" if !$byteCount || $byteCount != 10;
close(CHANGELOG);
$patch =~ s/(\n\+)\d{4}-[^-]{2}-[^-]{2}( )/$1$newDate$2/;
return $patch;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment