Changeset 58741 in webkit


Ignore:
Timestamp:
May 4, 2010 1:00:54 AM (14 years ago)
Author:
Chris Jerdonek
Message:

2010-05-04 Chris Jerdonek <Chris Jerdonek>

Reviewed by Eric Seidel.

Adjusted svn-apply and -unapply to accept git diffs generated
using the --no-prefix flag.

https://bugs.webkit.org/show_bug.cgi?id=32438

  • Scripts/VCSUtils.pm:
    • Loosened the regular expression for the "diff --git" line to match when the --no-prefix flag is used with "git diff".
    • Also refactored the code parsing the first line so that the script exits with an error message if the first line cannot be parsed.
  • Scripts/webkitperl/VCSUtils_unittest/parseGitDiffHeader.pl:
    • Added a unit test case for the --no-prefix case.
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r58739 r58741  
     12010-05-04  Chris Jerdonek  <cjerdonek@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Adjusted svn-apply and -unapply to accept git diffs generated
     6        using the --no-prefix flag.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=32438
     9
     10        * Scripts/VCSUtils.pm:
     11          - Loosened the regular expression for the "diff --git" line to
     12            match when the --no-prefix flag is used with "git diff".
     13          - Also refactored the code parsing the first line so that the
     14            script exits with an error message if the first line cannot
     15            be parsed.
     16        * Scripts/webkitperl/VCSUtils_unittest/parseGitDiffHeader.pl:
     17          - Added a unit test case for the --no-prefix case.
     18
    1192010-05-04  Chris Jerdonek  <cjerdonek@webkit.org>
    220
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r58739 r58741  
    440440    $_ = $line;
    441441
    442     my $headerStartRegEx = qr/^diff --git /;
    443 
    444     if (!/$headerStartRegEx/) {
    445         die("First line of Git diff does not begin with \"diff --git \": \"$_\"");
     442    my $headerStartRegEx = qr#^diff --git (\w/)?(.+) (\w/)?([^\r\n]+)#;
     443    my $indexPath;
     444    if (/$headerStartRegEx/) {
     445        $indexPath = $2;
     446        # Use $POSTMATCH to preserve the end-of-line character.
     447        $_ = "Index: $indexPath$POSTMATCH"; # Convert to SVN format.
     448    } else {
     449        die("Could not parse leading \"diff --git\" line: \"$line\".");
    446450    }
    447451
    448452    my $foundHeaderEnding;
    449     my $indexPath;
    450453    my $newExecutableBit = 0;
    451454    my $oldExecutableBit = 0;
     
    457460        my $eol = $1;
    458461
    459         if (m#^diff --git \w/(.+) \w/([^\r\n]+)#) {
    460             $indexPath = $1;
    461             $_ = "Index: $indexPath"; # Convert to SVN format.
    462         } elsif (/^(deleted file|old) mode ([0-9]{6})/) {
     462        if (/^(deleted file|old) mode ([0-9]{6})/) {
    463463            $oldExecutableBit = (isExecutable($2) ? 1 : 0);
    464464        } elsif (/^new( file)? mode ([0-9]{6})/) {
  • trunk/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseGitDiffHeader.pl

    r58681 r58741  
    8484    expectedNextLine => "+<html>\n",
    8585},
     86{   # New test
     87    diffName => "using --no-prefix",
     88    inputText => <<'END',
     89diff --git foo.h foo.h
     90index c925780..9e65c43 100644
     91--- foo.h
     92+++ foo.h
     93@@ -1,3 +1,17 @@
     94+contents
     95END
     96    expectedReturn => [
     97{
     98    svnConvertedText => <<'END',
     99Index: foo.h
     100index c925780..9e65c43 100644
     101--- foo.h
     102+++ foo.h
     103END
     104    executableBitDelta => 0,
     105    indexPath => "foo.h",
     106},
     107"@@ -1,3 +1,17 @@\n"],
     108    expectedNextLine => "+contents\n",
     109},
    86110####
    87111#    Binary file test cases
Note: See TracChangeset for help on using the changeset viewer.