OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 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 from optparse import make_option | |
30 | |
31 from webkitpy.common.net.omahaproxy import OmahaProxy | |
32 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand | |
33 | |
34 import re | |
35 | |
36 | |
37 class ChromeChannels(AbstractDeclarativeCommand): | |
38 name = "chrome-channels" | |
39 help_text = "List which chrome channels include the patches in bugs returned
by QUERY." | |
40 argument_names = "QUERY" | |
41 long_help = """Retrieves the current list of Chrome releases from omahaproxy
.appspot.com, | |
42 and then runs the bugzilla quicksearch QUERY on bugs.bugzilla.org. For each bug | |
43 returned by query, a single svn commit is deduced, and a short summary is | |
44 printed of each bug listing which Chrome channels contain each bugs associated | |
45 commit. | |
46 | |
47 The QUERY can be as simple as a bug number, or a comma delimited list of bug | |
48 numbers. See https://bugzilla.mozilla.org/page.cgi?id=quicksearch.html for full | |
49 documentation on the query format.""" | |
50 | |
51 chrome_channels = OmahaProxy.chrome_channels | |
52 commited_pattern = "Committed r([0-9]+): <http://trac.webkit.org/changeset/\
\1>" | |
53 rollout_pattern = "Rolled out in http://trac.webkit.org/changeset/[0-9]+" | |
54 | |
55 def __init__(self): | |
56 AbstractDeclarativeCommand.__init__(self) | |
57 self._re_committed = re.compile(self.commited_pattern) | |
58 self._re_rollout = re.compile(self.rollout_pattern) | |
59 self._omahaproxy = OmahaProxy() | |
60 | |
61 def _channels_for_bug(self, revisions, bug): | |
62 comments = bug.comments() | |
63 commit = None | |
64 | |
65 # Scan the comments, looking for a sane list of commits and rollbacks. | |
66 for comment in comments: | |
67 commit_match = self._re_committed.search(comment['text']) | |
68 if commit_match: | |
69 if commit: | |
70 return "%5s %s\n... has too confusing a commit history to pa
rse, skipping\n" % (bug.id(), bug.title()) | |
71 commit = int(commit_match.group(1)) | |
72 if self._re_rollout.search(comment['text']): | |
73 commit = None | |
74 if not commit: | |
75 return "%5s %s\n... does not appear to have an associated commit.\n"
% (bug.id(), bug.title()) | |
76 | |
77 # We now know that we have a commit, so gather up the list of platforms | |
78 # by channel, then print. | |
79 by_channel = {} | |
80 for revision in revisions: | |
81 channel = revision['channel'] | |
82 if revision['commit'] < commit: | |
83 continue | |
84 if not channel in by_channel: | |
85 by_channel[revision['channel']] = " %6s:" % channel | |
86 by_channel[channel] += " %s," % revision['platform'] | |
87 if not by_channel: | |
88 return "%5s %s (r%d)\n... not yet released in any Chrome channels.\n
" % (bug.id(), bug.title(), commit) | |
89 retval = "%5s %s (r%d)\n" % (bug.id(), bug.title(), commit) | |
90 for channel in self.chrome_channels: | |
91 if channel in by_channel: | |
92 retval += by_channel[channel][:-1] | |
93 retval += "\n" | |
94 return retval | |
95 | |
96 def execute(self, options, args, tool): | |
97 search_string = args[0] | |
98 revisions = self._omahaproxy.get_revisions() | |
99 bugs = tool.bugs.queries.fetch_bugs_matching_quicksearch(search_string) | |
100 if not bugs: | |
101 print "No bugs found matching '%s'" % search_string | |
102 return | |
103 for bug in bugs: | |
104 print self._channels_for_bug(revisions, bug), | |
OLD | NEW |