[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
vestbo at webkit.org
vestbo at webkit.org
Wed Jan 6 00:18:02 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 5ce656a0bf03939ad17e2808aec3efeb10fa674e
Author: vestbo at webkit.org <vestbo at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 4 16:12:27 2010 +0000
Add support for Git's "diff.mnemonicprefix" config option to WebKitTools
Reviewed by David Kilzer.
https://bugs.webkit.org/show_bug.cgi?id=32820
* Scripts/VCSUtils.pm:
* Scripts/svn-apply:
* Scripts/svn-unapply:
* Scripts/test-webkitperl: Run gitdiff2svndiff test
* Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl: Added.
* Scripts/webkitpy/diff_parser.py:
* Scripts/webkitpy/diff_parser_unittest.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 1eca884..ab01ae9 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,19 @@
+2010-01-04 Tor Arne Vestbø <tor.arne.vestbo at nokia.com>
+
+ Reviewed by David Kilzer.
+
+ Add support for Git's "diff.mnemonicprefix" config option to WebKitTools
+
+ https://bugs.webkit.org/show_bug.cgi?id=32820
+
+ * Scripts/VCSUtils.pm:
+ * Scripts/svn-apply:
+ * Scripts/svn-unapply:
+ * Scripts/test-webkitperl: Run gitdiff2svndiff test
+ * Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl: Added.
+ * Scripts/webkitpy/diff_parser.py:
+ * Scripts/webkitpy/diff_parser_unittest.py:
+
2010-01-04 Chris Jerdonek <chris.jerdonek at gmail.com>
Reviewed by David Kilzer.
diff --git a/WebKitTools/Scripts/VCSUtils.pm b/WebKitTools/Scripts/VCSUtils.pm
index 3879264..adf2f39 100644
--- a/WebKitTools/Scripts/VCSUtils.pm
+++ b/WebKitTools/Scripts/VCSUtils.pm
@@ -362,13 +362,13 @@ sub svnStatus($)
sub gitdiff2svndiff($)
{
$_ = shift @_;
- if (m#^diff --git a/(.+) b/(.+)#) {
+ if (m#^diff --git \w/(.+) \w/(.+)#) {
return "Index: $1";
} elsif (m#^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}#) {
return "===================================================================";
- } elsif (m#^--- a/(.+)#) {
+ } elsif (m#^--- \w/(.+)#) {
return "--- $1";
- } elsif (m#^\+\+\+ b/(.+)#) {
+ } elsif (m#^\+\+\+ \w/(.+)#) {
return "+++ $1";
}
return $_;
diff --git a/WebKitTools/Scripts/svn-apply b/WebKitTools/Scripts/svn-apply
index dc00a05..f586211 100755
--- a/WebKitTools/Scripts/svn-apply
+++ b/WebKitTools/Scripts/svn-apply
@@ -133,7 +133,7 @@ my $patch;
while (<>) {
s/([\n\r]+)$//mg;
my $eol = $1;
- if (!defined($indexPath) && m#^diff --git a/#) {
+ if (!defined($indexPath) && m#^diff --git \w/#) {
$filter = \&gitdiff2svndiff;
}
$_ = &$filter($_) if $filter;
diff --git a/WebKitTools/Scripts/svn-unapply b/WebKitTools/Scripts/svn-unapply
index 5f145b0..eb20ca0 100755
--- a/WebKitTools/Scripts/svn-unapply
+++ b/WebKitTools/Scripts/svn-unapply
@@ -104,7 +104,7 @@ my $patch;
while (<>) {
s/([\n\r]+)$//mg;
my $eol = $1;
- if (!defined($indexPath) && m#^diff --git a/#) {
+ if (!defined($indexPath) && m#^diff --git \w/#) {
$filter = \&gitdiff2svndiff;
}
$_ = &$filter($_) if $filter;
diff --git a/WebKitTools/Scripts/test-webkitperl b/WebKitTools/Scripts/test-webkitperl
index 94caeb3..e37a332 100755
--- a/WebKitTools/Scripts/test-webkitperl
+++ b/WebKitTools/Scripts/test-webkitperl
@@ -43,6 +43,7 @@ $scriptsDir =~ s|/+$||; # Remove trailing '/'
my @files = (
"fixChangeLogPatch.pl",
"generatePatchCommand.pl",
+ "gitdiff2svndiff.pl",
"runPatchCommand.pl",
);
diff --git a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl
new file mode 100644
index 0000000..6739585
--- /dev/null
+++ b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek at gmail.com)
+# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Unit tests of VCSUtils::gitdiff2svndiff()
+
+use Test::Simple tests => 6;
+use VCSUtils;
+
+my $out;
+my $title;
+
+# New test
+$title = "gitdiff2svndiff: Convert standard git diff to svn diff";
+
+my $git_patch = <<END;
+diff --git a/WebCore/rendering/style/StyleFlexibleBoxData.h b/WebCore/rendering/style/StyleFlexibleBoxData.h
+index f5d5e74..3b6aa92 100644
+--- a/WebCore/rendering/style/StyleFlexibleBoxData.h
++++ b/WebCore/rendering/style/StyleFlexibleBoxData.h
+@@ -47,7 +47,6 @@ public:
+END
+
+my $svn_patch = <<END;
+Index: WebCore/rendering/style/StyleFlexibleBoxData.h
+===================================================================
+--- WebCore/rendering/style/StyleFlexibleBoxData.h
++++ WebCore/rendering/style/StyleFlexibleBoxData.h
+@@ -47,7 +47,6 @@ public:
+END
+
+$out = "";
+
+foreach my $line (split('\n', $git_patch)) {
+ $out .= gitdiff2svndiff($line) . "\n";
+}
+
+ok($svn_patch eq $out, $title);
+
+# New test
+$title = "gitdiff2svndiff: Convert mnemonic git diff to svn diff";
+
+my @prefixes = (
+ { 'a' => 'i', 'b' => 'w' }, # git-diff (compares the (i)ndex and the (w)ork tree)
+ { 'a' => 'c', 'b' => 'w' }, # git-diff HEAD (compares a (c)ommit and the (w)ork tree)
+ { 'a' => 'c', 'b' => 'i' }, # git diff --cached (compares a (c)ommit and the (i)ndex)
+ { 'a' => 'o', 'b' => 'w' }, # git-diff HEAD:file1 file2 (compares an (o)bject and a (w)ork tree entity)
+ { 'a' => '1', 'b' => '2' }, # git diff --no-index a b (compares two non-git things (1) and (2))
+);
+
+foreach my $prefix (@prefixes) {
+ my $mnemonic_patch = $git_patch;
+ $mnemonic_patch =~ s/ a\// $prefix->{'a'}\//g;
+ $mnemonic_patch =~ s/ b\// $prefix->{'b'}\//g;
+
+ $out = "";
+ foreach my $line (split('\n', $mnemonic_patch)) {
+ $out .= gitdiff2svndiff($line) . "\n";
+ }
+
+ ok($svn_patch eq $out, $title . " (" . $prefix->{'a'} . "," . $prefix->{'b'} . ")");
+}
+
diff --git a/WebKitTools/Scripts/webkitpy/diff_parser.py b/WebKitTools/Scripts/webkitpy/diff_parser.py
index 91898af..7dce7e8 100644
--- a/WebKitTools/Scripts/webkitpy/diff_parser.py
+++ b/WebKitTools/Scripts/webkitpy/diff_parser.py
@@ -48,11 +48,11 @@ def git_diff_to_svn_diff(line):
Args:
line: A string representing a line of the diff.
"""
- conversion_patterns = (("^diff --git a/(.+) b/(?P<FilePath>.+)", lambda matched: "Index: " + matched.group('FilePath') + "\n"),
+ conversion_patterns = (("^diff --git \w/(.+) \w/(?P<FilePath>.+)", lambda matched: "Index: " + matched.group('FilePath') + "\n"),
("^new file.*", lambda matched: "\n"),
("^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}", lambda matched: "===================================================================\n"),
- ("^--- a/(?P<FilePath>.+)", lambda matched: "--- " + matched.group('FilePath') + "\n"),
- ("^\+\+\+ b/(?P<FilePath>.+)", lambda matched: "+++ " + matched.group('FilePath') + "\n"))
+ ("^--- \w/(?P<FilePath>.+)", lambda matched: "--- " + matched.group('FilePath') + "\n"),
+ ("^\+\+\+ \w/(?P<FilePath>.+)", lambda matched: "+++ " + matched.group('FilePath') + "\n"))
for pattern, conversion in conversion_patterns:
matched = match(pattern, line)
@@ -69,7 +69,7 @@ def get_diff_converter(first_diff_line):
If this line is git formatted, we'll return a
converter from git to SVN.
"""
- if match(r"^diff --git a/", first_diff_line):
+ if match(r"^diff --git \w/", first_diff_line):
return git_diff_to_svn_diff
return lambda input: input
diff --git a/WebKitTools/Scripts/webkitpy/diff_parser_unittest.py b/WebKitTools/Scripts/webkitpy/diff_parser_unittest.py
index 1c806f0..7eb0eab 100644
--- a/WebKitTools/Scripts/webkitpy/diff_parser_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/diff_parser_unittest.py
@@ -28,6 +28,7 @@
import unittest
import diff_parser
+import re
class DiffParserTest(unittest.TestCase):
@@ -82,11 +83,11 @@ index 0000000..6db26bd
@@ -0,0 +1 @@
+61a373ee739673a9dcd7bac62b9f182e
\ No newline at end of file
-'''.splitlines()
+'''
-
- def test_diff_parser(self):
- parser = diff_parser.DiffParser(self._PATCH)
+ def test_diff_parser(self, parser = None):
+ if not parser:
+ parser = diff_parser.DiffParser(self._PATCH.splitlines())
self.assertEquals(3, len(parser.files))
self.assertTrue('WebCore/rendering/style/StyleFlexibleBoxData.h' in parser.files)
@@ -126,6 +127,20 @@ index 0000000..6db26bd
self.assertEquals(1, len(diff.lines))
self.assertEquals((0, 1), diff.lines[0][0:2])
+ def test_git_mnemonicprefix(self):
+ p = re.compile(r' ([a|b])/')
+
+ prefixes = [
+ { 'a' : 'i', 'b' : 'w' }, # git-diff (compares the (i)ndex and the (w)ork tree)
+ { 'a' : 'c', 'b' : 'w' }, # git-diff HEAD (compares a (c)ommit and the (w)ork tree)
+ { 'a' : 'c', 'b' : 'i' }, # git diff --cached (compares a (c)ommit and the (i)ndex)
+ { 'a' : 'o', 'b' : 'w' }, # git-diff HEAD:file1 file2 (compares an (o)bject and a (w)ork tree entity)
+ { 'a' : '1', 'b' : '2' }, # git diff --no-index a b (compares two non-git things (1) and (2))
+ ]
+
+ for prefix in prefixes:
+ patch = p.sub(lambda x: " %s/" % prefix[x.group(1)], self._PATCH)
+ self.test_diff_parser(diff_parser.DiffParser(patch.splitlines()))
if __name__ == '__main__':
unittest.main()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list