Changeset 56471 in webkit


Ignore:
Timestamp:
Mar 24, 2010 4:50:18 PM (14 years ago)
Author:
ddkilzer@apple.com
Message:

<http://webkit.org/b/36560> resolve-ChangeLogs: move mergeChanges() into VCSUtils package

Reviewed by Eric Seidel.

  • Scripts/VCSUtils.pm:

(mergeChangeLogs): Copied from mergeChanges() in
resolve-ChangeLogs and renamed. Added method documentation.
Fixed bug found by new tests where the original file to be
patched was deleted when cleaning up after a traditinal rejected
patch failed to apply.

  • Scripts/resolve-ChangeLogs: Switched to using

mergeChangeLogs().
(mergeChanges): Moved to VCSUtils.pm and renamed to
mergeChangeLogs().

  • Scripts/webkitperl/VCSUtils_unittest/mergeChangeLogs.pl: Added.
Location:
trunk/WebKitTools
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56470 r56471  
     12010-03-24  David Kilzer  <ddkilzer@apple.com>
     2
     3        <http://webkit.org/b/36560> resolve-ChangeLogs: move mergeChanges() into VCSUtils package
     4
     5        Reviewed by Eric Seidel.
     6
     7        * Scripts/VCSUtils.pm:
     8        (mergeChangeLogs): Copied from mergeChanges() in
     9        resolve-ChangeLogs and renamed.  Added method documentation.
     10        Fixed bug found by new tests where the original file to be
     11        patched was deleted when cleaning up after a traditinal rejected
     12        patch failed to apply.
     13        * Scripts/resolve-ChangeLogs: Switched to using
     14        mergeChangeLogs().
     15        (mergeChanges): Moved to VCSUtils.pm and renamed to
     16        mergeChangeLogs().
     17        * Scripts/webkitperl/VCSUtils_unittest/mergeChangeLogs.pl: Added.
     18
    1192010-03-24  Eric Seidel  <eric@webkit.org>
    220
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r53667 r56471  
    6262        &isSVNVersion16OrNewer
    6363        &makeFilePathRelative
     64        &mergeChangeLogs
    6465        &normalizePath
    6566        &parsePatch
     
    816817}
    817818
     819# Merge ChangeLog patches using a three-file approach.
     820#
     821# This is used by resolve-ChangeLogs when it's operated as a merge driver
     822# and when it's used to merge conflicts after a patch is applied or after
     823# an svn update.
     824#
     825# It's also used for traditional rejected patches.
     826#
     827# Args:
     828#   $fileMine:  The merged version of the file.  Also known in git as the
     829#               other branch's version (%B) or "ours".
     830#               For traditional patch rejects, this is the *.rej file.
     831#   $fileOlder: The base version of the file.  Also known in git as the
     832#               ancestor version (%O) or "base".
     833#               For traditional patch rejects, this is the *.orig file.
     834#   $fileNewer: The current version of the file.  Also known in git as the
     835#               current version (%A) or "theirs".
     836#               For traditional patch rejects, this is the original-named
     837#               file.
     838#
     839# Returns 1 if merge was successful, else 0.
     840sub mergeChangeLogs($$$)
     841{
     842    my ($fileMine, $fileOlder, $fileNewer) = @_;
     843
     844    my $traditionalReject = $fileMine =~ /\.rej$/ ? 1 : 0;
     845
     846    local $/ = undef;
     847
     848    my $patch;
     849    if ($traditionalReject) {
     850        open(DIFF, "<", $fileMine) or die $!;
     851        $patch = <DIFF>;
     852        close(DIFF);
     853        rename($fileMine, "$fileMine.save");
     854        rename($fileOlder, "$fileOlder.save");
     855    } else {
     856        open(DIFF, "-|", qw(diff -u -a --binary), $fileOlder, $fileMine) or die $!;
     857        $patch = <DIFF>;
     858        close(DIFF);
     859    }
     860
     861    unlink("${fileNewer}.orig");
     862    unlink("${fileNewer}.rej");
     863
     864    open(PATCH, "| patch --fuzz=3 --binary $fileNewer > " . File::Spec->devnull()) or die $!;
     865    print PATCH ($traditionalReject ? $patch : fixChangeLogPatch($patch));
     866    close(PATCH);
     867
     868    my $result;
     869
     870    # Refuse to merge the patch if it did not apply cleanly
     871    if (-e "${fileNewer}.rej") {
     872        unlink("${fileNewer}.rej");
     873        if (-f "${fileNewer}.orig") {
     874            unlink($fileNewer);
     875            rename("${fileNewer}.orig", $fileNewer);
     876        }
     877        $result = 0;
     878    } else {
     879        unlink("${fileNewer}.orig");
     880        $result = 1;
     881    }
     882
     883    if ($traditionalReject) {
     884        rename("$fileMine.save", $fileMine);
     885        rename("$fileOlder.save", $fileOlder);
     886    }
     887
     888    return $result;
     889}
     890
    818891sub gitConfig($)
    819892{
  • trunk/WebKitTools/Scripts/resolve-ChangeLogs

    r54960 r56471  
    5050sub hasGitUnmergedFiles();
    5151sub isInGitFilterBranch();
    52 sub mergeChanges($$$);
    5352sub parseFixMerged($$;$);
    5453sub removeChangeLogArguments($);
     
    131130} elsif ($mergeDriver) {
    132131    my ($base, $theirs, $ours) = @ARGV;
    133     if (mergeChanges($ours, $base, $theirs)) {
     132    if (mergeChangeLogs($ours, $base, $theirs)) {
    134133        unlink($ours);
    135134        copy($theirs, $ours) or die $!;
     
    402401}
    403402
    404 sub mergeChanges($$$)
    405 {
    406     my ($fileMine, $fileOlder, $fileNewer) = @_;
    407 
    408     my $traditionalReject = $fileMine =~ /\.rej$/ ? 1 : 0;
    409 
    410     local $/ = undef;
    411 
    412     my $patch;
    413     if ($traditionalReject) {
    414         open(DIFF, "<", $fileMine) or die $!;
    415         $patch = <DIFF>;
    416         close(DIFF);
    417         rename($fileMine, "$fileMine.save");
    418         rename($fileOlder, "$fileOlder.save");
    419     } else {
    420         open(DIFF, "-|", qw(diff -u -a --binary), $fileOlder, $fileMine) or die $!;
    421         $patch = <DIFF>;
    422         close(DIFF);
    423     }
    424 
    425     unlink("${fileNewer}.orig");
    426     unlink("${fileNewer}.rej");
    427 
    428     open(PATCH, "| patch --fuzz=3 --binary $fileNewer > " . File::Spec->devnull()) or die $!;
    429     print PATCH fixChangeLogPatch($patch);
    430     close(PATCH);
    431 
    432     my $result;
    433 
    434     # Refuse to merge the patch if it did not apply cleanly
    435     if (-e "${fileNewer}.rej") {
    436         unlink("${fileNewer}.rej");
    437         unlink($fileNewer);
    438         rename("${fileNewer}.orig", $fileNewer);
    439         $result = 0;
    440     } else {
    441         unlink("${fileNewer}.orig");
    442         $result = 1;
    443     }
    444 
    445     if ($traditionalReject) {
    446         rename("$fileMine.save", $fileMine);
    447         rename("$fileOlder.save", $fileOlder);
    448     }
    449 
    450     return $result;
    451 }
    452 
    453403sub parseFixMerged($$;$)
    454404{
     
    492442    return unless $fileMine && $fileOlder && $fileNewer;
    493443
    494     if (mergeChanges($fileMine, $fileOlder, $fileNewer)) {
     444    if (mergeChangeLogs($fileMine, $fileOlder, $fileNewer)) {
    495445        if ($file ne $fileNewer) {
    496446            unlink($file);
Note: See TracChangeset for help on using the changeset viewer.