Changeset 56472 in webkit


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

<http://webkit.org/b/36560> resolve-ChangeLogs: git-rebase fails when resolve-ChangeLogs can't merge

Reviewed by Eric Seidel.

When resolve-ChangeLogs fails to merge a patch while running as
a git merge driver, it deletes the original file, which causes
an internal failure and stops git mid-merge:

fatal: Failed to execute internal merge

The fix is to use the --force switch with patch so that it will
always attempt to apply the patch. (The change in
mergeChangeLogs() for the previous commit also fixed this, but
adding --force also prevents any potential user interaction that
patch may want to display.)

  • Scripts/VCSUtils.pm:

(mergeChangeLogs): Added --force switch to patch command. Also
changed to use the exit status from the patch command to
determine the return value for this method.

  • Scripts/webkitperl/VCSUtils_unittest/mergeChangeLogs.pl: Added

test to cover this bug.

Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56471 r56472  
     12010-03-24  David Kilzer  <ddkilzer@apple.com>
     2
     3        <http://webkit.org/b/36560> resolve-ChangeLogs: git-rebase fails when resolve-ChangeLogs can't merge
     4
     5        Reviewed by Eric Seidel.
     6
     7        When resolve-ChangeLogs fails to merge a patch while running as
     8        a git merge driver, it deletes the original file, which causes
     9        an internal failure and stops git mid-merge:
     10
     11            fatal: Failed to execute internal merge
     12
     13        The fix is to use the --force switch with patch so that it will
     14        always attempt to apply the patch.  (The change in
     15        mergeChangeLogs() for the previous commit also fixed this, but
     16        adding --force also prevents any potential user interaction that
     17        patch may want to display.)
     18
     19        * Scripts/VCSUtils.pm:
     20        (mergeChangeLogs): Added --force switch to patch command.  Also
     21        changed to use the exit status from the patch command to
     22        determine the return value for this method.
     23        * Scripts/webkitperl/VCSUtils_unittest/mergeChangeLogs.pl: Added
     24        test to cover this bug.
     25
    1262010-03-24  David Kilzer  <ddkilzer@apple.com>
    227
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r56471 r56472  
    862862    unlink("${fileNewer}.rej");
    863863
    864     open(PATCH, "| patch --fuzz=3 --binary $fileNewer > " . File::Spec->devnull()) or die $!;
     864    open(PATCH, "| patch --force --fuzz=3 --binary $fileNewer > " . File::Spec->devnull()) or die $!;
    865865    print PATCH ($traditionalReject ? $patch : fixChangeLogPatch($patch));
    866866    close(PATCH);
    867867
    868     my $result;
     868    my $result = !exitStatus($?);
    869869
    870870    # Refuse to merge the patch if it did not apply cleanly
     
    875875            rename("${fileNewer}.orig", $fileNewer);
    876876        }
    877         $result = 0;
    878877    } else {
    879878        unlink("${fileNewer}.orig");
    880         $result = 1;
    881879    }
    882880
  • trunk/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/mergeChangeLogs.pl

    r56471 r56472  
    2727use strict;
    2828
    29 use Test::Simple tests => 12;
     29use Test::Simple tests => 16;
    3030use File::Temp qw(tempfile);
    3131use VCSUtils;
     
    264264# --------------------------------------------------------------------------------
    265265
     266{
     267    # New test
     268    my $title = "mergeChangeLogs: patch fails";
     269
     270    my $fileMineContent = <<'EOF';
     2712010-01-29  Mark Rowe  <mrowe@apple.com>
     272
     273        Fix the Mac build.
     274
     275        Disable ENABLE_INDEXED_DATABASE since it is "completely non-functional".
     276
     2772010-01-29  Simon Hausmann  <simon.hausmann@nokia.com>
     278
     279        Rubber-stamped by Maciej Stachowiak.
     280
     281        Fix the ARM build.
     282EOF
     283    my $fileMine = writeTempFile("fileMine", "", $fileMineContent);
     284
     285    my $fileOlderContent = <<'EOF';
     2862010-01-29  Mark Rowe  <mrowe@apple.com>
     287
     288        Fix the Mac build.
     289
     290        Disable ENABLE_INDEXED_DATABASE since it is "completely non-functional".
     291
     2922010-01-29  Oliver Hunt  <oliver@apple.com>
     293
     294        Reviewed by Darin Adler.
     295
     296        JSC is failing to propagate anonymous slot count on some transitions
     297
     2982010-01-29  Simon Hausmann  <simon.hausmann@nokia.com>
     299
     300        Rubber-stamped by Maciej Stachowiak.
     301
     302        Fix the ARM build.
     303EOF
     304    my $fileOlder = writeTempFile("fileOlder", "", $fileOlderContent);
     305
     306    my $fileNewerContent = <<'EOF';
     3072010-01-29  Oliver Hunt  <oliver@apple.com>
     308
     309        Reviewed by Darin Adler.
     310
     311        JSC is failing to propagate anonymous slot count on some transitions
     312
     3132010-01-29  Simon Hausmann  <simon.hausmann@nokia.com>
     314
     315        Rubber-stamped by Maciej Stachowiak.
     316
     317        Fix the ARM build.
     318EOF
     319    my $fileNewer = writeTempFile("fileNewer", "", $fileNewerContent);
     320
     321    my $exitStatus = mergeChangeLogs($fileMine, $fileOlder, $fileNewer);
     322
     323    # mergeChangeLogs() should return a non-zero exit status since the patch failed.
     324    ok($exitStatus == 0, "$title: return non-zero exit status for failure");
     325
     326    ok(readFile($fileMine) eq $fileMineContent, "$title: \$fileMine should be unchanged");
     327    ok(readFile($fileOlder) eq $fileOlderContent, "$title: \$fileOlder should be unchanged");
     328
     329    # $fileNewer should still exist unchanged because the patch failed
     330    ok(readFile($fileNewer) eq $fileNewerContent, "$title: \$fileNewer should be unchanged");
     331
     332    unlink($fileMine, $fileOlder, $fileNewer);
     333}
     334
     335# --------------------------------------------------------------------------------
     336
Note: See TracChangeset for help on using the changeset viewer.