Extend diff_parser to support the --full-index output.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jan 2013 07:10:43 +0000 (07:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jan 2013 07:10:43 +0000 (07:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107408

Patch by Tim 'mithro' Ansell <mithro@mithis.com> on 2013-01-20
Reviewed by Maciej Stachowiak.

* Scripts/webkitpy/common/checkout/diff_parser.py:
(git_diff_to_svn_diff):
* Scripts/webkitpy/common/checkout/diff_parser_unittest.py:
(DiffParserTest):
(DiffParserTest.test_git_diff_to_svn_diff):
(git_diff_to_svn_diff):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140301 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/diff_parser.py
Tools/Scripts/webkitpy/common/checkout/diff_parser_unittest.py

index a62f744..e6ea4cd 100644 (file)
@@ -1,3 +1,17 @@
+2013-01-20  Tim 'mithro' Ansell  <mithro@mithis.com>
+
+        Extend diff_parser to support the --full-index output.
+        https://bugs.webkit.org/show_bug.cgi?id=107408
+
+        Reviewed by Maciej Stachowiak.
+
+        * Scripts/webkitpy/common/checkout/diff_parser.py:
+        (git_diff_to_svn_diff):
+        * Scripts/webkitpy/common/checkout/diff_parser_unittest.py:
+        (DiffParserTest):
+        (DiffParserTest.test_git_diff_to_svn_diff):
+        (git_diff_to_svn_diff):
+
 2013-01-20  Yoshifumi Inoue  <yosin@chromium.org>
 
         Dragging over an element with scrollbars should scroll the element when dragging near edges
index 2ed552c..3c5b45b 100644 (file)
@@ -58,7 +58,7 @@ def git_diff_to_svn_diff(line):
     # These regexp patterns should be compiled once instead of every time.
     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"),
+                           ("^index (([0-9a-f]{7}\.\.[0-9a-f]{7})|([0-9a-f]{40}\.\.[0-9a-f]{40})) [0-9]{6}", lambda matched: "===================================================================\n"),
                            ("^--- \w/(?P<FilePath>.+)", lambda matched: "--- " + matched.group('FilePath') + "\n"),
                            ("^\+\+\+ \w/(?P<FilePath>.+)", lambda matched: "+++ " + matched.group('FilePath') + "\n"))
 
index b48b162..832adad 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import unittest
+import cStringIO as StringIO
+import unittest2 as unittest
 import diff_parser
 import re
 
 from webkitpy.common.checkout.diff_test_data import DIFF_TEST_DATA
 
 class DiffParserTest(unittest.TestCase):
+    maxDiff = None
+
     def test_diff_parser(self, parser = None):
         if not parser:
             parser = diff_parser.DiffParser(DIFF_TEST_DATA.splitlines())
@@ -89,3 +92,48 @@ class DiffParserTest(unittest.TestCase):
         for prefix in prefixes:
             patch = p.sub(lambda x: " %s/" % prefix[x.group(1)], DIFF_TEST_DATA)
             self.test_diff_parser(diff_parser.DiffParser(patch.splitlines()))
+
+    def test_git_diff_to_svn_diff(self):
+        output = """\
+Index: Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+===================================================================
+--- Tools/Scripts/webkitpy/common/checkout/diff_parser.py
++++ Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
+ A
+ B
+ C
++D
+ E
+ F
+"""
+
+        inputfmt = StringIO.StringIO("""\
+diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+index 2ed552c4555db72df16b212547f2c125ae301a04..72870482000c0dba64ce4300ed782c03ee79b74f 100644
+--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
++++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
+ A
+ B
+ C
++D
+ E
+ F
+""")
+        shortfmt = StringIO.StringIO("""\
+diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+index b48b162..f300960 100644
+--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
++++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
+ A
+ B
+ C
++D
+ E
+ F
+""")
+
+        self.assertMultiLineEqual(output, ''.join(diff_parser.git_diff_to_svn_diff(x) for x in shortfmt.readlines()))
+        self.assertMultiLineEqual(output, ''.join(diff_parser.git_diff_to_svn_diff(x) for x in inputfmt.readlines()))