[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:21 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit e7b41ce08f2a2e802d2b67e8892c78a4e0631b92
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 16 12:29:21 2009 +0000

    2009-11-16  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Move StyleQueue over to using PatchCollection
            https://bugs.webkit.org/show_bug.cgi?id=31544
    
            That's what the class it's for.
    
            * Scripts/bugzilla-tool:
            * Scripts/modules/patchcollection.py:
            * Scripts/modules/patchcollection_unittest.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51030 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index c95442e..5396f84 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,16 @@
+2009-11-16  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Move StyleQueue over to using PatchCollection
+        https://bugs.webkit.org/show_bug.cgi?id=31544
+
+        That's what the class it's for.
+
+        * Scripts/bugzilla-tool:
+        * Scripts/modules/patchcollection.py:
+        * Scripts/modules/patchcollection_unittest.py:
+
 2009-11-16  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index 00c73b0..7a61df8 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -45,6 +45,7 @@ from modules.bugzilla import Bugzilla, parse_bug_id
 from modules.changelogs import ChangeLog
 from modules.comments import bug_comment_from_commit_text
 from modules.logging import error, log, tee
+from modules.patchcollection import PatchCollection
 from modules.scm import CommitMessage, detect_scm_system, ScriptError, CheckoutNeedsUpdate
 from modules.buildbot import BuildBot
 from modules.statusbot import StatusBot
@@ -751,6 +752,9 @@ class AbstractQueue(Command, WorkQueueDelegate):
         bugzilla_tool_args = [bugzilla_tool_path] + args
         WebKitLandingScripts.run_and_throw_if_fail(bugzilla_tool_args)
 
+    def log_progress(self, patch_ids):
+        log("%s in %s [%s]" % (pluralize('patch', len(patch_ids)), self._name, ", ".join(patch_ids)))
+
     def execute(self, options, args, tool):
         self.options = options
         self.tool = tool
@@ -797,20 +801,19 @@ class CommitQueue(AbstractQueue):
 
 class StyleQueue(AbstractQueue):
     def __init__(self):
-        self.patches = []
         AbstractQueue.__init__(self, "style-queue")
 
     def status_host(self):
         return None # FIXME: A hack until we come up with a more generic status page.
 
+    def begin_work_queue(self):
+        AbstractQueue.begin_work_queue(self)
+        self._patches = PatchCollection(self.tool.bugs)
+        self._patches.add_patches(self.tool.bugs.fetch_patches_from_review_queue(limit=10))
+
     def next_work_item(self):
-        if not self.patches:
-            self.patches = self.tool.bugs.fetch_patches_from_review_queue(limit=10)
-            if not self.patches:
-                return None
-        patch_ids = map(lambda patch: patch['id'], self.patches)
-        log("%s in review queue [%s]" % (pluralize('patch', len(self.patches)), ", ".join(patch_ids)))
-        return self.patches.pop(0)
+        self.log_progress(self._patches.patch_ids())
+        return self._patches.next()
 
     def should_proceed_with_work_item(self, patch):
         return (True, "Checking style for patch %s on bug %s." % (patch['id'], patch['bug_id']), patch['bug_id'])
diff --git a/WebKitTools/Scripts/modules/patchcollection.py b/WebKitTools/Scripts/modules/patchcollection.py
index fee5d24..2ab9310 100644
--- a/WebKitTools/Scripts/modules/patchcollection.py
+++ b/WebKitTools/Scripts/modules/patchcollection.py
@@ -33,23 +33,27 @@ class PatchCollection:
         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(self, patch):
+        self.add_patches([patch])
 
-    def add_all_from_bug(self, bug_id):
-        patches = self._bugs.fetch_patches_from_bug(bug_id)
+    def add_patches(self, patches):
         for patch in patches:
+            if not patch:
+                continue
             if self._filter and not self._filter(patch):
                 continue
             self._patches.append(patch)
 
+    def add_patches_from_bug(self, bug_id):
+        self.add_patches(self._bugs.fetch_patches_from_bug(bug_id))
+
     def next(self):
+        if not self._patches:
+            return None
         return self._patches.pop(0)
 
+    def patch_ids(self):
+        return map(lambda patch: patch['id'], self._patches)
+
     def __len__(self):
         return len(self._patches)
diff --git a/WebKitTools/Scripts/modules/patchcollection_unittest.py b/WebKitTools/Scripts/modules/patchcollection_unittest.py
index 86de81f..dd0b86e 100644
--- a/WebKitTools/Scripts/modules/patchcollection_unittest.py
+++ b/WebKitTools/Scripts/modules/patchcollection_unittest.py
@@ -60,12 +60,12 @@ class PatchCollectionTest(unittest.TestCase):
         bugs = MockBugzilla()
         patches = PatchCollection(bugs, filter=test_filter)
         self.assertEqual(len(patches), 0)
-        patches.add(42)
+        patches.add(bugs.fetch_attachment(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)
+        patches.add_patches_from_bug(38)
         # Notice that one of the patches gets filtered out.
         self.assertEqual(len(patches), 2)
         patch = patches.next()
@@ -79,10 +79,28 @@ class PatchCollectionTest(unittest.TestCase):
         bugs = MockEmptyBugzilla()
         patches = PatchCollection(bugs, filter=test_filter)
         self.assertEqual(len(patches), 0)
-        patches.add(42)
+        patches.add(bugs.fetch_attachment(42))
         self.assertEqual(len(patches), 0)
-        patches.add_all_from_bug(38)
+        patches.add_patches_from_bug(38)
         self.assertEqual(len(patches), 0)
 
+    def test_add_patches(self):
+        patches = PatchCollection(None)
+        self.assertEqual(patches.patch_ids(), [])
+        patches.add_patches([{'id': 42}, {'id': 74}])
+        self.assertEqual(len(patches), 2)
+        self.assertEqual(patches.patch_ids(), [42, 74])
+
+    def test_patch_ids(self):
+        patches = PatchCollection(None)
+        self.assertEqual(patches.patch_ids(), [])
+        patches.add({'id': 42})
+        patches.add({'id': 74})
+        self.assertEqual(patches.patch_ids(), [42, 74])
+
+    def test_empty(self):
+        patches = PatchCollection(None)
+        self.assertEqual(patches.next(), None)
+
 if __name__ == '__main__':
     unittest.main()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list