Merge AbstractDeclarativeCommand into Command as a comment suggests
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2013 17:39:30 +0000 (17:39 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2013 17:39:30 +0000 (17:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114559

Reviewed by Antti Koivisto.

Merged two classes as the comment right above AbstractDeclarativeCommand suggested.
We need to merge a lot more classes to make webkitpy hackable.

* Scripts/webkitpy/tool/commands/abstractlocalservercommand.py:
(AbstractLocalServerCommand):
(AbstractLocalServerCommand.__init__):
* Scripts/webkitpy/tool/commands/abstractsequencedcommand.py:
(AbstractSequencedCommand):
(AbstractSequencedCommand.__init__):
* Scripts/webkitpy/tool/commands/adduserstogroups.py:
(AddUsersToGroups):
* Scripts/webkitpy/tool/commands/analyzechangelog.py:
(AnalyzeChangeLog):
(AnalyzeChangeLog.__init__):
* Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py:
* Scripts/webkitpy/tool/commands/bugfortest.py:
(BugForTest):
* Scripts/webkitpy/tool/commands/bugsearch.py:
(BugSearch):
* Scripts/webkitpy/tool/commands/chromechannels.py:
(ChromeChannels):
(__init__):
* Scripts/webkitpy/tool/commands/download.py:
(AbstractPatchProcessingCommand):
* Scripts/webkitpy/tool/commands/findusers.py:
(FindUsers):
* Scripts/webkitpy/tool/commands/openbugs.py:
(OpenBugs):
* Scripts/webkitpy/tool/commands/queries.py:
(BugsToCommit):
(PatchesInCommitQueue):
(PatchesToCommitQueue):
(PatchesToCommitQueue.__init__):
(PatchesToReview):
(PatchesToReview.__init__):
(PatchesToReview.execute):
(WhatBroke):
(ResultsFor):
(FailureReason):
(FindFlakyTests):
(TreeStatus):
(CrashLog):
(PrintExpectations):
(PrintExpectations.__init__):
(PrintBaselines):
(PrintBaselines.__init__):
* Scripts/webkitpy/tool/commands/queues.py:
(AbstractQueue.__init__):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(AbstractRebaseliningCommand):
* Scripts/webkitpy/tool/commands/suggestnominations.py:
(SuggestNominations):
(SuggestNominations.__init__):
* Scripts/webkitpy/tool/commands/upload.py:
(CommitMessageForCurrentDiff):
(CommitMessageForCurrentDiff.__init__):
(CleanPendingCommit):
(CleanReviewQueue):
(AssignToCommitter):
(PostCommits):
(PostCommits.__init__):
(MarkBugFixed):
(MarkBugFixed.__init__):
(CreateBug):
(CreateBug.__init__):
* Scripts/webkitpy/tool/multicommandtool.py:
(Command):
(Command.__init__):
(Command.main):
(HelpCommand):
(HelpCommand.__init__):
* Scripts/webkitpy/tool/multicommandtool_unittest.py:
(TrivialCommand):
(TrivialCommand.__init__):
(LikesToRetry):
(LikesToRetry.__init__):
(CommandTest.test_name_with_arguments):
(CommandTest.test_required_arguments):
(test_command_help):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148360 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Tools/ChangeLog
Tools/Scripts/webkitpy/tool/commands/abstractlocalservercommand.py
Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py
Tools/Scripts/webkitpy/tool/commands/adduserstogroups.py
Tools/Scripts/webkitpy/tool/commands/analyzechangelog.py
Tools/Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py
Tools/Scripts/webkitpy/tool/commands/bugfortest.py
Tools/Scripts/webkitpy/tool/commands/bugsearch.py
Tools/Scripts/webkitpy/tool/commands/chromechannels.py
Tools/Scripts/webkitpy/tool/commands/download.py
Tools/Scripts/webkitpy/tool/commands/findusers.py
Tools/Scripts/webkitpy/tool/commands/openbugs.py
Tools/Scripts/webkitpy/tool/commands/queries.py
Tools/Scripts/webkitpy/tool/commands/queues.py
Tools/Scripts/webkitpy/tool/commands/rebaseline.py
Tools/Scripts/webkitpy/tool/commands/suggestnominations.py
Tools/Scripts/webkitpy/tool/commands/upload.py
Tools/Scripts/webkitpy/tool/multicommandtool.py
Tools/Scripts/webkitpy/tool/multicommandtool_unittest.py

index b9998af..8caad5c 100644 (file)
@@ -1,3 +1,90 @@
+2013-04-13  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Merge AbstractDeclarativeCommand into Command as a comment suggests
+        https://bugs.webkit.org/show_bug.cgi?id=114559
+
+        Reviewed by Antti Koivisto.
+
+        Merged two classes as the comment right above AbstractDeclarativeCommand suggested.
+        We need to merge a lot more classes to make webkitpy hackable.
+
+        * Scripts/webkitpy/tool/commands/abstractlocalservercommand.py:
+        (AbstractLocalServerCommand):
+        (AbstractLocalServerCommand.__init__):
+        * Scripts/webkitpy/tool/commands/abstractsequencedcommand.py:
+        (AbstractSequencedCommand):
+        (AbstractSequencedCommand.__init__):
+        * Scripts/webkitpy/tool/commands/adduserstogroups.py:
+        (AddUsersToGroups):
+        * Scripts/webkitpy/tool/commands/analyzechangelog.py:
+        (AnalyzeChangeLog):
+        (AnalyzeChangeLog.__init__):
+        * Scripts/webkitpy/tool/commands/analyzechangelog_unittest.py:
+        * Scripts/webkitpy/tool/commands/bugfortest.py:
+        (BugForTest):
+        * Scripts/webkitpy/tool/commands/bugsearch.py:
+        (BugSearch):
+        * Scripts/webkitpy/tool/commands/chromechannels.py:
+        (ChromeChannels):
+        (__init__):
+        * Scripts/webkitpy/tool/commands/download.py:
+        (AbstractPatchProcessingCommand):
+        * Scripts/webkitpy/tool/commands/findusers.py:
+        (FindUsers):
+        * Scripts/webkitpy/tool/commands/openbugs.py:
+        (OpenBugs):
+        * Scripts/webkitpy/tool/commands/queries.py:
+        (BugsToCommit):
+        (PatchesInCommitQueue):
+        (PatchesToCommitQueue):
+        (PatchesToCommitQueue.__init__):
+        (PatchesToReview):
+        (PatchesToReview.__init__):
+        (PatchesToReview.execute):
+        (WhatBroke):
+        (ResultsFor):
+        (FailureReason):
+        (FindFlakyTests):
+        (TreeStatus):
+        (CrashLog):
+        (PrintExpectations):
+        (PrintExpectations.__init__):
+        (PrintBaselines):
+        (PrintBaselines.__init__):
+        * Scripts/webkitpy/tool/commands/queues.py:
+        (AbstractQueue.__init__):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (AbstractRebaseliningCommand):
+        * Scripts/webkitpy/tool/commands/suggestnominations.py:
+        (SuggestNominations):
+        (SuggestNominations.__init__):
+        * Scripts/webkitpy/tool/commands/upload.py:
+        (CommitMessageForCurrentDiff):
+        (CommitMessageForCurrentDiff.__init__):
+        (CleanPendingCommit):
+        (CleanReviewQueue):
+        (AssignToCommitter):
+        (PostCommits):
+        (PostCommits.__init__):
+        (MarkBugFixed):
+        (MarkBugFixed.__init__):
+        (CreateBug):
+        (CreateBug.__init__):
+        * Scripts/webkitpy/tool/multicommandtool.py:
+        (Command):
+        (Command.__init__):
+        (Command.main):
+        (HelpCommand):
+        (HelpCommand.__init__):
+        * Scripts/webkitpy/tool/multicommandtool_unittest.py:
+        (TrivialCommand):
+        (TrivialCommand.__init__):
+        (LikesToRetry):
+        (LikesToRetry.__init__):
+        (CommandTest.test_name_with_arguments):
+        (CommandTest.test_required_arguments):
+        (test_command_help):
+
 2013-04-13  Ed Bartosh  <bartosh@gmail.com>
 
         [EFL] --minimal build fails with error: 'ViewModeInvalid' is not a member of 'WebCore::Page'
index 0056684..25a36ce 100644 (file)
 from optparse import make_option
 import threading
 
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
-class AbstractLocalServerCommand(AbstractDeclarativeCommand):
+class AbstractLocalServerCommand(Command):
     server = None
     launch_path = "/"
 
@@ -37,7 +37,7 @@ class AbstractLocalServerCommand(AbstractDeclarativeCommand):
             make_option("--httpd-port", action="store", type="int", default=8127, help="Port to use for the HTTP server"),
             make_option("--no-show-results", action="store_false", default=True, dest="show_results", help="Don't launch a browser with the rebaseline server"),
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
 
     def _prepare_config(self, options, args, tool):
         return None
index 0593f2c..fcc76ca 100644 (file)
@@ -30,16 +30,16 @@ import logging
 
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.tool.commands.stepsequence import StepSequence
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)
 
 
-class AbstractSequencedCommand(AbstractDeclarativeCommand):
+class AbstractSequencedCommand(Command):
     steps = None
     def __init__(self):
         self._sequence = StepSequence(self.steps)
-        AbstractDeclarativeCommand.__init__(self, self._sequence.options())
+        Command.__init__(self, self._sequence.options())
 
     def _prepare_state(self, options, args, tool):
         return None
index 2286958..25e719f 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
-class AddUsersToGroups(AbstractDeclarativeCommand):
+class AddUsersToGroups(Command):
     name = "add-users-to-groups"
     help_text = "Add users matching subtring to specified groups"
 
index b88b61f..4c5208b 100644 (file)
@@ -35,11 +35,11 @@ from webkitpy.common.checkout.changelog import ChangeLog
 from webkitpy.common.config.contributionareas import ContributionAreas
 from webkitpy.common.system.filesystem import FileSystem
 from webkitpy.common.system.executive import Executive
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 from webkitpy.tool import steps
 
 
-class AnalyzeChangeLog(AbstractDeclarativeCommand):
+class AnalyzeChangeLog(Command):
     name = "analyze-changelog"
     help_text = "Experimental command for analyzing change logs."
     long_help = "This command parses changelogs in a specified directory and summarizes the result as JSON files."
@@ -48,7 +48,7 @@ class AnalyzeChangeLog(AbstractDeclarativeCommand):
         options = [
             steps.Options.changelog_count,
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
 
     @staticmethod
     def _enumerate_changelogs(filesystem, dirname, changelog_count):
index 661d2d8..9c13740 100644 (file)
@@ -36,7 +36,7 @@ from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.commands.analyzechangelog import AnalyzeChangeLog
 from webkitpy.tool.commands.analyzechangelog import ChangeLogAnalyzer
 from webkitpy.tool.commands.commandtest import CommandsTest
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
 class AnalyzeChangeLogTest(CommandsTest):
index 36aa6b5..f6f8411 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 from webkitpy.tool.bot.flakytestreporter import FlakyTestReporter
 
 
 # This is mostly a command for testing FlakyTestReporter, however
 # it could be easily expanded to auto-create bugs, etc. if another
 # command outside of webkitpy wanted to use it.
-class BugForTest(AbstractDeclarativeCommand):
+class BugForTest(Command):
     name = "bug-for-test"
     help_text = "Finds the bugzilla bug for a given test"
 
index a1d74c5..1f3af7a 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
-class BugSearch(AbstractDeclarativeCommand):
+class BugSearch(Command):
     name = "bug-search"
     help_text = "List bugs matching a query"
     argument_names = "QUERY"
index da093b4..ab9d121 100644 (file)
 from optparse import make_option
 
 from webkitpy.common.net.omahaproxy import OmahaProxy
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 import re
 
 
-class ChromeChannels(AbstractDeclarativeCommand):
+class ChromeChannels(Command):
     name = "chrome-channels"
     help_text = "List which chrome channels include the patches in bugs returned by QUERY."
     argument_names = "QUERY"
@@ -53,7 +53,7 @@ documentation on the query format."""
     rollout_pattern = "Rolled out in http://trac.webkit.org/changeset/[0-9]+"
 
     def __init__(self):
-        AbstractDeclarativeCommand.__init__(self)
+        Command.__init__(self)
         self._re_committed = re.compile(self.commited_pattern)
         self._re_rollout = re.compile(self.rollout_pattern)
         self._omahaproxy = OmahaProxy()
index 395c913..4653a9b 100644 (file)
@@ -38,7 +38,7 @@ from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCom
 from webkitpy.tool.commands.stepsequence import StepSequence
 from webkitpy.tool.comments import bug_comment_from_commit_text
 from webkitpy.tool.grammar import pluralize
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)
 
@@ -145,7 +145,7 @@ class CheckStyleLocal(AbstractSequencedCommand):
     ]
 
 
-class AbstractPatchProcessingCommand(AbstractDeclarativeCommand):
+class AbstractPatchProcessingCommand(Command):
     # Subclasses must implement the methods below.  We don't declare them here
     # because we want to be able to implement them with mix-ins.
     #
index 4363c8c..ae47023 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
-class FindUsers(AbstractDeclarativeCommand):
+class FindUsers(Command):
     name = "find-users"
     help_text = "Find users matching substring"
 
index 8c55aba..b2ed532 100644 (file)
@@ -30,12 +30,12 @@ import logging
 import re
 import sys
 
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)
 
 
-class OpenBugs(AbstractDeclarativeCommand):
+class OpenBugs(Command):
     name = "open-bugs"
     help_text = "Finds all bug numbers passed in arguments (or stdin if no args provided) and opens them in a web browser"
 
index eeb93a1..cf1c47f 100644 (file)
@@ -46,7 +46,7 @@ from webkitpy.common.system.crashlogs import CrashLogs
 from webkitpy.common.system.user import User
 from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
 from webkitpy.tool.grammar import pluralize
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 from webkitpy.layout_tests.models.test_expectations import TestExpectations
 from webkitpy.layout_tests.port import platform_options, configuration_options
 
@@ -64,7 +64,7 @@ class SuggestReviewers(AbstractSequencedCommand):
         options.suggest_reviewers = True
 
 
-class BugsToCommit(AbstractDeclarativeCommand):
+class BugsToCommit(Command):
     name = "bugs-to-commit"
     help_text = "List bugs in the commit-queue"
 
@@ -75,7 +75,7 @@ class BugsToCommit(AbstractDeclarativeCommand):
             print "%s" % bug_id
 
 
-class PatchesInCommitQueue(AbstractDeclarativeCommand):
+class PatchesInCommitQueue(Command):
     name = "patches-in-commit-queue"
     help_text = "List patches in the commit-queue"
 
@@ -86,14 +86,14 @@ class PatchesInCommitQueue(AbstractDeclarativeCommand):
             print patch.url()
 
 
-class PatchesToCommitQueue(AbstractDeclarativeCommand):
+class PatchesToCommitQueue(Command):
     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)
+        Command.__init__(self, options=options)
 
     @staticmethod
     def _needs_commit_queue(patch):
@@ -120,7 +120,7 @@ class PatchesToCommitQueue(AbstractDeclarativeCommand):
                 print "%s" % tool.bugs.attachment_url_for_id(patch.id(), action="edit")
 
 
-class PatchesToReview(AbstractDeclarativeCommand):
+class PatchesToReview(Command):
     name = "patches-to-review"
     help_text = "List bugs which have attachments pending review"
 
@@ -133,7 +133,7 @@ class PatchesToReview(AbstractDeclarativeCommand):
             make_option("--cc-email",
                         help="Specifies the email on the CC field (defaults to your bugzilla login email)"),
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
 
     def _print_report(self, report, cc_email, print_all):
         if print_all:
@@ -173,7 +173,8 @@ class PatchesToReview(AbstractDeclarativeCommand):
         report = self._generate_report(bugs, options.include_cq_denied)
         self._print_report(report, cc_email, options.all)
 
-class WhatBroke(AbstractDeclarativeCommand):
+
+class WhatBroke(Command):
     name = "what-broke"
     help_text = "Print failing buildbots (%s) and what revisions broke them" % config_urls.buildbot_url
 
@@ -219,7 +220,7 @@ class WhatBroke(AbstractDeclarativeCommand):
             print "All builders are passing!"
 
 
-class ResultsFor(AbstractDeclarativeCommand):
+class ResultsFor(Command):
     name = "results-for"
     help_text = "Print a list of failures for the passed revision from bots on %s" % config_urls.buildbot_url
     argument_names = "REVISION"
@@ -241,7 +242,7 @@ class ResultsFor(AbstractDeclarativeCommand):
             self._print_layout_test_results(build.layout_test_results())
 
 
-class FailureReason(AbstractDeclarativeCommand):
+class FailureReason(Command):
     name = "failure-reason"
     help_text = "Lists revisions where individual test failures started at %s" % config_urls.buildbot_url
 
@@ -327,7 +328,7 @@ class FailureReason(AbstractDeclarativeCommand):
         return self._explain_failures_for_builder(builder, start_revision=int(start_revision))
 
 
-class FindFlakyTests(AbstractDeclarativeCommand):
+class FindFlakyTests(Command):
     name = "find-flaky-tests"
     help_text = "Lists tests that often fail for a single build at %s" % config_urls.buildbot_url
 
@@ -396,7 +397,7 @@ class FindFlakyTests(AbstractDeclarativeCommand):
         return self._walk_backwards_from(builder, latest_revision, limit=int(limit))
 
 
-class TreeStatus(AbstractDeclarativeCommand):
+class TreeStatus(Command):
     name = "tree-status"
     help_text = "Print the status of the %s buildbots" % config_urls.buildbot_url
     long_help = """Fetches build status from http://build.webkit.org/one_box_per_builder
@@ -408,7 +409,7 @@ and displayes the status of each builder."""
             print "%s : %s" % (status_string.ljust(4), builder["name"])
 
 
-class CrashLog(AbstractDeclarativeCommand):
+class CrashLog(Command):
     name = "crash-log"
     help_text = "Print the newest crash log for the given process"
     long_help = """Finds the newest crash log matching the given process name
@@ -423,7 +424,7 @@ and PID and prints it to stdout."""
         print crash_logs.find_newest_log(args[0], pid)
 
 
-class PrintExpectations(AbstractDeclarativeCommand):
+class PrintExpectations(Command):
     name = 'print-expectations'
     help_text = 'Print the expected result for the given test(s) on the given port(s)'
 
@@ -443,7 +444,7 @@ class PrintExpectations(AbstractDeclarativeCommand):
                         help='display the paths for all applicable expectation files'),
         ] + platform_options(use_globs=True)
 
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
         self._expectation_models = {}
 
     def execute(self, options, args, tool):
@@ -514,7 +515,7 @@ class PrintExpectations(AbstractDeclarativeCommand):
         return TestExpectations(port, tests).model()
 
 
-class PrintBaselines(AbstractDeclarativeCommand):
+class PrintBaselines(Command):
     name = 'print-baselines'
     help_text = 'Prints the baseline locations for given test(s) on the given port(s)'
 
@@ -527,7 +528,7 @@ class PrintBaselines(AbstractDeclarativeCommand):
             make_option('--include-virtual-tests', action='store_true',
                         help='Include virtual tests'),
         ] + platform_options(use_globs=True)
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
         self._platform_regexp = re.compile('platform/([^\/]+)/(.+)')
 
     def execute(self, options, args, tool):
index f68b51a..b80ae9e 100644 (file)
@@ -72,7 +72,8 @@ class AbstractQueue(Command, QueueEngineDelegate):
             make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Do not ask the user for confirmation before running the queue.  Dangerous!"),
             make_option("--exit-after-iteration", action="store", type="int", dest="iterations", default=None, help="Stop running the queue after iterating this number of times."),
         ]
-        Command.__init__(self, "Run the %s" % self.name, options=options_list)
+        self.help_text = "Run the %s" % self.name
+        Command.__init__(self, options=options_list)
         self._iteration_count = 0
 
     def _cc_watchers(self, bug_id):
index e8ae8f3..f15dc03 100644 (file)
@@ -38,7 +38,7 @@ from webkitpy.layout_tests.models import test_failures
 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BASELINE_SUFFIX_LIST
 from webkitpy.layout_tests.port import builders
 from webkitpy.layout_tests.port import factory
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
 _log = logging.getLogger(__name__)
@@ -49,7 +49,7 @@ def _baseline_name(fs, test_name, suffix):
     return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED + "." + suffix
 
 
-class AbstractRebaseliningCommand(AbstractDeclarativeCommand):
+class AbstractRebaseliningCommand(Command):
     # not overriding execute() - pylint: disable=W0223
 
     move_overwritten_baselines_option = optparse.make_option("--move-overwritten-baselines", action="store_true", default=False,
index c197a11..845b782 100644 (file)
@@ -34,10 +34,10 @@ from webkitpy.common.checkout.changelog import ChangeLogEntry
 from webkitpy.common.config.committers import CommitterList
 from webkitpy.tool import steps
 from webkitpy.tool.grammar import join_with_separators
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 
-class SuggestNominations(AbstractDeclarativeCommand):
+class SuggestNominations(Command):
     name = "suggest-nominations"
     help_text = "Suggest contributors for committer/reviewer nominations"
 
@@ -49,7 +49,7 @@ class SuggestNominations(AbstractDeclarativeCommand):
             make_option("--show-commits", action="store_true", dest="show_commits", default=False, help="Show commit history with nomination suggestions."),
         ]
 
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
         # FIXME: This should probably be on the tool somewhere.
         self._committer_list = CommitterList()
 
index d3faa78..69dc4f7 100644 (file)
@@ -43,12 +43,12 @@ from webkitpy.thirdparty.mock import Mock
 from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
 from webkitpy.tool.comments import bug_comment_from_svn_revision
 from webkitpy.tool.grammar import pluralize, join_with_separators
-from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
+from webkitpy.tool.multicommandtool import Command
 
 _log = logging.getLogger(__name__)
 
 
-class CommitMessageForCurrentDiff(AbstractDeclarativeCommand):
+class CommitMessageForCurrentDiff(Command):
     name = "commit-message"
     help_text = "Print a commit message suitable for the uncommitted changes"
 
@@ -56,7 +56,7 @@ class CommitMessageForCurrentDiff(AbstractDeclarativeCommand):
         options = [
             steps.Options.git_commit,
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
 
     def execute(self, options, args, tool):
         # This command is a useful test to make sure commit_message_for_this_commit
@@ -64,7 +64,7 @@ class CommitMessageForCurrentDiff(AbstractDeclarativeCommand):
         print "%s" % tool.checkout().commit_message_for_this_commit(options.git_commit).message()
 
 
-class CleanPendingCommit(AbstractDeclarativeCommand):
+class CleanPendingCommit(Command):
     name = "clean-pending-commit"
     help_text = "Clear r+ on obsolete patches so they do not appear in the pending-commit list."
 
@@ -94,7 +94,7 @@ class CleanPendingCommit(AbstractDeclarativeCommand):
 
 
 # FIXME: This should be share more logic with AssignToCommitter and CleanPendingCommit
-class CleanReviewQueue(AbstractDeclarativeCommand):
+class CleanReviewQueue(Command):
     name = "clean-review-queue"
     help_text = "Clear r? on obsolete patches so they do not appear in the pending-review list."
 
@@ -119,7 +119,7 @@ class CleanReviewQueue(AbstractDeclarativeCommand):
             self._tool.bugs.obsolete_attachment(patch.id(), message)
 
 
-class AssignToCommitter(AbstractDeclarativeCommand):
+class AssignToCommitter(Command):
     name = "assign-to-committer"
     help_text = "Assign bug to whoever attached the most recent r+'d patch"
 
@@ -306,7 +306,7 @@ class EditChangeLogs(AbstractSequencedCommand):
     ]
 
 
-class PostCommits(AbstractDeclarativeCommand):
+class PostCommits(Command):
     name = "post-commits"
     help_text = "Attach a range of local commits to bugs as patch files"
     argument_names = "COMMITISH"
@@ -320,7 +320,7 @@ class PostCommits(AbstractDeclarativeCommand):
             steps.Options.review,
             steps.Options.request_commit,
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options, requires_local_commits=True)
+        Command.__init__(self, options=options, requires_local_commits=True)
 
     def _comment_text_for_commit(self, options, commit_message, tool, commit_id):
         comment_text = None
@@ -358,7 +358,7 @@ class PostCommits(AbstractDeclarativeCommand):
 
 
 # FIXME: This command needs to be brought into the modern age with steps and CommitInfo.
-class MarkBugFixed(AbstractDeclarativeCommand):
+class MarkBugFixed(Command):
     name = "mark-bug-fixed"
     help_text = "Mark the specified bug as fixed"
     argument_names = "[SVN_REVISION]"
@@ -369,7 +369,7 @@ class MarkBugFixed(AbstractDeclarativeCommand):
             make_option("--open", action="store_true", default=False, dest="open_bug", help="Open bug in default web browser (Mac only)."),
             make_option("--update-only", action="store_true", default=False, dest="update_only", help="Add comment to the bug, but do not close it."),
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
 
     # FIXME: We should be using checkout().changelog_entries_for_revision(...) instead here.
     def _fetch_commit_log(self, tool, svn_revision):
@@ -439,7 +439,7 @@ class MarkBugFixed(AbstractDeclarativeCommand):
 
 
 # FIXME: Requires unit test.  Blocking issue: too complex for now.
-class CreateBug(AbstractDeclarativeCommand):
+class CreateBug(Command):
     name = "create-bug"
     help_text = "Create a bug from local changes or local commits"
     argument_names = "[COMMITISH]"
@@ -452,7 +452,7 @@ class CreateBug(AbstractDeclarativeCommand):
             make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review."),
             make_option("--request-commit", action="store_true", dest="request_commit", default=False, help="Mark the patch as needing auto-commit after review."),
         ]
-        AbstractDeclarativeCommand.__init__(self, options=options)
+        Command.__init__(self, options=options)
 
     def create_bug_from_commit(self, options, args, tool):
         commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
index e2f91a7..01b022f 100644 (file)
@@ -48,11 +48,12 @@ class TryAgain(Exception):
 class Command(object):
     name = None
     show_in_main_help = False
-    def __init__(self, help_text, argument_names=None, options=None, long_help=None, requires_local_commits=False):
-        self.help_text = help_text
-        self.long_help = long_help
-        self.argument_names = argument_names
-        self.required_arguments = self._parse_required_arguments(argument_names)
+    help_text = None
+    long_help = None
+    argument_names = None
+
+    def __init__(self, options=None, requires_local_commits=False):
+        self.required_arguments = self._parse_required_arguments(self.argument_names)
         self.options = options
         self.requires_local_commits = requires_local_commits
         self._tool = None
@@ -139,15 +140,6 @@ class Command(object):
         return self.check_arguments_and_execute(options, args)
 
 
-# FIXME: This should just be rolled into Command.  help_text and argument_names do not need to be instance variables.
-class AbstractDeclarativeCommand(Command):
-    help_text = None
-    argument_names = None
-    long_help = None
-    def __init__(self, options=None, **kwargs):
-        Command.__init__(self, self.help_text, self.argument_names, options=options, long_help=self.long_help, **kwargs)
-
-
 class HelpPrintingOptionParser(OptionParser):
     def __init__(self, epilog_method=None, *args, **kwargs):
         self.epilog_method = epilog_method
@@ -168,7 +160,7 @@ class HelpPrintingOptionParser(OptionParser):
         return ""
 
 
-class HelpCommand(AbstractDeclarativeCommand):
+class HelpCommand(Command):
     name = "help"
     help_text = "Display information about this program or its subcommands"
     argument_names = "[COMMAND]"
@@ -177,7 +169,7 @@ class HelpCommand(AbstractDeclarativeCommand):
         options = [
             make_option("-a", "--all-commands", action="store_true", dest="show_all_commands", help="Print all available commands"),
         ]
-        AbstractDeclarativeCommand.__init__(self, options)
+        Command.__init__(self, options)
         self.show_all_commands = False # A hack used to pass --all-commands to _help_epilog even though it's called by the OptionParser.
 
     def _help_epilog(self):
index 7230235..1d15c7d 100644 (file)
@@ -38,8 +38,9 @@ from webkitpy.tool.multicommandtool import MultiCommandTool, Command, TryAgain
 class TrivialCommand(Command):
     name = "trivial"
     show_in_main_help = True
+    help_text = "help text"
     def __init__(self, **kwargs):
-        Command.__init__(self, "help text", **kwargs)
+        Command.__init__(self, **kwargs)
 
     def execute(self, options, args, tool):
         pass
@@ -53,9 +54,10 @@ class UncommonCommand(TrivialCommand):
 class LikesToRetry(Command):
     name = "likes-to-retry"
     show_in_main_help = True
+    help_text = "help text"
 
     def __init__(self, **kwargs):
-        Command.__init__(self, "help text", **kwargs)
+        Command.__init__(self, **kwargs)
         self.execute_count = 0
 
     def execute(self, options, args, tool):
@@ -66,9 +68,11 @@ class LikesToRetry(Command):
 
 class CommandTest(unittest.TestCase):
     def test_name_with_arguments(self):
-        command_with_args = TrivialCommand(argument_names="ARG1 ARG2")
+        TrivialCommand.argument_names = "ARG1 ARG2"
+        command_with_args = TrivialCommand()
         self.assertEqual(command_with_args.name_with_arguments(), "trivial ARG1 ARG2")
 
+        TrivialCommand.argument_names = None
         command_with_args = TrivialCommand(options=[make_option("--my_option")])
         self.assertEqual(command_with_args.name_with_arguments(), "trivial [options]")
 
@@ -80,7 +84,8 @@ class CommandTest(unittest.TestCase):
         self.assertRaises(Exception, Command._parse_required_arguments, "[ARG1 ARG2]")
 
     def test_required_arguments(self):
-        two_required_arguments = TrivialCommand(argument_names="ARG1 ARG2 [ARG3]")
+        TrivialCommand.argument_names = "ARG1 ARG2 [ARG3]"
+        two_required_arguments = TrivialCommand()
         expected_logs = "2 arguments required, 1 argument provided.  Provided: 'foo'  Required: ARG1 ARG2\nSee 'trivial-tool help trivial' for usage.\n"
         exit_code = OutputCapture().assert_outputs(self, two_required_arguments.check_arguments_and_execute, [None, ["foo"], TrivialTool()], expected_logs=expected_logs)
         self.assertEqual(exit_code, 1)
@@ -167,7 +172,8 @@ See 'trivial-tool help COMMAND' for more information on a specific command.
 
 
     def test_command_help(self):
-        command_with_options = TrivialCommand(options=[make_option("--my_option")], long_help="LONG HELP")
+        command_with_options = TrivialCommand(options=[make_option("--my_option")])
+        command_with_options.long_help = "LONG HELP"
         tool = TrivialTool(commands=[command_with_options])
         expected_subcommand_help = "trivial [options]   help text\n\nLONG HELP\n\nOptions:\n  --my_option=MY_OPTION\n\n"
         self._assert_tool_main_outputs(tool, ["tool", "help", "trivial"], expected_subcommand_help)