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

abarth at webkit.org abarth at webkit.org
Wed Apr 7 23:43:11 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 07c69cf8f532363722b6e01126332e26b56a79b7
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 16 11:47:56 2009 +0000

    2009-11-16  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Implement PatchCollection
            https://bugs.webkit.org/show_bug.cgi?id=31541
    
            This class holds a set of patches and lets clients iterate through
            them.  Optionally, clients can install a filter.
    
            * Scripts/modules/patchcollection.py: Added.
            * Scripts/modules/patchcollection_unittest.py: Added.
            * Scripts/run-webkit-unittests:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51026 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 19bcdde..bf2df12 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,17 @@
+2009-11-16  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Implement PatchCollection
+        https://bugs.webkit.org/show_bug.cgi?id=31541
+
+        This class holds a set of patches and lets clients iterate through
+        them.  Optionally, clients can install a filter.
+
+        * Scripts/modules/patchcollection.py: Added.
+        * Scripts/modules/patchcollection_unittest.py: Added.
+        * Scripts/run-webkit-unittests:
+
 2009-11-16  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebKitTools/Scripts/modules/patchcollection.py b/WebKitTools/Scripts/modules/patchcollection.py
new file mode 100644
index 0000000..fee5d24
--- /dev/null
+++ b/WebKitTools/Scripts/modules/patchcollection.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+# Copyright (c) 2009, Google Inc. All rights reserved.
+#
+# 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.
+
+class PatchCollection:
+    def __init__(self, bugs, filter=None):
+        self._bugs = bugs
+        self._filter = filter
+        self._patches = []
+
+    def add(self, patch_id):
+        patch = self._bugs.fetch_attachment(patch_id)
+        if not patch:
+            return
+        if self._filter and not self._filter(patch):
+            return
+        self._patches.append(patch)
+
+    def add_all_from_bug(self, bug_id):
+        patches = self._bugs.fetch_patches_from_bug(bug_id)
+        for patch in patches:
+            if self._filter and not self._filter(patch):
+                continue
+            self._patches.append(patch)
+
+    def next(self):
+        return self._patches.pop(0)
+
+    def __len__(self):
+        return len(self._patches)
diff --git a/WebKitTools/Scripts/modules/patchcollection_unittest.py b/WebKitTools/Scripts/modules/patchcollection_unittest.py
new file mode 100644
index 0000000..86de81f
--- /dev/null
+++ b/WebKitTools/Scripts/modules/patchcollection_unittest.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+# Copyright (c) 2009, Google Inc. All rights reserved.
+#
+# 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.
+
+import unittest
+
+from modules.patchcollection import PatchCollection
+
+def test_filter(patch):
+    return not patch == MockBugzilla.patch_3
+
+class MockBugzilla:
+    patch_1 = ("patch", 1)
+    patch_2 = ("patch", 2)
+    patch_3 = ("patch", 3)
+    patch_4 = ("patch", 4)
+
+    def fetch_attachment(self, patch_id):
+        return self.patch_1
+
+    def fetch_patches_from_bug(self, bug_id):
+        return [self.patch_2, self.patch_3, self.patch_4]
+
+
+class MockEmptyBugzilla:
+    def fetch_attachment(self, patch_id):
+        return None
+
+    def fetch_patches_from_bug(self, bug_id):
+        return []
+
+
+class PatchCollectionTest(unittest.TestCase):
+    def test_basic(self):
+        bugs = MockBugzilla()
+        patches = PatchCollection(bugs, filter=test_filter)
+        self.assertEqual(len(patches), 0)
+        patches.add(42)
+        self.assertEqual(len(patches), 1)
+        patch = patches.next()
+        self.assertEqual(patch, MockBugzilla.patch_1)
+        self.assertEqual(len(patches), 0)
+        patches.add_all_from_bug(38)
+        # Notice that one of the patches gets filtered out.
+        self.assertEqual(len(patches), 2)
+        patch = patches.next()
+        self.assertEqual(patch, MockBugzilla.patch_2)
+        self.assertEqual(len(patches), 1)
+        patch = patches.next()
+        self.assertEqual(patch, MockBugzilla.patch_4)
+        self.assertEqual(len(patches), 0)
+
+    def test_no_patch(self):
+        bugs = MockEmptyBugzilla()
+        patches = PatchCollection(bugs, filter=test_filter)
+        self.assertEqual(len(patches), 0)
+        patches.add(42)
+        self.assertEqual(len(patches), 0)
+        patches.add_all_from_bug(38)
+        self.assertEqual(len(patches), 0)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/WebKitTools/Scripts/run-webkit-unittests b/WebKitTools/Scripts/run-webkit-unittests
index 0ad6570..8e518e2 100755
--- a/WebKitTools/Scripts/run-webkit-unittests
+++ b/WebKitTools/Scripts/run-webkit-unittests
@@ -36,6 +36,7 @@ from modules.committers_unittest import *
 from modules.cpp_style_unittest import *
 from modules.diff_parser_unittest import *
 from modules.logging_unittest import *
+from modules.patchcollection_unittest import *
 from modules.scm_unittest import *
 from modules.workqueue_unittest import *
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list