• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright (c) 2009, Google Inc. All rights reserved.
3# Copyright (c) 2009 Apple Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met:
8#
9#     * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11#     * Redistributions in binary form must reproduce the above
12# copyright notice, this list of conditions and the following disclaimer
13# in the documentation and/or other materials provided with the
14# distribution.
15#     * Neither the name of Google Inc. nor the names of its
16# contributors may be used to endorse or promote products derived from
17# this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31
32from optparse import make_option
33
34from webkitpy.buildbot import BuildBot
35from webkitpy.committers import CommitterList
36from webkitpy.webkit_logging import log
37from webkitpy.multicommandtool import AbstractDeclarativeCommand
38
39
40class BugsToCommit(AbstractDeclarativeCommand):
41    name = "bugs-to-commit"
42    help_text = "List bugs in the commit-queue"
43
44    def execute(self, options, args, tool):
45        # FIXME: This command is poorly named.  It's fetching the commit-queue list here.  The name implies it's fetching pending-commit (all r+'d patches).
46        bug_ids = tool.bugs.queries.fetch_bug_ids_from_commit_queue()
47        for bug_id in bug_ids:
48            print "%s" % bug_id
49
50
51class PatchesInCommitQueue(AbstractDeclarativeCommand):
52    name = "patches-in-commit-queue"
53    help_text = "List patches in the commit-queue"
54
55    def execute(self, options, args, tool):
56        patches = tool.bugs.queries.fetch_patches_from_commit_queue()
57        log("Patches in commit queue:")
58        for patch in patches:
59            print patch.url()
60
61
62class PatchesToCommitQueue(AbstractDeclarativeCommand):
63    name = "patches-to-commit-queue"
64    help_text = "Patches which should be added to the commit queue"
65    def __init__(self):
66        options = [
67            make_option("--bugs", action="store_true", dest="bugs", help="Output bug links instead of patch links"),
68        ]
69        AbstractDeclarativeCommand.__init__(self, options=options)
70
71    @staticmethod
72    def _needs_commit_queue(patch):
73        if patch.commit_queue() == "+": # If it's already cq+, ignore the patch.
74            log("%s already has cq=%s" % (patch.id(), patch.commit_queue()))
75            return False
76
77        # We only need to worry about patches from contributers who are not yet committers.
78        committer_record = CommitterList().committer_by_email(patch.attacher_email())
79        if committer_record:
80            log("%s committer = %s" % (patch.id(), committer_record))
81        return not committer_record
82
83    def execute(self, options, args, tool):
84        patches = tool.bugs.queries.fetch_patches_from_pending_commit_list()
85        patches_needing_cq = filter(self._needs_commit_queue, patches)
86        if options.bugs:
87            bugs_needing_cq = map(lambda patch: patch.bug_id(), patches_needing_cq)
88            bugs_needing_cq = sorted(set(bugs_needing_cq))
89            for bug_id in bugs_needing_cq:
90                print "%s" % tool.bugs.bug_url_for_bug_id(bug_id)
91        else:
92            for patch in patches_needing_cq:
93                print "%s" % tool.bugs.attachment_url_for_id(patch.id(), action="edit")
94
95
96class PatchesToReview(AbstractDeclarativeCommand):
97    name = "patches-to-review"
98    help_text = "List patches that are pending review"
99
100    def execute(self, options, args, tool):
101        patch_ids = tool.bugs.queries.fetch_attachment_ids_from_review_queue()
102        log("Patches pending review:")
103        for patch_id in patch_ids:
104            print patch_id
105
106
107class TreeStatus(AbstractDeclarativeCommand):
108    name = "tree-status"
109    help_text = "Print the status of the %s buildbots" % BuildBot.default_host
110    long_help = """Fetches build status from http://build.webkit.org/one_box_per_builder
111and displayes the status of each builder."""
112
113    def execute(self, options, args, tool):
114        for builder in tool.buildbot.builder_statuses():
115            status_string = "ok" if builder["is_green"] else "FAIL"
116            print "%s : %s" % (status_string.ljust(4), builder["name"])
117