Changeset 183030 in webkit


Ignore:
Timestamp:
Apr 20, 2015, 3:05:52 PM (10 years ago)
Author:
matthew_hanson@apple.com
Message:

prepare-ChangeLog should ignore the preceeding function when processing the removal of a function.
https://bugs.webkit.org/show_bug.cgi?id=143897

Reviewed by David Kilzer.

This is a speculative fix that addresses two issues:

  1. An off-by-one error which allowed ending lines to be less than starting lines when a hunk was a pure delete.

We were determining ending lines from combined diffs using the logic: End = Start + Offset - 1.

So for a hunk like "@@ -723,10 +721,0 @@ bool foobar", we were generating the following starting/ending line pairs:
Before: (723, 729)
After: (721, 720)

Before is correct, but After should be (721, 721), since it represents the beginning and ending lines for the hunk.
Whether there are zero lines or one line in the hunk, the starting and ending line are the same.

This error was causing bad behavior on purely additive and purely subtractive hunks, but since we only refer
to After when generating ChangeLog output, the extractLineRangeBeforeChange had no visible effect on program output.

The fix is to set End to the max of Start + Offset - 1 and Start, rather than always using the former.

  1. Creating git diffs from HEAD and not origin/master by default.

Hard-coding origin/master into the originalFile command has the disadvantage of causing the diff to fail entirely
when origin/master does not exist, and to do the wrong thing when determining deleted functions/methods.

  • Scripts/prepare-ChangeLog:

(originalFile):
Use HEAD instead of origin/master in default Git case.

(generateFunctionLists):
Ensure that the end line is not less than the start line.

(extractLineRangeAfterChange):
Set the end line to the start line if the end line is less than the start line.

(extractLineRangeBeforeChange):
Ditto.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r183029 r183030  
     12015-04-17  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        prepare-ChangeLog should ignore the preceeding function when processing the removal of a function.
     4        https://bugs.webkit.org/show_bug.cgi?id=143897
     5
     6        Reviewed by David Kilzer.
     7
     8        This is a speculative fix that addresses two issues:
     9
     10        1. An off-by-one error which allowed ending lines to be less than starting lines when a hunk was a pure delete.
     11        We were determining ending lines from combined diffs using the logic: End = Start + Offset - 1.
     12
     13        So for a hunk like "@@ -723,10 +721,0 @@ bool foobar", we were generating the following starting/ending line pairs:
     14        Before: (723, 729)
     15        After: (721, 720)
     16
     17        Before is correct, but After should be (721, 721), since it represents the beginning and ending lines for the hunk.
     18        Whether there are zero lines or one line in the hunk, the starting and ending line are the same.
     19
     20        This error was causing bad behavior on purely additive and purely subtractive hunks, but since we only refer
     21        to After when generating ChangeLog output, the extractLineRangeBeforeChange had no visible effect on program output.
     22
     23        The fix is to set End to the max of Start + Offset - 1 and Start, rather than always using the former.
     24
     25        2. Creating git diffs from HEAD and not origin/master by default.
     26
     27        Hard-coding origin/master into the originalFile command has the disadvantage of causing the diff to fail entirely
     28        when origin/master does not exist, and to do the wrong thing when determining deleted functions/methods.
     29
     30        * Scripts/prepare-ChangeLog:
     31        (originalFile):
     32        Use HEAD instead of origin/master in default Git case.
     33
     34        (generateFunctionLists):
     35        Ensure that the end line is not less than the start line.
     36
     37        (extractLineRangeAfterChange):
     38        Set the end line to the start line if the end line is less than the start line.
     39
     40        (extractLineRangeBeforeChange):
     41        Ditto.
     42
    1432015-04-17  Matthew Hanson  <matthew_hanson@apple.com>
    244
  • trunk/Tools/Scripts/prepare-ChangeLog

    r183029 r183030  
    6161use Getopt::Long;
    6262use lib $FindBin::Bin;
    63 use List::Util qw/any/;
     63use List::Util qw/any max/;
    6464use POSIX qw(strftime);
    6565use VCSUtils;
     
    258258            $command .= "$mergeBase";
    259259        } else {
    260             $command .= "origin/master";
     260            $command .= "HEAD";
    261261        }
    262262        $command .= ":$file";
     
    288288                }
    289289                my ($after_start, $after_end) = extractLineRangeAfterChange($_);
    290                 if ($after_start >= 0 && $after_end >= 0) {
     290                if ($after_start >= 0 && $after_end >= 0 && $after_end >= $after_start) {
    291291                    push @{$line_ranges_after_changed{$file}}, [ $after_start, $after_end ];
    292292                } elsif (/DO_NOT_COMMIT/) {
     
    21092109    } elsif (isGit() && $string =~ /^@@ -\d+(,\d+)? \+(\d+)(,(\d+))? @@/) {
    21102110        $start = $2;
    2111         $end = defined($4) ? $4 + $2 - 1 : $2;
     2111        $end = defined($4) ? max($start + $4 - 1, $start) : $start;
    21122112    }
    21132113
     
    21262126    } elsif (isGit() && $string =~ /^@@ -(\d+)(,(\d+))? \+\d+(,\d+)? @@/) {
    21272127        $start = $1;
    2128         $end = defined($3) ? $3 + $1 - 1 : $1;
     2128        $end = defined($3) ? max($start + $3 - 1, $start) : $start;
    21292129    }
    21302130
Note: See TracChangeset for help on using the changeset viewer.