prepare-ChangeLog reports function above deleted function as deleted; uninitialized value warning
when staged non-empty file for commit
https://bugs.webkit.org/show_bug.cgi?id=145082

Reviewed by Darin Adler.

Fixes two issues when running prepare-ChangeLog:
    1. The function above a deleted function is reported as changed.
    2. With a Git checkout of WebKit, a Perl uninitialized value warning is emitted when
    a new non-empty file is staged for commit (e.g. extractLineRangeBeforeAndAfterChange.pl,
    included in this patch).

Simplify code by using unified diff parsing logic for both SVN and Git support. Currently
prepare-ChangeLog has logic to parse normal diff- and unified diff- chunk range lines as
generated by `svn diff` and `git diff`, respectively. The logic for parsing these formats
has correctness issues. We should make use of the VCSUtil::parseChunkRange() to parse
chunk range lines of a unified diff as opposed to having specialized logic in prepare-ChangeLog.
VCSUtil::parseChunkRange() has existing test coverage.

* Scripts/prepare-ChangeLog:
(generateFunctionLists): Only add a line range to %line_ranges_before_changed, %line_ranges_after_changed
when the beginning line number, ending line number >= 1. Modified for-loop condition to iterate over
all the files represented by %line_ranges_before_changed and %line_ranges_after_changed so that we
examine files that only have deletions. Currently this works as a side effect of the behavior of
extractLineRangeAfterChange(), which always returns a well-formed (though nonsensical) line range for
a change that represents a deletion (e.g. extractLineRangeAfterChange("@@ -166,6 +165,0 @@") => [165, 165]).
(diffCommand): Generate a unified diff instead of a normal diff when using a SVN checkout of WebKit.
(extractLineRangeAfterChange): Remove logic to parse a normal diff chunk range line and write
the logic to parse a unified diff chunk range line in terms of VCSUtil::parseChunkRange().
We return (-1, -1) when the change represents a deletion.
(extractLineRangeBeforeChange): Remove logic to parse a normal diff chunk range line and write
the logic to parse a unified diff chunk range line in terms of VCSUtil::parseChunkRange().
We return (-1, -1) when the change represents an addition.
* Scripts/webkitperl/prepare-ChangeLog_unittest/extractLineRangeBeforeAndAfterChange.pl: Added;
unit tests.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@184521 268f45cc-cd09-0410-ab3c-d52691b4dbfc
3 files changed