Changeset 51030 in webkit


Ignore:
Timestamp:
Nov 16, 2009 4:29:21 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-11-16 Adam Barth <abarth@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:
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51029 r51030  
     12009-11-16  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Move StyleQueue over to using PatchCollection
     6        https://bugs.webkit.org/show_bug.cgi?id=31544
     7
     8        That's what the class it's for.
     9
     10        * Scripts/bugzilla-tool:
     11        * Scripts/modules/patchcollection.py:
     12        * Scripts/modules/patchcollection_unittest.py:
     13
    1142009-11-16  Eric Seidel  <eric@webkit.org>
    215
  • trunk/WebKitTools/Scripts/bugzilla-tool

    r51029 r51030  
    4646from modules.comments import bug_comment_from_commit_text
    4747from modules.logging import error, log, tee
     48from modules.patchcollection import PatchCollection
    4849from modules.scm import CommitMessage, detect_scm_system, ScriptError, CheckoutNeedsUpdate
    4950from modules.buildbot import BuildBot
     
    752753        WebKitLandingScripts.run_and_throw_if_fail(bugzilla_tool_args)
    753754
     755    def log_progress(self, patch_ids):
     756        log("%s in %s [%s]" % (pluralize('patch', len(patch_ids)), self._name, ", ".join(patch_ids)))
     757
    754758    def execute(self, options, args, tool):
    755759        self.options = options
     
    798802class StyleQueue(AbstractQueue):
    799803    def __init__(self):
    800         self.patches = []
    801804        AbstractQueue.__init__(self, "style-queue")
    802805
     
    804807        return None # FIXME: A hack until we come up with a more generic status page.
    805808
     809    def begin_work_queue(self):
     810        AbstractQueue.begin_work_queue(self)
     811        self._patches = PatchCollection(self.tool.bugs)
     812        self._patches.add_patches(self.tool.bugs.fetch_patches_from_review_queue(limit=10))
     813
    806814    def next_work_item(self):
    807         if not self.patches:
    808             self.patches = self.tool.bugs.fetch_patches_from_review_queue(limit=10)
    809             if not self.patches:
    810                 return None
    811         patch_ids = map(lambda patch: patch['id'], self.patches)
    812         log("%s in review queue [%s]" % (pluralize('patch', len(self.patches)), ", ".join(patch_ids)))
    813         return self.patches.pop(0)
     815        self.log_progress(self._patches.patch_ids())
     816        return self._patches.next()
    814817
    815818    def should_proceed_with_work_item(self, patch):
  • trunk/WebKitTools/Scripts/modules/patchcollection.py

    r51026 r51030  
    3434        self._patches = []
    3535
    36     def add(self, patch_id):
    37         patch = self._bugs.fetch_attachment(patch_id)
    38         if not patch:
    39             return
    40         if self._filter and not self._filter(patch):
    41             return
    42         self._patches.append(patch)
     36    def add(self, patch):
     37        self.add_patches([patch])
    4338
    44     def add_all_from_bug(self, bug_id):
    45         patches = self._bugs.fetch_patches_from_bug(bug_id)
     39    def add_patches(self, patches):
    4640        for patch in patches:
     41            if not patch:
     42                continue
    4743            if self._filter and not self._filter(patch):
    4844                continue
    4945            self._patches.append(patch)
    5046
     47    def add_patches_from_bug(self, bug_id):
     48        self.add_patches(self._bugs.fetch_patches_from_bug(bug_id))
     49
    5150    def next(self):
     51        if not self._patches:
     52            return None
    5253        return self._patches.pop(0)
     54
     55    def patch_ids(self):
     56        return map(lambda patch: patch['id'], self._patches)
    5357
    5458    def __len__(self):
  • trunk/WebKitTools/Scripts/modules/patchcollection_unittest.py

    r51026 r51030  
    6161        patches = PatchCollection(bugs, filter=test_filter)
    6262        self.assertEqual(len(patches), 0)
    63         patches.add(42)
     63        patches.add(bugs.fetch_attachment(42))
    6464        self.assertEqual(len(patches), 1)
    6565        patch = patches.next()
    6666        self.assertEqual(patch, MockBugzilla.patch_1)
    6767        self.assertEqual(len(patches), 0)
    68         patches.add_all_from_bug(38)
     68        patches.add_patches_from_bug(38)
    6969        # Notice that one of the patches gets filtered out.
    7070        self.assertEqual(len(patches), 2)
     
    8080        patches = PatchCollection(bugs, filter=test_filter)
    8181        self.assertEqual(len(patches), 0)
    82         patches.add(42)
     82        patches.add(bugs.fetch_attachment(42))
    8383        self.assertEqual(len(patches), 0)
    84         patches.add_all_from_bug(38)
     84        patches.add_patches_from_bug(38)
    8585        self.assertEqual(len(patches), 0)
     86
     87    def test_add_patches(self):
     88        patches = PatchCollection(None)
     89        self.assertEqual(patches.patch_ids(), [])
     90        patches.add_patches([{'id': 42}, {'id': 74}])
     91        self.assertEqual(len(patches), 2)
     92        self.assertEqual(patches.patch_ids(), [42, 74])
     93
     94    def test_patch_ids(self):
     95        patches = PatchCollection(None)
     96        self.assertEqual(patches.patch_ids(), [])
     97        patches.add({'id': 42})
     98        patches.add({'id': 74})
     99        self.assertEqual(patches.patch_ids(), [42, 74])
     100
     101    def test_empty(self):
     102        patches = PatchCollection(None)
     103        self.assertEqual(patches.next(), None)
    86104
    87105if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.