Index: Tools/Scripts/webkitpy/tool/commands/queries.py |
diff --git a/Tools/Scripts/webkitpy/tool/commands/queries.py b/Tools/Scripts/webkitpy/tool/commands/queries.py |
index eea23b4bbc99d3d428a1a60bb796fab07c56a4a0..74f7f876ad66b52aa4d44292cf349b5d71c8f64c 100644 |
--- a/Tools/Scripts/webkitpy/tool/commands/queries.py |
+++ b/Tools/Scripts/webkitpy/tool/commands/queries.py |
@@ -37,8 +37,6 @@ from optparse import make_option |
from webkitpy.tool import steps |
-from webkitpy.common.checkout.commitinfo import CommitInfo |
-from webkitpy.common.config.committers import CommitterList |
import webkitpy.common.config.urls as config_urls |
from webkitpy.common.net.buildbot import BuildBot |
from webkitpy.common.net.regressionwindow import RegressionWindow |
@@ -53,161 +51,6 @@ from webkitpy.layout_tests.port import platform_options, configuration_options |
_log = logging.getLogger(__name__) |
-class BugsToCommit(AbstractDeclarativeCommand): |
- name = "bugs-to-commit" |
- help_text = "List bugs in the commit-queue" |
- |
- def execute(self, options, args, tool): |
- # 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). |
- bug_ids = tool.bugs.queries.fetch_bug_ids_from_commit_queue() |
- for bug_id in bug_ids: |
- print "%s" % bug_id |
- |
- |
-class PatchesInCommitQueue(AbstractDeclarativeCommand): |
- name = "patches-in-commit-queue" |
- help_text = "List patches in the commit-queue" |
- |
- def execute(self, options, args, tool): |
- patches = tool.bugs.queries.fetch_patches_from_commit_queue() |
- _log.info("Patches in commit queue:") |
- for patch in patches: |
- print patch.url() |
- |
- |
-class PatchesToCommitQueue(AbstractDeclarativeCommand): |
- name = "patches-to-commit-queue" |
- help_text = "Patches which should be added to the commit queue" |
- def __init__(self): |
- options = [ |
- make_option("--bugs", action="store_true", dest="bugs", help="Output bug links instead of patch links"), |
- ] |
- AbstractDeclarativeCommand.__init__(self, options=options) |
- |
- @staticmethod |
- def _needs_commit_queue(patch): |
- if patch.commit_queue() == "+": # If it's already cq+, ignore the patch. |
- _log.info("%s already has cq=%s" % (patch.id(), patch.commit_queue())) |
- return False |
- |
- # We only need to worry about patches from contributers who are not yet committers. |
- committer_record = CommitterList().committer_by_email(patch.attacher_email()) |
- if committer_record: |
- _log.info("%s committer = %s" % (patch.id(), committer_record)) |
- return not committer_record |
- |
- def execute(self, options, args, tool): |
- patches = tool.bugs.queries.fetch_patches_from_pending_commit_list() |
- patches_needing_cq = filter(self._needs_commit_queue, patches) |
- if options.bugs: |
- bugs_needing_cq = map(lambda patch: patch.bug_id(), patches_needing_cq) |
- bugs_needing_cq = sorted(set(bugs_needing_cq)) |
- for bug_id in bugs_needing_cq: |
- print "%s" % tool.bugs.bug_url_for_bug_id(bug_id) |
- else: |
- for patch in patches_needing_cq: |
- print "%s" % tool.bugs.attachment_url_for_id(patch.id(), action="edit") |
- |
- |
-class PatchesToReview(AbstractDeclarativeCommand): |
- name = "patches-to-review" |
- help_text = "List bugs which have attachments pending review" |
- |
- def __init__(self): |
- options = [ |
- make_option("--all", action="store_true", |
- help="Show all bugs regardless of who is on CC (it might take a while)"), |
- make_option("--include-cq-denied", action="store_true", |
- help="By default, r? patches with cq- are omitted unless this option is set"), |
- make_option("--cc-email", |
- help="Specifies the email on the CC field (defaults to your bugzilla login email)"), |
- ] |
- AbstractDeclarativeCommand.__init__(self, options=options) |
- |
- def _print_report(self, report, cc_email, print_all): |
- if print_all: |
- print "Bugs with attachments pending review:" |
- else: |
- print "Bugs with attachments pending review that has %s in the CC list:" % cc_email |
- |
- print "http://webkit.org/b/bugid Description (age in days)" |
- for row in report: |
- print "%s (%d)" % (row[1], row[0]) |
- |
- print "Total: %d" % len(report) |
- |
- def _generate_report(self, bugs, include_cq_denied): |
- report = [] |
- |
- for bug in bugs: |
- patch = bug.unreviewed_patches()[-1] |
- |
- if not include_cq_denied and patch.commit_queue() == "-": |
- continue |
- |
- age_in_days = (datetime.today() - patch.attach_date()).days |
- report.append((age_in_days, "http://webkit.org/b/%-7s %s" % (bug.id(), bug.title()))) |
- |
- report.sort() |
- return report |
- |
- def execute(self, options, args, tool): |
- tool.bugs.authenticate() |
- |
- cc_email = options.cc_email |
- if not cc_email and not options.all: |
- cc_email = tool.bugs.username |
- |
- bugs = tool.bugs.queries.fetch_bugs_from_review_queue(cc_email=cc_email) |
- report = self._generate_report(bugs, options.include_cq_denied) |
- self._print_report(report, cc_email, options.all) |
- |
-class WhatBroke(AbstractDeclarativeCommand): |
- name = "what-broke" |
- help_text = "Print failing buildbots (%s) and what revisions broke them" % config_urls.buildbot_url |
- |
- def _print_builder_line(self, builder_name, max_name_width, status_message): |
- print "%s : %s" % (builder_name.ljust(max_name_width), status_message) |
- |
- def _print_blame_information_for_builder(self, builder_status, name_width, avoid_flakey_tests=True): |
- builder = self._tool.buildbot.builder_with_name(builder_status["name"]) |
- red_build = builder.build(builder_status["build_number"]) |
- regression_window = builder.find_regression_window(red_build) |
- if not regression_window.failing_build(): |
- self._print_builder_line(builder.name(), name_width, "FAIL (error loading build information)") |
- return |
- if not regression_window.build_before_failure(): |
- self._print_builder_line(builder.name(), name_width, "FAIL (blame-list: sometime before %s?)" % regression_window.failing_build().revision()) |
- return |
- |
- revisions = regression_window.revisions() |
- first_failure_message = "" |
- if (regression_window.failing_build() == builder.build(builder_status["build_number"])): |
- first_failure_message = " FIRST FAILURE, possibly a flaky test" |
- self._print_builder_line(builder.name(), name_width, "FAIL (blame-list: %s%s)" % (revisions, first_failure_message)) |
- for revision in revisions: |
- commit_info = self._tool.checkout().commit_info_for_revision(revision) |
- if commit_info: |
- print commit_info.blame_string(self._tool.bugs) |
- else: |
- print "FAILED to fetch CommitInfo for r%s, likely missing ChangeLog" % revision |
- |
- def execute(self, options, args, tool): |
- builder_statuses = tool.buildbot.builder_statuses() |
- longest_builder_name = max(map(len, map(lambda builder: builder["name"], builder_statuses))) |
- failing_builders = 0 |
- for builder_status in builder_statuses: |
- # If the builder is green, print OK, exit. |
- if builder_status["is_green"]: |
- continue |
- self._print_blame_information_for_builder(builder_status, name_width=longest_builder_name) |
- failing_builders += 1 |
- if failing_builders: |
- print "%s of %s are failing" % (failing_builders, pluralize("builder", len(builder_statuses))) |
- else: |
- print "All builders are passing!" |
- |
- |
class ResultsFor(AbstractDeclarativeCommand): |
name = "results-for" |
help_text = "Print a list of failures for the passed revision from bots on %s" % config_urls.buildbot_url |