Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: Tools/Scripts/webkitpy/tool/bot/feeders.py

Issue 15416008: Remove a bunch of dead code from webkitpy (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import logging
30
31 from webkitpy.common.config.committervalidator import CommitterValidator
32 from webkitpy.tool.grammar import pluralize
33
34 _log = logging.getLogger(__name__)
35
36
37 class AbstractFeeder(object):
38 def __init__(self, tool):
39 self._tool = tool
40
41 def feed(self):
42 raise NotImplementedError("subclasses must implement")
43
44
45 class CommitQueueFeeder(AbstractFeeder):
46 queue_name = "commit-queue"
47
48 def __init__(self, tool):
49 AbstractFeeder.__init__(self, tool)
50 self.committer_validator = CommitterValidator(self._tool)
51
52 def _update_work_items(self, item_ids):
53 # FIXME: This is the last use of update_work_items, the commit-queue
54 # should move to feeding patches one at a time like the EWS does.
55 self._tool.status_server.update_work_items(self.queue_name, item_ids)
56 _log.info("Feeding %s items %s" % (self.queue_name, item_ids))
57
58 def feed(self):
59 patches = self._validate_patches()
60 patches = self._patches_with_acceptable_review_flag(patches)
61 patches = sorted(patches, self._patch_cmp)
62 patch_ids = [patch.id() for patch in patches]
63 self._update_work_items(patch_ids)
64
65 def _patches_for_bug(self, bug_id):
66 return self._tool.bugs.fetch_bug(bug_id).commit_queued_patches(include_i nvalid=True)
67
68 # Filters out patches with r? or r-, only r+ or no review are OK to land.
69 def _patches_with_acceptable_review_flag(self, patches):
70 return [patch for patch in patches if patch.review() in [None, '+']]
71
72 def _validate_patches(self):
73 # Not using BugzillaQueries.fetch_patches_from_commit_queue() so we can reject patches with invalid committers/reviewers.
74 bug_ids = self._tool.bugs.queries.fetch_bug_ids_from_commit_queue()
75 all_patches = sum([self._patches_for_bug(bug_id) for bug_id in bug_ids], [])
76 return self.committer_validator.patches_after_rejecting_invalid_commiter s_and_reviewers(all_patches)
77
78 def _patch_cmp(self, a, b):
79 # Sort first by is_rollout, then by attach_date.
80 # Reversing the order so that is_rollout is first.
81 rollout_cmp = cmp(b.is_rollout(), a.is_rollout())
82 if rollout_cmp != 0:
83 return rollout_cmp
84 return cmp(a.attach_date(), b.attach_date())
85
86
87 class EWSFeeder(AbstractFeeder):
88 def __init__(self, tool):
89 self._ids_sent_to_server = set()
90 AbstractFeeder.__init__(self, tool)
91
92 def feed(self):
93 ids_needing_review = set(self._tool.bugs.queries.fetch_attachment_ids_fr om_review_queue())
94 new_ids = ids_needing_review.difference(self._ids_sent_to_server)
95 _log.info("Feeding EWS (%s, %s new)" % (pluralize("r? patch", len(ids_ne eding_review)), len(new_ids)))
96 for attachment_id in new_ids: # Order doesn't really matter for the EWS .
97 self._tool.status_server.submit_to_ews(attachment_id)
98 self._ids_sent_to_server.add(attachment_id)
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/tool/bot/expectedfailures_unittest.py ('k') | Tools/Scripts/webkitpy/tool/bot/feeders_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698