[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 01:09:56 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit a6d0f62d42888e450cbcfc03bcc1fdeb492f46ab
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 15 20:36:25 2010 +0000

    2010-01-15  Chris Jerdonek  <chris.jerdonek at gmail.com>
    
            Reviewed by David Kilzer.
    
            Altered parseDiffHeader() to skip unrecognized lines and
            other minor clean-ups.
    
            https://bugs.webkit.org/show_bug.cgi?id=33476
    
            * Scripts/VCSUtils.pm:
              - Changed parseDiffHeader() as follows:
                - Skips over unrecognized lines.
                - Addressed FIXME to remove substitution for "diff" line.
                - Renamed "version" header hash key to "sourceRevision".
                - Eliminated "copiedFromVersion" header hash key.
                - Included "sourceRevision" also for copied files.
                - Checks that copy revision number matches "sourceRevision".
                - No longer returns $foundHeaderEnding.
                - Dies if header ending not found.
                - Diff header dividing line now always added.
    
            * Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl:
              - Made necessary changes in parseDiffHeader() unit tests.
              - Shortened the file paths in some test cases.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53340 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index d0dd55c..7a3586e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,28 @@
+2010-01-15  Chris Jerdonek  <chris.jerdonek at gmail.com>
+
+        Reviewed by David Kilzer.
+
+        Altered parseDiffHeader() to skip unrecognized lines and
+        other minor clean-ups.
+
+        https://bugs.webkit.org/show_bug.cgi?id=33476
+
+        * Scripts/VCSUtils.pm:
+          - Changed parseDiffHeader() as follows:
+            - Skips over unrecognized lines.
+            - Addressed FIXME to remove substitution for "diff" line.
+            - Renamed "version" header hash key to "sourceRevision".
+            - Eliminated "copiedFromVersion" header hash key.
+            - Included "sourceRevision" also for copied files.
+            - Checks that copy revision number matches "sourceRevision".
+            - No longer returns $foundHeaderEnding.
+            - Dies if header ending not found.
+            - Diff header dividing line now always added.
+
+        * Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl:
+          - Made necessary changes in parseDiffHeader() unit tests.
+          - Shortened the file paths in some test cases.
+
 2010-01-14  Yuzo Fujishima  <yuzo at google.com>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/WebKitTools/Scripts/VCSUtils.pm b/WebKitTools/Scripts/VCSUtils.pm
index 18adb15..764fdbd 100644
--- a/WebKitTools/Scripts/VCSUtils.pm
+++ b/WebKitTools/Scripts/VCSUtils.pm
@@ -370,6 +370,7 @@ sub gitdiff2svndiff($)
         return "Index: $1$POSTMATCH";
     }
     if (m#^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}#) {
+        # FIXME: No need to return dividing line once parseDiffHeader() is used.
         return "===================================================================$POSTMATCH";
     }
     if (m#^--- \w/([^\r\n]+)#) {
@@ -385,7 +386,9 @@ sub gitdiff2svndiff($)
 # the file handle so the last line read is the first line after the
 # parsed header block.
 #
-# This subroutine dies if given leading junk.
+# This subroutine dies if given leading junk or if the end of the header
+# block could not be detected. The last line of a header block is a
+# line beginning with "+++".
 #
 # Args:
 #   $fileHandle: advanced so the last line read is the first line of the
@@ -393,19 +396,18 @@ sub gitdiff2svndiff($)
 #                "Index:" line.
 #   $line: the line last read from $fileHandle
 #
-# Returns ($headerHashRef, $foundHeaderEnding, $lastReadLine):
+# Returns ($headerHashRef, $lastReadLine):
 #   $headerHashRef: a hash reference representing a diff header
-#     copiedFromPath: the path in the "from" clause, if any.
-#     copiedFromVersion: the revision number in the "from" clause, if any.
+#     copiedFromPath: if a file copy, the path from which the file was
+#                     copied. Otherwise, undefined.
 #     indexPath: the path in the "Index:" line.
+#     sourceRevision: the revision number of the source. This is the same
+#                     as the revision number the file was copied from, in
+#                     the case of a file copy.
 #     svnConvertedText: the header text converted to SVN format.
-#                       Unrecognized Git lines are left alone.
-#     version: the revision number of the source.
-#   $foundHeaderEnding: whether the last header block line was found.
-#                       This is a line beginning with "+++".
-#   $lastReadLine: the line last read from $fileHandle. If EOF has not
-#                  been reached, this is the first line after the
-#                  header ending.
+#                       Unrecognized lines are discarded.
+#   $lastReadLine: the line last read from $fileHandle. This is the first
+#                  line after the header ending.
 sub parseDiffHeader($$)
 {
     my ($fileHandle, $line) = @_;
@@ -425,8 +427,9 @@ sub parseDiffHeader($$)
 
     my %header;
 
-    my $foundHeaderEnding = 0;
-    my $lastReadLine;
+    my $foundHeaderEnding;
+    my $lastReadLine; 
+    my $sourceRevision;
     my $svnConvertedText = $line;
     while (<$fileHandle>) {
         # Temporarily strip off any end-of-line characters to simplify
@@ -436,31 +439,45 @@ sub parseDiffHeader($$)
 
         $_ = &$filter($_) if $filter;
 
-        # Fix paths on "diff", "---", and "+++" lines to match the
-        # leading index line.
-        s/\S+$/$indexPath/ if /^diff/; # FIXME: Can this ever occur? If so, include
-                                       #        a unit test. Otherwise, remove it.
-        s/^--- \S+/--- $indexPath/;
-        if (/^--- .+\(from (\S+):(\d+)\)$/) {
-            $header{copiedFromPath} = $1;
-            $header{copiedFromVersion} = $2 if ($2 != 0);
-        } elsif (/^--- .+\(revision (\d+)\)$/) {
-            $header{version} = $1 if ($1 != 0);
+        # Fix paths on ""---" and "+++" lines to match the leading
+        # index line.
+        if (s/^--- \S+/--- $indexPath/) {
+            # ---
+            if (/^--- .+\(revision (\d+)\)/) {
+                $sourceRevision = $1 if ($1 != 0);
+                if (/\(from (\S+):(\d+)\)$/) {
+                    # The "from" clause is created by svn-create-patch, in
+                    # which case there is always also a "revision" clause.
+                    $header{copiedFromPath} = $1;
+                    die("Revision number \"$2\" in \"from\" clause does not match " .
+                        "source revision number \"$sourceRevision\".") if ($2 != $sourceRevision);
+                }
+            }
+            $_ = "=" x 67 . "$eol$_"; # Prepend dividing line ===....
         } elsif (s/^\+\+\+ \S+/+++ $indexPath/) {
+            # +++
             $foundHeaderEnding = 1;
+        } else {
+            # Skip unrecognized lines.
+            next;
         }
 
-        $svnConvertedText .= "$_$eol"; # Also restore EOL characters.
+        $svnConvertedText .= "$_$eol"; # Also restore end-of-line characters.
         if ($foundHeaderEnding) {
             $lastReadLine = <$fileHandle>;
             last;
         }
     } # $lastReadLine is undef if while loop ran out.
 
+    if (!$foundHeaderEnding) {
+        die("Did not find end of header block corresponding to index path \"$indexPath\".");
+    }
+
     $header{indexPath} = $indexPath;
+    $header{sourceRevision} = $sourceRevision;
     $header{svnConvertedText} = $svnConvertedText;
 
-    return (\%header, $foundHeaderEnding, $lastReadLine);
+    return (\%header, $lastReadLine);
 }
 
 # If possible, returns a ChangeLog patch equivalent to the given one,
diff --git a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl
index 8c861aa..d095dc0 100644
--- a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl
+++ b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl
@@ -38,10 +38,9 @@ use VCSUtils;
 
 my @headerKeys = ( # The $headerHashRef keys to check.
     "copiedFromPath",
-    "copiedFromVersion",
     "indexPath",
+    "sourceRevision",
     "svnConvertedText",
-    "version",
 );
 
 # Test parseDiffHeader() for the given $diffTestHashRef.
@@ -54,7 +53,7 @@ sub doDiffTest($)
 
     my $line = <$fileHandle>;
 
-    my ($headerHashRef, $foundHeaderEnding, $lastReadLine) = VCSUtils::parseDiffHeader($fileHandle, $line);
+    my ($headerHashRef, $lastReadLine) = VCSUtils::parseDiffHeader($fileHandle, $line);
 
     my $titleHeader = "parseDiffHeader(): [$diffTestHashRef->{diffName}] ";
     my $title;
@@ -64,32 +63,13 @@ sub doDiffTest($)
         is($headerHashRef->{$headerKey}, $diffTestHashRef->{$headerKey}, $title);
     }
 
-    is($foundHeaderEnding, $diffTestHashRef->{foundHeaderEnding}, "${titleHeader}foundHeaderEnding");
     is($lastReadLine, $diffTestHashRef->{lastReadLine}, "${titleHeader}lastReadLine");
 
     my $nextLine = <$fileHandle>;
     is($nextLine, $diffTestHashRef->{nextLine}, "${titleHeader}nextLine");
 }
 
-my @diffTests = ({
-    # New test: missing closing header line
-    diffName => "SVN: incomplete header",
-    inputText => <<'END',
-Index: WebKitTools/Scripts/VCSUtils.pm
-END
-    # Header keys to check
-    svnConvertedText => <<'END',
-Index: WebKitTools/Scripts/VCSUtils.pm
-END
-    copiedFromPath => undef,
-    copiedFromVersion => undef,
-    indexPath => "WebKitTools/Scripts/VCSUtils.pm",
-    version => undef,
-    # Other values to check
-    foundHeaderEnding => 0,
-    lastReadLine => undef,
-    nextLine => undef,
-},
+my @diffTests = (
 {
     # New test
     diffName => "SVN: simple",
@@ -109,11 +89,9 @@ Index: WebKitTools/Scripts/VCSUtils.pm
 +++ WebKitTools/Scripts/VCSUtils.pm	(working copy)
 END
     copiedFromPath => undef,
-    copiedFromVersion => undef,
     indexPath => "WebKitTools/Scripts/VCSUtils.pm",
-    version => "53004",
+    sourceRevision => "53004",
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -32,6 +32,7 @@ use strict;\n",
     nextLine => " use warnings;\n",
 },
@@ -136,11 +114,9 @@ Index: WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl
 +++ WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl	(revision 0)
 END
     copiedFromPath => undef,
-    copiedFromVersion => undef,
     indexPath => "WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiffHeader.pl",
-    version => undef,
+    sourceRevision => undef,
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -0,0 +1,262 @@\n",
     nextLine => "+#!/usr/bin/perl -w\n",
 },
@@ -148,82 +124,76 @@ END
     # New test
     diffName => "SVN: copy",
     inputText => <<'END',
-Index: WebKitTools/Scripts/webkitpy/move_test.py
+Index: index_path.py
 ===================================================================
---- WebKitTools/Scripts/webkitpy/move_test.py	(revision 53047)	(from WebKitTools/Scripts/webkitpy/__init__.py:53048)
-+++ WebKitTools/Scripts/webkitpy/move_test.py	(working copy)
+--- index_path.py	(revision 53048)	(from copied_from_path.py:53048)
++++ index_path.py	(working copy)
 @@ -0,0 +1,7 @@
-+# Required for Python to search this directory for module files
++# Python file...
 END
     # Header keys to check
     svnConvertedText => <<'END',
-Index: WebKitTools/Scripts/webkitpy/move_test.py
+Index: index_path.py
 ===================================================================
---- WebKitTools/Scripts/webkitpy/move_test.py	(revision 53047)	(from WebKitTools/Scripts/webkitpy/__init__.py:53048)
-+++ WebKitTools/Scripts/webkitpy/move_test.py	(working copy)
+--- index_path.py	(revision 53048)	(from copied_from_path.py:53048)
++++ index_path.py	(working copy)
 END
-    copiedFromPath => "WebKitTools/Scripts/webkitpy/__init__.py",
-    copiedFromVersion => "53048",
-    indexPath => "WebKitTools/Scripts/webkitpy/move_test.py",
-    version => undef,
+    copiedFromPath => "copied_from_path.py",
+    indexPath => "index_path.py",
+    sourceRevision => 53048,
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -0,0 +1,7 @@\n",
-    nextLine => "+# Required for Python to search this directory for module files\n",
+    nextLine => "+# Python file...\n",
 },
 {
     # New test
     diffName => "SVN: \\r\\n lines",
     inputText => <<END, # No single quotes to allow interpolation of "\r"
-Index: WebKitTools/Scripts/webkitpy/move_test.py\r
+Index: index_path.py\r
 ===================================================================\r
---- WebKitTools/Scripts/webkitpy/move_test.py	(revision 53047)	(from WebKitTools/Scripts/webkitpy/__init__.py:53048)\r
-+++ WebKitTools/Scripts/webkitpy/move_test.py	(working copy)\r
+--- index_path.py	(revision 53048)	(from copied_from_path.py:53048)\r
++++ index_path.py	(working copy)\r
 @@ -0,0 +1,7 @@\r
-+# Required for Python to search this directory for module files\r
++# Python file...\r
 END
     # Header keys to check
     svnConvertedText => <<END, # No single quotes to allow interpolation of "\r"
-Index: WebKitTools/Scripts/webkitpy/move_test.py\r
+Index: index_path.py\r
 ===================================================================\r
---- WebKitTools/Scripts/webkitpy/move_test.py	(revision 53047)	(from WebKitTools/Scripts/webkitpy/__init__.py:53048)\r
-+++ WebKitTools/Scripts/webkitpy/move_test.py	(working copy)\r
+--- index_path.py	(revision 53048)	(from copied_from_path.py:53048)\r
++++ index_path.py	(working copy)\r
 END
-    copiedFromPath => "WebKitTools/Scripts/webkitpy/__init__.py",
-    copiedFromVersion => "53048",
-    indexPath => "WebKitTools/Scripts/webkitpy/move_test.py",
-    version => undef,
+    copiedFromPath => "copied_from_path.py",
+    indexPath => "index_path.py",
+    sourceRevision => 53048,
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -0,0 +1,7 @@\r\n",
-    nextLine => "+# Required for Python to search this directory for module files\r\n",
+    nextLine => "+# Python file...\r\n",
 },
 {
     # New test
     diffName => "SVN: path corrections",
     inputText => <<'END',
-Index: WebKitTools/Scripts/webkitpy/move_test.py
+Index: index_path.py
 ===================================================================
---- bad_path	(revision 53047)	(from WebKitTools/Scripts/webkitpy/__init__.py:53048)
+--- bad_path	(revision 53048)	(from copied_from_path.py:53048)
 +++ bad_path	(working copy)
 @@ -0,0 +1,7 @@
-+# Required for Python to search this directory for module files
++# Python file...
 END
     # Header keys to check
     svnConvertedText => <<'END',
-Index: WebKitTools/Scripts/webkitpy/move_test.py
+Index: index_path.py
 ===================================================================
---- WebKitTools/Scripts/webkitpy/move_test.py	(revision 53047)	(from WebKitTools/Scripts/webkitpy/__init__.py:53048)
-+++ WebKitTools/Scripts/webkitpy/move_test.py	(working copy)
+--- index_path.py	(revision 53048)	(from copied_from_path.py:53048)
++++ index_path.py	(working copy)
 END
-    copiedFromPath => "WebKitTools/Scripts/webkitpy/__init__.py",
-    copiedFromVersion => "53048",
-    indexPath => "WebKitTools/Scripts/webkitpy/move_test.py",
-    version => undef,
+    copiedFromPath => "copied_from_path.py",
+    indexPath => "index_path.py",
+    sourceRevision => 53048,
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -0,0 +1,7 @@\n",
-    nextLine => "+# Required for Python to search this directory for module files\n",
+    nextLine => "+# Python file...\n",
 },
 {
     # New test
@@ -243,11 +213,9 @@ Index: WebCore/rendering/style/StyleFlexibleBoxData.h
 +++ WebCore/rendering/style/StyleFlexibleBoxData.h
 END
     copiedFromPath => undef,
-    copiedFromVersion => undef,
     indexPath => "WebCore/rendering/style/StyleFlexibleBoxData.h",
-    version => undef,
+    sourceRevision => undef,
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -47,7 +47,6 @@ public:\n",
     nextLine => undef,
 },
@@ -266,23 +234,20 @@ END
     # Header keys to check
     svnConvertedText => <<'END',
 Index: LayoutTests/http/tests/security/listener/xss-inactive-closure.html
-new file mode 100644
-index 0000000..3c9f114
+===================================================================
 --- LayoutTests/http/tests/security/listener/xss-inactive-closure.html
 +++ LayoutTests/http/tests/security/listener/xss-inactive-closure.html
 END
     copiedFromPath => undef,
-    copiedFromVersion => undef,
     indexPath => "LayoutTests/http/tests/security/listener/xss-inactive-closure.html",
-    version => undef,
+    sourceRevision => undef,
     # Other values to check
-    foundHeaderEnding => 1,
     lastReadLine => "@@ -0,0 +1,34 @@\n",
     nextLine => "+<html>\n",
 },
 );
 
-plan(tests => @diffTests * 8); # Eight assertions per call to doDiffTest().
+plan(tests => @diffTests * 6); # Multiply by number of assertions per call to doDiffTest().
 
 foreach my $diffTestHashRef (@diffTests) {
     doDiffTest($diffTestHashRef);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list