Commit 17059c3e authored by abarth@webkit.org's avatar abarth@webkit.org
Browse files

2010-09-20 Adam Barth <abarth@webkit.org>

        Reviewed by Eric Seidel.

        The tool member variable should be called _tool
        https://bugs.webkit.org/show_bug.cgi?id=46160

        Created by find-and-replace.

        * Scripts/webkitpy/tool/commands/download.py:
        * Scripts/webkitpy/tool/commands/openbugs.py:
        * Scripts/webkitpy/tool/commands/queries.py:
        * Scripts/webkitpy/tool/commands/queues.py:
        * Scripts/webkitpy/tool/commands/queues_unittest.py:
        * Scripts/webkitpy/tool/commands/rebaseline.py:
        * Scripts/webkitpy/tool/commands/sheriffbot.py:
        * Scripts/webkitpy/tool/commands/upload.py:
        * Scripts/webkitpy/tool/multicommandtool.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f3b40934
2010-09-20 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
The tool member variable should be called _tool
https://bugs.webkit.org/show_bug.cgi?id=46160
Created by find-and-replace.
* Scripts/webkitpy/tool/commands/download.py:
* Scripts/webkitpy/tool/commands/openbugs.py:
* Scripts/webkitpy/tool/commands/queries.py:
* Scripts/webkitpy/tool/commands/queues.py:
* Scripts/webkitpy/tool/commands/queues_unittest.py:
* Scripts/webkitpy/tool/commands/rebaseline.py:
* Scripts/webkitpy/tool/commands/sheriffbot.py:
* Scripts/webkitpy/tool/commands/upload.py:
* Scripts/webkitpy/tool/multicommandtool.py:
2010-09-20 Adam Barth <abarth@webkit.org>
I ran the tests before landing but ignored the fact that they failed. :(
......
......@@ -289,7 +289,7 @@ class AbstractRolloutPrepCommand(AbstractSequencedCommand):
argument_names = "REVISION REASON"
def _commit_info(self, revision):
commit_info = self.tool.checkout().commit_info_for_revision(revision)
commit_info = self._tool.checkout().commit_info_for_revision(revision)
if commit_info and commit_info.bug_id():
# Note: Don't print a bug URL here because it will confuse the
# SheriffBot because the SheriffBot just greps the output
......
......@@ -41,8 +41,8 @@ class OpenBugs(AbstractDeclarativeCommand):
def _open_bugs(self, bug_ids):
for bug_id in bug_ids:
bug_url = self.tool.bugs.bug_url_for_bug_id(bug_id)
self.tool.user.open_url(bug_url)
bug_url = self._tool.bugs.bug_url_for_bug_id(bug_id)
self._tool.user.open_url(bug_url)
# _find_bugs_in_string mostly exists for easy unit testing.
def _find_bugs_in_string(self, string):
......
......@@ -112,7 +112,7 @@ class LastGreenRevision(AbstractDeclarativeCommand):
help_text = "Prints the last known good revision"
def execute(self, options, args, tool):
print self.tool.buildbot.last_green_revision()
print self._tool.buildbot.last_green_revision()
class WhatBroke(AbstractDeclarativeCommand):
......@@ -125,7 +125,7 @@ class WhatBroke(AbstractDeclarativeCommand):
# FIXME: This is slightly different from Builder.suspect_revisions_for_green_to_red_transition
# due to needing to detect the "hit the limit" case an print a special 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"])
builder = self._tool.buildbot.builder_with_name(builder_status["name"])
red_build = builder.build(builder_status["build_number"])
(last_green_build, first_red_build) = builder.find_failure_transition(red_build)
if not first_red_build:
......@@ -142,9 +142,9 @@ class WhatBroke(AbstractDeclarativeCommand):
first_failure_message = " FIRST FAILURE, possibly a flaky test"
self._print_builder_line(builder.name(), name_width, "FAIL (blame-list: %s%s)" % (suspect_revisions, first_failure_message))
for revision in suspect_revisions:
commit_info = self.tool.checkout().commit_info_for_revision(revision)
commit_info = self._tool.checkout().commit_info_for_revision(revision)
if commit_info:
print commit_info.blame_string(self.tool.bugs)
print commit_info.blame_string(self._tool.bugs)
else:
print "FAILED to fetch CommitInfo for r%s, likely missing ChangeLog" % revision
......@@ -169,7 +169,7 @@ class WhoBrokeIt(AbstractDeclarativeCommand):
help_text = "Print a list of revisions causing failures on %s" % BuildBot.default_host
def execute(self, options, args, tool):
for revision, builders in self.tool.buildbot.revisions_causing_failures(False).items():
for revision, builders in self._tool.buildbot.revisions_causing_failures(False).items():
print "r%s appears to have broken %s" % (revision, [builder.name() for builder in builders])
......@@ -188,7 +188,7 @@ class ResultsFor(AbstractDeclarativeCommand):
print " %s" % filename
def execute(self, options, args, tool):
builders = self.tool.buildbot.builders()
builders = self._tool.buildbot.builders()
for builder in builders:
print "%s:" % builder.name()
build = builder.build_for_revision(args[0], allow_failed_lookups=True)
......@@ -204,9 +204,9 @@ class FailureReason(AbstractDeclarativeCommand):
print "SUCCESS: Build %s (r%s) was the first to show failures: %s" % (red_build._number, red_build.revision(), failing_tests)
print "Suspect revisions:"
for revision in suspect_revisions:
commit_info = self.tool.checkout().commit_info_for_revision(revision)
commit_info = self._tool.checkout().commit_info_for_revision(revision)
if commit_info:
print commit_info.blame_string(self.tool.bugs)
print commit_info.blame_string(self._tool.bugs)
else:
print "FAILED to fetch CommitInfo for r%s, likely missing ChangeLog" % revision
......@@ -255,7 +255,7 @@ class FailureReason(AbstractDeclarativeCommand):
return 0
def _builder_to_explain(self):
builder_statuses = self.tool.buildbot.builder_statuses()
builder_statuses = self._tool.buildbot.builder_statuses()
red_statuses = [status for status in builder_statuses if not status["is_green"]]
print "%s failing" % (pluralize("builder", len(red_statuses)))
builder_choices = [status["name"] for status in red_statuses]
......@@ -264,11 +264,11 @@ class FailureReason(AbstractDeclarativeCommand):
# FIXME: prompt_with_list should really take a set of objects and a set of names and then return the object.
for status in red_statuses:
if status["name"] == chosen_name:
return (self.tool.buildbot.builder_with_name(chosen_name), status["built_revision"])
return (self._tool.buildbot.builder_with_name(chosen_name), status["built_revision"])
def execute(self, options, args, tool):
(builder, latest_revision) = self._builder_to_explain()
start_revision = self.tool.user.prompt("Revision to walk backwards from? [%s] " % latest_revision) or latest_revision
start_revision = self._tool.user.prompt("Revision to walk backwards from? [%s] " % latest_revision) or latest_revision
if not start_revision:
print "Revision required."
return 1
......
......@@ -64,20 +64,20 @@ class AbstractQueue(Command, QueueEngineDelegate):
def _cc_watchers(self, bug_id):
try:
self.tool.bugs.add_cc_to_bug(bug_id, self.watchers)
self._tool.bugs.add_cc_to_bug(bug_id, self.watchers)
except Exception, e:
traceback.print_exc()
log("Failed to CC watchers.")
def run_webkit_patch(self, args):
webkit_patch_args = [self.tool.path()]
webkit_patch_args = [self._tool.path()]
# FIXME: This is a hack, we should have a more general way to pass global options.
# FIXME: We must always pass global options and their value in one argument
# because our global option code looks for the first argument which does
# not begin with "-" and assumes that is the command name.
webkit_patch_args += ["--status-host=%s" % self.tool.status_server.host]
webkit_patch_args += ["--status-host=%s" % self._tool.status_server.host]
webkit_patch_args.extend(args)
return self.tool.executive.run_and_throw_if_fail(webkit_patch_args)
return self._tool.executive.run_and_throw_if_fail(webkit_patch_args)
def _log_directory(self):
return "%s-logs" % self.name
......@@ -91,16 +91,16 @@ class AbstractQueue(Command, QueueEngineDelegate):
raise NotImplementedError, "subclasses must implement"
def begin_work_queue(self):
log("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self.tool.scm().checkout_root))
log("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self._tool.scm().checkout_root))
if self.options.confirm:
response = self.tool.user.prompt("Are you sure? Type \"yes\" to continue: ")
response = self._tool.user.prompt("Are you sure? Type \"yes\" to continue: ")
if (response != "yes"):
error("User declined.")
log("Running WebKit %s." % self.name)
self.tool.status_server.update_status(self.name, "Starting Queue")
self._tool.status_server.update_status(self.name, "Starting Queue")
def stop_work_queue(self, reason):
self.tool.status_server.update_status(self.name, "Stopping Queue, reason: %s" % reason)
self._tool.status_server.update_status(self.name, "Stopping Queue, reason: %s" % reason)
def should_continue_work_queue(self):
self._iteration_count += 1
......@@ -122,8 +122,8 @@ class AbstractQueue(Command, QueueEngineDelegate):
def execute(self, options, args, tool, engine=QueueEngine):
self.options = options # FIXME: This code is wrong. Command.options is a list, this assumes an Options element!
self.tool = tool # FIXME: This code is wrong too! Command.bind_to_tool handles this!
return engine(self.name, self, self.tool.wakeup_event).run()
self._tool = tool # FIXME: This code is wrong too! Command.bind_to_tool handles this!
return engine(self.name, self, self._tool.wakeup_event).run()
@classmethod
def _log_from_script_error_for_upload(cls, script_error, output_limit=None):
......@@ -156,7 +156,7 @@ class FeederQueue(AbstractQueue):
def begin_work_queue(self):
AbstractQueue.begin_work_queue(self)
self.feeders = [
CommitQueueFeeder(self.tool),
CommitQueueFeeder(self._tool),
]
def next_work_item(self):
......@@ -191,10 +191,10 @@ class FeederQueue(AbstractQueue):
class AbstractPatchQueue(AbstractQueue):
def _update_status(self, message, patch=None, results_file=None):
self.tool.status_server.update_status(self.name, message, patch, results_file)
self._tool.status_server.update_status(self.name, message, patch, results_file)
def _fetch_next_work_item(self):
return self.tool.status_server.next_work_item(self.name)
return self._tool.status_server.next_work_item(self.name)
def _did_pass(self, patch):
self._update_status(self._pass_status, patch)
......@@ -217,13 +217,13 @@ class CommitQueue(AbstractPatchQueue, StepSequenceErrorHandler):
def begin_work_queue(self):
AbstractPatchQueue.begin_work_queue(self)
self.committer_validator = CommitterValidator(self.tool.bugs)
self.committer_validator = CommitterValidator(self._tool.bugs)
def next_work_item(self):
patch_id = self._fetch_next_work_item()
if not patch_id:
return None
return self.tool.bugs.fetch_attachment(patch_id)
return self._tool.bugs.fetch_attachment(patch_id)
def _can_build_and_test_without_patch(self):
try:
......@@ -285,7 +285,7 @@ class CommitQueue(AbstractPatchQueue, StepSequenceErrorHandler):
def _revalidate_patch(self, patch):
# Bugs might get closed, or patches might be obsoleted or r-'d while the
# commit-queue is processing. Do one last minute check before landing.
patch = self.tool.bugs.fetch_attachment(patch.id())
patch = self._tool.bugs.fetch_attachment(patch.id())
if patch.is_obsolete():
return None
if patch.bug().is_closed():
......@@ -377,7 +377,7 @@ class RietveldUploadQueue(AbstractPatchQueue, StepSequenceErrorHandler):
# AbstractPatchQueue methods
def next_work_item(self):
patch_id = self.tool.bugs.queries.fetch_first_patch_from_rietveld_queue()
patch_id = self._tool.bugs.queries.fetch_first_patch_from_rietveld_queue()
if patch_id:
return patch_id
self._update_status("Empty queue")
......@@ -402,7 +402,7 @@ class RietveldUploadQueue(AbstractPatchQueue, StepSequenceErrorHandler):
def handle_unexpected_error(self, patch, message):
log(message)
self._reject_patch(self.tool, patch.id())
self._reject_patch(self._tool, patch.id())
# StepSequenceErrorHandler methods
......@@ -426,10 +426,10 @@ class AbstractReviewQueue(AbstractPatchQueue, PersistentPatchCollectionDelegate,
return self.name
def fetch_potential_patch_ids(self):
return self.tool.bugs.queries.fetch_attachment_ids_from_review_queue()
return self._tool.bugs.queries.fetch_attachment_ids_from_review_queue()
def status_server(self):
return self.tool.status_server
return self._tool.status_server
def is_terminal_status(self, status):
return status == "Pass" or status == "Fail" or status.startswith("Error:")
......@@ -443,7 +443,7 @@ class AbstractReviewQueue(AbstractPatchQueue, PersistentPatchCollectionDelegate,
def next_work_item(self):
patch_id = self._patches.next()
if patch_id:
return self.tool.bugs.fetch_attachment(patch_id)
return self._tool.bugs.fetch_attachment(patch_id)
def should_proceed_with_work_item(self, patch):
raise NotImplementedError, "subclasses must implement"
......
......@@ -187,7 +187,7 @@ class SecondThoughtsCommitQueue(CommitQueue):
"attacher_email": "Contributer1",
}
patch = Attachment(attachment_dictionary, None)
self.tool.bugs.set_override_patch(patch)
self._tool.bugs.set_override_patch(patch)
return True
......
......@@ -72,15 +72,15 @@ class Rebaseline(AbstractDeclarativeCommand):
# FIXME: This should share more code with FailureReason._builder_to_explain
def _builder_to_pull_from(self):
builder_statuses = self.tool.buildbot.builder_statuses()
builder_statuses = self._tool.buildbot.builder_statuses()
red_statuses = [status for status in builder_statuses if not status["is_green"]]
print "%s failing" % (pluralize("builder", len(red_statuses)))
builder_choices = [status["name"] for status in red_statuses]
chosen_name = self.tool.user.prompt_with_list("Which builder to pull results from:", builder_choices)
chosen_name = self._tool.user.prompt_with_list("Which builder to pull results from:", builder_choices)
# FIXME: prompt_with_list should really take a set of objects and a set of names and then return the object.
for status in red_statuses:
if status["name"] == chosen_name:
return (self.tool.buildbot.builder_with_name(chosen_name), status["build_number"])
return (self._tool.buildbot.builder_with_name(chosen_name), status["build_number"])
def _replace_expectation_with_remote_result(self, local_file, remote_file):
(downloaded_file, headers) = urllib.urlretrieve(remote_file)
......
......@@ -50,9 +50,9 @@ class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
def begin_work_queue(self):
AbstractQueue.begin_work_queue(self)
self._sheriff = Sheriff(self.tool, self)
self._irc_bot = SheriffIRCBot(self.tool, self._sheriff)
self.tool.ensure_irc_connected(self._irc_bot.irc_delegate())
self._sheriff = Sheriff(self._tool, self)
self._irc_bot = SheriffIRCBot(self._tool, self._sheriff)
self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
def work_item_log_path(self, new_failures):
return os.path.join("%s-logs" % self.name, "%s.log" % new_failures.keys()[0])
......@@ -86,12 +86,12 @@ class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
self._update()
# We do one read from buildbot to ensure a consistent view.
revisions_causing_failures = self.tool.buildbot.revisions_causing_failures()
revisions_causing_failures = self._tool.buildbot.revisions_causing_failures()
# Similarly, we read once from our the status_server.
old_failing_svn_revisions = []
for svn_revision in revisions_causing_failures.keys():
if self.tool.status_server.svn_revision(svn_revision):
if self._tool.status_server.svn_revision(svn_revision):
old_failing_svn_revisions.append(svn_revision)
new_failures = self._new_failures(revisions_causing_failures,
......@@ -108,7 +108,7 @@ class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
blame_list = new_failures.keys()
for svn_revision, builders in new_failures.items():
try:
commit_info = self.tool.checkout().commit_info_for_revision(svn_revision)
commit_info = self._tool.checkout().commit_info_for_revision(svn_revision)
if not commit_info:
print "FAILED to fetch CommitInfo for r%s, likely missing ChangeLog" % revision
continue
......@@ -120,7 +120,7 @@ class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
builders)
finally:
for builder in builders:
self.tool.status_server.update_svn_revision(svn_revision,
self._tool.status_server.update_svn_revision(svn_revision,
builder.name())
return True
......
......@@ -82,14 +82,14 @@ class CleanPendingCommit(AbstractDeclarativeCommand):
def execute(self, options, args, tool):
committers = CommitterList()
for bug_id in tool.bugs.queries.fetch_bug_ids_from_pending_commit_list():
bug = self.tool.bugs.fetch_bug(bug_id)
bug = self._tool.bugs.fetch_bug(bug_id)
patches = bug.patches(include_obsolete=True)
for patch in patches:
flags_to_clear = self._flags_to_clear_on_patch(patch)
if not flags_to_clear:
continue
message = "Cleared %s from obsolete attachment %s so that this bug does not appear in http://webkit.org/pending-commit." % (flags_to_clear, patch.id())
self.tool.bugs.obsolete_attachment(patch.id(), message)
self._tool.bugs.obsolete_attachment(patch.id(), message)
class AssignToCommitter(AbstractDeclarativeCommand):
......@@ -104,7 +104,7 @@ class AssignToCommitter(AbstractDeclarativeCommand):
def _assign_bug_to_last_patch_attacher(self, bug_id):
committers = CommitterList()
bug = self.tool.bugs.fetch_bug(bug_id)
bug = self._tool.bugs.fetch_bug(bug_id)
if not bug.is_unassigned():
assigned_to_email = bug.assigned_to_email()
log("Bug %s is already assigned to %s (%s)." % (bug_id, assigned_to_email, committers.committer_by_email(assigned_to_email)))
......@@ -128,7 +128,7 @@ class AssignToCommitter(AbstractDeclarativeCommand):
return
reassign_message = "Attachment %s was posted by a committer and has review+, assigning to %s for commit." % (latest_patch.id(), committer.full_name)
self.tool.bugs.reassign_bug(bug_id, committer.bugzilla_email(), reassign_message)
self._tool.bugs.reassign_bug(bug_id, committer.bugzilla_email(), reassign_message)
def execute(self, options, args, tool):
for bug_id in tool.bugs.queries.fetch_bug_ids_from_pending_commit_list():
......
......@@ -53,7 +53,7 @@ class Command(object):
self.required_arguments = self._parse_required_arguments(argument_names)
self.options = options
self.requires_local_commits = requires_local_commits
self.tool = None
self._tool = None
# option_parser can be overriden by the tool using set_option_parser
# This default parser will be used for standalone_help printing.
self.option_parser = HelpPrintingOptionParser(usage=SUPPRESS_USAGE, add_help_option=False, option_list=self.options)
......@@ -73,9 +73,9 @@ class Command(object):
# The tool calls bind_to_tool on each Command after adding it to its list.
def bind_to_tool(self, tool):
# Command instances can only be bound to one tool at a time.
if self.tool and tool != self.tool:
if self._tool and tool != self._tool:
raise Exception("Command already bound to tool!")
self.tool = tool
self._tool = tool
@staticmethod
def _parse_required_arguments(argument_names):
......@@ -179,17 +179,17 @@ class HelpCommand(AbstractDeclarativeCommand):
# Only show commands which are relevant to this checkout's SCM system. Might this be confusing to some users?
if self.show_all_commands:
epilog = "All %prog commands:\n"
relevant_commands = self.tool.commands[:]
relevant_commands = self._tool.commands[:]
else:
epilog = "Common %prog commands:\n"
relevant_commands = filter(self.tool.should_show_in_main_help, self.tool.commands)
relevant_commands = filter(self._tool.should_show_in_main_help, self._tool.commands)
longest_name_length = max(map(lambda command: len(command.name), relevant_commands))
relevant_commands.sort(lambda a, b: cmp(a.name, b.name))
command_help_texts = map(lambda command: " %s %s\n" % (command.name.ljust(longest_name_length), command.help_text), relevant_commands)
epilog += "%s\n" % "".join(command_help_texts)
epilog += "See '%prog help --all-commands' to list all commands.\n"
epilog += "See '%prog help COMMAND' for more information on a specific command.\n"
return epilog.replace("%prog", self.tool.name()) # Use of %prog here mimics OptionParser.expand_prog_name().
return epilog.replace("%prog", self._tool.name()) # Use of %prog here mimics OptionParser.expand_prog_name().
# FIXME: This is a hack so that we don't show --all-commands as a global option:
def _remove_help_options(self):
......@@ -198,7 +198,7 @@ class HelpCommand(AbstractDeclarativeCommand):
def execute(self, options, args, tool):
if args:
command = self.tool.command_by_name(args[0])
command = self._tool.command_by_name(args[0])
if command:
print command.standalone_help()
return 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment