[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

dbates at webkit.org dbates at webkit.org
Wed Dec 22 14:16:36 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 64ce91cf0c8ebdbdd7b95659bd3b7c5579e8c24a
Author: dbates at webkit.org <dbates at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 6 04:58:55 2010 +0000

    2010-10-05  Daniel Bates  <dbates at rim.com>
    
            Reviewed by David Kilzer.
    
            Add infrastructure to towards detecting change log diffs that aren't at the top of the ChangeLog
            https://bugs.webkit.org/show_bug.cgi?id=46058
    
            Make VCSUtils::fixChangeLogPatch() return a reference to a hash
            structure so as to support returning additional information
            about a change log diff.
    
            Currently, VCSUtils::fixChangeLogPatch() returns a string that
            represents the change log diff. Towards supporting the return
            of additional information, such as whether the change log diff
            inserts an entry at the top of the ChangeLog file, we need to
            make VCSUtils::fixChangeLogPatch() return a reference to hash
            structure.
    
            * Scripts/VCSUtils.pm:
              - Modified fixChangeLogPatch() to return a reference to a
                hash structure.
              - Added documentation to fixChangeLogPatch().
              - Modified call site in mergeChangeLogs() as necessary.
            * Scripts/svn-apply:
              - Modified call site in patch() as necessary.
            * Scripts/svn-create-patch:
              - Modified call site in generateDiff() as necessary.
            * Scripts/svn-unapply:
              - Modified call site in patch() as necessary.
            * Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl:
              - Modified the unit tests as necessary.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69177 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 266a515..2a31621 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,35 @@
+2010-10-05  Daniel Bates  <dbates at rim.com>
+
+        Reviewed by David Kilzer.
+
+        Add infrastructure to towards detecting change log diffs that aren't at the top of the ChangeLog
+        https://bugs.webkit.org/show_bug.cgi?id=46058
+
+        Make VCSUtils::fixChangeLogPatch() return a reference to a hash
+        structure so as to support returning additional information
+        about a change log diff.
+
+        Currently, VCSUtils::fixChangeLogPatch() returns a string that
+        represents the change log diff. Towards supporting the return
+        of additional information, such as whether the change log diff
+        inserts an entry at the top of the ChangeLog file, we need to
+        make VCSUtils::fixChangeLogPatch() return a reference to hash
+        structure.
+
+        * Scripts/VCSUtils.pm:
+          - Modified fixChangeLogPatch() to return a reference to a
+            hash structure.
+          - Added documentation to fixChangeLogPatch().
+          - Modified call site in mergeChangeLogs() as necessary.
+        * Scripts/svn-apply:
+          - Modified call site in patch() as necessary.
+        * Scripts/svn-create-patch:
+          - Modified call site in generateDiff() as necessary.
+        * Scripts/svn-unapply:
+          - Modified call site in patch() as necessary.
+        * Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl:
+          - Modified the unit tests as necessary.
+
 2010-10-05  Tony Chang  <tony at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebKitTools/Scripts/VCSUtils.pm b/WebKitTools/Scripts/VCSUtils.pm
index dd08baa..5b29bcf 100644
--- a/WebKitTools/Scripts/VCSUtils.pm
+++ b/WebKitTools/Scripts/VCSUtils.pm
@@ -1284,6 +1284,16 @@ sub setChangeLogDateAndReviewer($$$)
 # context.
 #
 # This subroutine has unit tests in VCSUtils_unittest.pl.
+#
+# Returns $changeLogHashRef:
+#   $changeLogHashRef: a hash reference representing a change log patch.
+#     patch: a ChangeLog patch equivalent to the given one, but with the
+#            newest ChangeLog entry inserted at the top of the file, if possible.
+#     hasOverlappingLines: the value 1 if the change log entry overlaps
+#                          some lines of another change log entry. This can
+#                          happen when deliberately inserting a new ChangeLog
+#                          entry earlier in the file above an entry with
+#                          the same date and author.                     
 sub fixChangeLogPatch($)
 {
     my $patch = shift; # $patch will only contain patch fragments for ChangeLog.
@@ -1301,10 +1311,12 @@ sub fixChangeLogPatch($)
         }
     }
     my $chunkStartIndex = ++$i;
+    my %changeLogHashRef;
 
     # Optimization: do not process if new lines already begin the chunk.
     if (substr($lines[$i], 0, 1) eq "+") {
-        return $patch;
+        $changeLogHashRef{patch} = $patch;
+        return \%changeLogHashRef;
     }
 
     # Skip to first line of newly added ChangeLog entry.
@@ -1321,10 +1333,12 @@ sub fixChangeLogPatch($)
         } elsif ($firstChar eq " " or $firstChar eq "+") {
             next;
         }
-        return $patch; # Do not change if, for example, "-" or "@" found.
+        $changeLogHashRef{patch} = $patch; # Do not change if, for example, "-" or "@" found.
+        return \%changeLogHashRef;
     }
     if ($i >= @lines) {
-        return $patch; # Do not change if date not found.
+        $changeLogHashRef{patch} = $patch; # Do not change if date not found.
+        return \%changeLogHashRef;
     }
     my $dateStartIndex = $i;
 
@@ -1367,7 +1381,8 @@ sub fixChangeLogPatch($)
         my $text = substr($line, 1);
         my $newLine = pop(@overlappingLines);
         if ($text ne substr($newLine, 1)) {
-            return $patch; # Unexpected difference.
+            $changeLogHashRef{patch} = $patch; # Unexpected difference.
+            return \%changeLogHashRef;
         }
         $lines[$i] = "+$text";
     }
@@ -1379,7 +1394,8 @@ sub fixChangeLogPatch($)
         # FIXME: Handle errors differently from ChangeLog files that
         # are okay but should not be altered. That way we can find out
         # if improvements to the script ever become necessary.
-        return $patch; # Error: unexpected patch string format.
+        $changeLogHashRef{patch} = $patch; # Error: unexpected patch string format.
+        return \%changeLogHashRef;
     }
     my $skippedFirstLineCount = $1 - 1;
     my $oldSourceLineCount = $2;
@@ -1388,7 +1404,9 @@ sub fixChangeLogPatch($)
     if (@overlappingLines != $skippedFirstLineCount) {
         # This can happen, for example, when deliberately inserting
         # a new ChangeLog entry earlier in the file.
-        return $patch;
+        $changeLogHashRef{hasOverlappingLines} = 1;
+        $changeLogHashRef{patch} = $patch;
+        return \%changeLogHashRef;
     }
     # If @overlappingLines > 0, this is where we make use of the
     # assumption that the beginning of the source file was not modified.
@@ -1398,7 +1416,8 @@ sub fixChangeLogPatch($)
     my $targetLineCount = $oldTargetLineCount + @overlappingLines - $deletedLineCount;
     $lines[$chunkStartIndex - 1] = "@@ -1,$sourceLineCount +1,$targetLineCount @@";
 
-    return join($lineEnding, @lines) . "\n"; # patch(1) expects an extra trailing newline.
+    $changeLogHashRef{patch} = join($lineEnding, @lines) . "\n"; # patch(1) expects an extra trailing newline.
+    return \%changeLogHashRef;
 }
 
 # This is a supporting method for runPatchCommand.
@@ -1550,7 +1569,12 @@ sub mergeChangeLogs($$$)
     unlink("${fileNewer}.rej");
 
     open(PATCH, "| patch --force --fuzz=3 --binary $fileNewer > " . File::Spec->devnull()) or die $!;
-    print PATCH ($traditionalReject ? $patch : fixChangeLogPatch($patch));
+    if ($traditionalReject) {
+        print PATCH $patch;
+    } else {
+        my $changeLogHash = fixChangeLogPatch($patch);
+        print PATCH $changeLogHash->{patch};
+    }
     close(PATCH);
 
     my $result = !exitStatus($?);
diff --git a/WebKitTools/Scripts/svn-apply b/WebKitTools/Scripts/svn-apply
index 1cf9c01..cab7fb4 100755
--- a/WebKitTools/Scripts/svn-apply
+++ b/WebKitTools/Scripts/svn-apply
@@ -316,7 +316,8 @@ sub patch($)
         # Standard patch, patch tool can handle this.
         if (basename($fullPath) eq "ChangeLog") {
             my $changeLogDotOrigExisted = -f "${fullPath}.orig";
-            my $newPatch = setChangeLogDateAndReviewer(fixChangeLogPatch($patch), $reviewer, $epochTime);
+            my $changeLogHash = fixChangeLogPatch($patch);
+            my $newPatch = setChangeLogDateAndReviewer($changeLogHash->{patch}, $reviewer, $epochTime);
             applyPatch($newPatch, $fullPath, ["--fuzz=3"]);
             unlink("${fullPath}.orig") if (! $changeLogDotOrigExisted);
         } else {
diff --git a/WebKitTools/Scripts/svn-create-patch b/WebKitTools/Scripts/svn-create-patch
index 5aead2e..863998d 100755
--- a/WebKitTools/Scripts/svn-create-patch
+++ b/WebKitTools/Scripts/svn-create-patch
@@ -232,7 +232,10 @@ sub generateDiff($$)
         $patch .= $_;
     }
     close DIFF;
-    $patch = fixChangeLogPatch($patch) if basename($file) eq "ChangeLog";
+    if (basename($file) eq "ChangeLog") {
+        my $changeLogHash = fixChangeLogPatch($patch);
+        $patch = $changeLogHash->{patch};   
+    }
     print $patch;
     if ($fileData->{isBinary}) {
         print "\n" if ($patch && $patch =~ m/\n\S+$/m);
diff --git a/WebKitTools/Scripts/svn-unapply b/WebKitTools/Scripts/svn-unapply
index 53ab1b5..1dca11c 100755
--- a/WebKitTools/Scripts/svn-unapply
+++ b/WebKitTools/Scripts/svn-unapply
@@ -158,7 +158,8 @@ sub patch($)
         # Standard patch, patch tool can handle this.
         if (basename($fullPath) eq "ChangeLog") {
             my $changeLogDotOrigExisted = -f "${fullPath}.orig";
-            unapplyPatch(unsetChangeLogDate($fullPath, fixChangeLogPatch($patch)), $fullPath, ["--fuzz=3"]);
+            my $changeLogHash = fixChangeLogPatch($patch);
+            unapplyPatch(unsetChangeLogDate($fullPath, $changeLogHash->{patch}), $fullPath, ["--fuzz=3"]);
             unlink("${fullPath}.orig") if (! $changeLogDotOrigExisted);
         } else {
             unapplyPatch($patch, $fullPath);
diff --git a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl
index ee258da..a7282c7 100644
--- a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl
+++ b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 #
 # Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek at gmail.com)
+# Copyright (C) Research In Motion 2010. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -30,7 +31,10 @@
 
 # Unit tests of VCSUtils::fixChangeLogPatch().
 
-use Test::Simple tests => 12;
+use strict;
+use warnings;
+
+use Test::More;
 use VCSUtils;
 
 # The source ChangeLog for these tests is the following:
@@ -53,14 +57,10 @@ use VCSUtils;
 #         * File:
 #         * File2:
 
-my $title;
-my $in;
-my $out;
-
-# New test
-$title = "fixChangeLogPatch: [no change] In-place change.";
-
-$in = <<'END';
+my @testCaseHashRefs = (
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] In-place change.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -1,5 +1,5 @@
@@ -71,13 +71,23 @@ $in = <<'END';
  
          Changed some code on 2010-12-22.
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] Remove first entry.";
-
-$in = <<'END';
+    expectedReturn => {
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -1,5 +1,5 @@
+ 2010-12-22  Bob  <bob at email.address>
+ 
+-        Reviewed by Sue.
++        Reviewed by Ray.
+ 
+         Changed some code on 2010-12-22.
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] Remove first entry.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -1,11 +1,3 @@
@@ -93,13 +103,28 @@ $in = <<'END';
  
          Reviewed by Ray.
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] Remove entry in the middle.";
-
-$in = <<'END';
+    expectedReturn => {
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -1,11 +1,3 @@
+-2010-12-22  Bob  <bob at email.address>
+-
+-        Reviewed by Ray.
+-
+-        Changed some code on 2010-12-22.
+-
+-        * File:
+-
+ 2010-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] Remove entry in the middle.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@@ -7,10 +7,6 @@
@@ -114,13 +139,27 @@ $in = <<'END';
  
          Reviewed by Ray.
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] Far apart changes (i.e. more than one chunk).";
-
-$in = <<'END';
+    expectedReturn => {
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@@ -7,10 +7,6 @@
+ 
+         * File:
+ 
+-2010-12-22  Bob  <bob at email.address>
+-
+-        Changed some code on 2010-12-22.
+-
+ 2010-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] Far apart changes (i.e. more than one chunk).",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -7,7 +7,7 @@
@@ -141,13 +180,33 @@ $in = <<'END';
  
          Changed some code on 2010-12-21.
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] First line is new line.";
-
-$in = <<'END';
+    expectedReturn => {
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -7,7 +7,7 @@
+ 
+         * File:
+ 
+-2010-12-22  Bob  <bob at email.address>
++2010-12-22  Bobby <bob at email.address>
+ 
+         Changed some code on 2010-12-22.
+ 
+@@ -21,7 +21,7 @@
+ 
+         * File2:
+ 
+-2010-12-21  Bob  <bob at email.address>
++2010-12-21  Bobby <bob at email.address>
+ 
+         Changed some code on 2010-12-21.
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] First line is new line.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -1,3 +1,11 @@
@@ -163,13 +222,28 @@ $in = <<'END';
  
          Reviewed by Ray.
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] No date string.";
-
-$in = <<'END';
+    expectedReturn => {
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,11 @@
++2009-12-22  Bob  <bob at email.address>
++
++        Reviewed by Ray.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
+ 2009-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] No date string.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -6,6 +6,7 @@
@@ -181,13 +255,24 @@ $in = <<'END';
  2009-12-21  Alice  <alice at email.address>
  
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] New entry inserted in middle.";
-
-$in = <<'END';
+    expectedReturn => {
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -6,6 +6,7 @@
+ 
+         * File:
+         * File2:
++        * File3:
+ 
+ 2009-12-21  Alice  <alice at email.address>
+ 
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] New entry inserted in middle.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -11,6 +11,14 @@
@@ -206,13 +291,32 @@ $in = <<'END';
  
          * File:
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] New entry inserted earlier in the file, but after an entry with the same author and date.";
-
-$in = <<'END';
+    expectedReturn => {
+    hasOverlappingLines => 1,
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -11,6 +11,14 @@
+ 
+         Reviewed by Ray.
+ 
++        Changed some more code on 2009-12-21.
++
++        * File:
++
++2009-12-21  Alice  <alice at email.address>
++
++        Reviewed by Ray.
++
+         Changed some code on 2009-12-21.
+ 
+         * File:
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: [no change] New entry inserted earlier in the file, but after an entry with the same author and date.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -70,6 +70,14 @@
@@ -231,13 +335,32 @@ $in = <<'END';
  
          Changed some code on 2009-12-22.
 END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: Leading context includes first line.";
-
-$in = <<'END';
+    expectedReturn => {
+    hasOverlappingLines => 1,
+    patch => <<'END',
+--- ChangeLog
++++ ChangeLog
+@@ -70,6 +70,14 @@
+ 
+ 2009-12-22  Alice  <alice at email.address>
+ 
++        Reviewed by Sue.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
++2009-12-22  Alice  <alice at email.address>
++
+         Reviewed by Ray.
+ 
+         Changed some code on 2009-12-22.
+END
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: Leading context includes first line.",
+    inputText => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -1,5 +1,13 @@
@@ -255,8 +378,8 @@ $in = <<'END';
  
          Changed some code on 2009-12-22.
 END
-
-$out = <<'END';
+    expectedReturn => {
+    patch => <<'END',
 --- ChangeLog
 +++ ChangeLog
 @@ -1,3 +1,11 @@
@@ -272,13 +395,11 @@ $out = <<'END';
  
          Reviewed by Ray.
 END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# New test
-$title = "fixChangeLogPatch: Leading context does not include first line.";
-
-$in = <<'END';
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: Leading context does not include first line.",
+    inputText => <<'END',
 @@ -2,6 +2,14 @@
  
          Reviewed by Ray.
@@ -295,8 +416,8 @@ $in = <<'END';
  
          * File:
 END
-
-$out = <<'END';
+    expectedReturn => {
+    patch => <<'END',
 @@ -1,3 +1,11 @@
 +2009-12-22  Alice  <alice at email.address>
 +
@@ -310,18 +431,17 @@ $out = <<'END';
  
          Reviewed by Ray.
 END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# New test
-$title = "fixChangeLogPatch: Non-consecutive line additions.";
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: Non-consecutive line additions.",
 
 # This can occur, for example, if the new ChangeLog entry includes
 # trailing white space in the first blank line but not the second.
 # A diff command can then match the second blank line of the new
 # ChangeLog entry with the first blank line of the old.
 # The svn diff command with the default --diff-cmd has done this.
-$in = <<'END';
+    inputText => <<'END',
 @@ -1,5 +1,11 @@
  2009-12-22  Alice  <alice at email.address>
 + <pretend-whitespace>
@@ -335,8 +455,8 @@ $in = <<'END';
  
          Changed some code on 2009-12-22.
 END
-
-$out = <<'END';
+    expectedReturn => {
+    patch => <<'END',
 @@ -1,3 +1,9 @@
 +2009-12-22  Alice  <alice at email.address>
 + <pretend-whitespace>
@@ -348,13 +468,11 @@ $out = <<'END';
  
          Reviewed by Ray.
 END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# New test
-$title = "fixChangeLogPatch: Additional edits after new entry.";
-
-$in = <<'END';
+    }
+},
+{ # New test
+    diffName => "fixChangeLogPatch: Additional edits after new entry.",
+    inputText => <<'END',
 @@ -2,10 +2,17 @@
  
          Reviewed by Ray.
@@ -375,8 +493,8 @@ $in = <<'END';
  2009-12-21  Alice  <alice at email.address>
  
 END
-
-$out = <<'END';
+    expectedReturn => {
+    patch => <<'END',
 @@ -1,11 +1,18 @@
 +2009-12-22  Alice  <alice at email.address>
 +
@@ -398,5 +516,18 @@ $out = <<'END';
  2009-12-21  Alice  <alice at email.address>
  
 END
+    }
+},
+);
+
+my $testCasesCount = @testCaseHashRefs;
+plan(tests => $testCasesCount); # Total number of assertions.
 
-ok(fixChangeLogPatch($in) eq $out, $title);
+foreach my $testCase (@testCaseHashRefs) {
+    my $testNameStart = "fixChangeLogPatch(): $testCase->{diffName}: comparing";
+
+    my $got = VCSUtils::fixChangeLogPatch($testCase->{inputText});
+    my $expectedReturn = $testCase->{expectedReturn};
+ 
+    is_deeply($got, $expectedReturn, "$testNameStart return value.");
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list