diff options
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/tool')
26 files changed, 146 insertions, 116 deletions
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py b/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py index 887802c..de92cd3 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py @@ -29,10 +29,9 @@ import unittest from webkitpy.common.system.outputcapture import OutputCapture -from webkitpy.tool.mocktool import MockTool -from webkitpy.thirdparty.mock import Mock +from webkitpy.tool.mocktool import MockOptions, MockTool class CommandsTest(unittest.TestCase): - def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=Mock(), tool=MockTool()): + def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=MockOptions(), tool=MockTool()): command.bind_to_tool(tool) OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/download.py b/WebKitTools/Scripts/webkitpy/tool/commands/download.py index 59af16a..d27ab0e 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/download.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/download.py @@ -93,7 +93,7 @@ If a bug id is provided, or one can be found in the ChangeLog land will update t def _prepare_state(self, options, args, tool): return { - "bug_id": (args and args[0]) or tool.checkout().bug_id_for_this_commit(options.git_commit, options.squash), + "bug_id": (args and args[0]) or tool.checkout().bug_id_for_this_commit(options.git_commit), } diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py b/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py index 958620a..75cd0f3 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py @@ -32,7 +32,7 @@ from webkitpy.common.system.outputcapture import OutputCapture from webkitpy.thirdparty.mock import Mock from webkitpy.tool.commands.commandtest import CommandsTest from webkitpy.tool.commands.download import * -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool class AbstractRolloutPrepCommandTest(unittest.TestCase): @@ -56,7 +56,7 @@ class AbstractRolloutPrepCommandTest(unittest.TestCase): class DownloadCommandsTest(CommandsTest): def _default_options(self): - options = Mock() + options = MockOptions() options.force_clean = False options.clean = True options.check_builders = True diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/queues.py b/WebKitTools/Scripts/webkitpy/tool/commands/queues.py index 5ff390c..97c3ddb 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/queues.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/queues.py @@ -42,7 +42,7 @@ from webkitpy.tool.commands.stepsequence import StepSequenceErrorHandler from webkitpy.tool.bot.patchcollection import PersistentPatchCollection, PersistentPatchCollectionDelegate from webkitpy.tool.bot.queueengine import QueueEngine, QueueEngineDelegate from webkitpy.tool.grammar import pluralize -from webkitpy.tool.multicommandtool import Command +from webkitpy.tool.multicommandtool import Command, TryAgain class AbstractQueue(Command, QueueEngineDelegate): watchers = [ @@ -279,6 +279,17 @@ class CommitQueue(AbstractPatchQueue, StepSequenceErrorHandler): validator = CommitterValidator(tool.bugs) validator.reject_patch_from_commit_queue(state["patch"].id(), cls._error_message_for_bug(tool, status_id, script_error)) + @classmethod + def handle_checkout_needs_update(cls, tool, state, options, error): + # The only time when we find out that out checkout needs update is + # when we were ready to actually pull the trigger and land the patch. + # Rather than spinning in the master process, we retry without + # building or testing, which is much faster. + options.build = False + options.test = False + options.update = True + raise TryAgain() + class RietveldUploadQueue(AbstractPatchQueue, StepSequenceErrorHandler): name = "rietveld-upload-queue" diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/stepsequence.py b/WebKitTools/Scripts/webkitpy/tool/commands/stepsequence.py index c6de79f..be2ed4c 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/stepsequence.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/stepsequence.py @@ -39,6 +39,10 @@ class StepSequenceErrorHandler(): def handle_script_error(cls, tool, patch, script_error): raise NotImplementedError, "subclasses must implement" + @classmethod + def handle_checkout_needs_update(cls, tool, state, options, error): + raise NotImplementedError, "subclasses must implement" + class StepSequence(object): def __init__(self, steps): @@ -66,6 +70,9 @@ class StepSequence(object): self._run(tool, options, state) except CheckoutNeedsUpdate, e: log("Commit failed because the checkout is out of date. Please update and try again.") + if options.parent_command: + command = tool.command_by_name(options.parent_command) + command.handle_checkout_needs_update(tool, state, options, e) QueueEngine.exit_after_handled_error(e) except ScriptError, e: if not options.quiet: diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/upload.py b/WebKitTools/Scripts/webkitpy/tool/commands/upload.py index 9c935e8..4a15ed6 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/upload.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/upload.py @@ -53,7 +53,6 @@ class CommitMessageForCurrentDiff(AbstractDeclarativeCommand): def __init__(self): options = [ - steps.Options.squash, steps.Options.git_commit, ] AbstractDeclarativeCommand.__init__(self, options=options) @@ -61,7 +60,7 @@ class CommitMessageForCurrentDiff(AbstractDeclarativeCommand): def execute(self, options, args, tool): # This command is a useful test to make sure commit_message_for_this_commit # always returns the right value regardless of the current working directory. - print "%s" % tool.checkout().commit_message_for_this_commit(options.git_commit, options.squash).message() + print "%s" % tool.checkout().commit_message_for_this_commit(options.git_commit).message() class CleanPendingCommit(AbstractDeclarativeCommand): @@ -153,7 +152,7 @@ class AbstractPatchUploadingCommand(AbstractSequencedCommand): # Perfer a bug id passed as an argument over a bug url in the diff (i.e. ChangeLogs). bug_id = args and args[0] if not bug_id: - bug_id = tool.checkout().bug_id_for_this_commit(options.git_commit, options.squash) + bug_id = tool.checkout().bug_id_for_this_commit(options.git_commit) return bug_id def _prepare_state(self, options, args, tool): @@ -423,11 +422,11 @@ class CreateBug(AbstractDeclarativeCommand): if options.prompt: (bug_title, comment_text) = self.prompt_for_bug_title_and_comment() else: - commit_message = tool.checkout().commit_message_for_this_commit(options.git_commit, options.squash) + commit_message = tool.checkout().commit_message_for_this_commit(options.git_commit) bug_title = commit_message.description(lstrip=True, strip_url=True) comment_text = commit_message.body(lstrip=True) - diff = tool.scm().create_patch(options.git_commit, options.squash) + diff = tool.scm().create_patch(options.git_commit) bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit) def prompt_for_bug_title_and_comment(self): diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py b/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py index 8fef54a..5f3f400 100644 --- a/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py @@ -29,7 +29,7 @@ from webkitpy.thirdparty.mock import Mock from webkitpy.tool.commands.commandtest import CommandsTest from webkitpy.tool.commands.upload import * -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool class UploadCommandsTest(CommandsTest): def test_commit_message_for_current_diff(self): @@ -51,7 +51,7 @@ class UploadCommandsTest(CommandsTest): self.assert_execute_outputs(ObsoleteAttachments(), [42], expected_stderr=expected_stderr) def test_post(self): - options = Mock() + options = MockOptions() options.description = "MOCK description" options.request_commit = False options.review = True @@ -80,7 +80,7 @@ MOCK: user.open_url: http://example.com/42 self.assert_execute_outputs(Prepare(), [], expected_stderr=expected_stderr) def test_upload(self): - options = Mock() + options = MockOptions() options.description = "MOCK description" options.request_commit = False options.review = True diff --git a/WebKitTools/Scripts/webkitpy/tool/mocktool.py b/WebKitTools/Scripts/webkitpy/tool/mocktool.py index d88190f..a467364 100644 --- a/WebKitTools/Scripts/webkitpy/tool/mocktool.py +++ b/WebKitTools/Scripts/webkitpy/tool/mocktool.py @@ -397,7 +397,7 @@ class MockSCM(Mock): # will actually be the root. Since getcwd() is wrong, use a globally fake root for now. self.checkout_root = self.fake_checkout_root - def create_patch(self, git_commit, squash): + def create_patch(self, git_commit): return "Patch1" def commit_ids_from_commitish_arguments(self, args): @@ -437,12 +437,12 @@ class MockCheckout(object): def bug_id_for_revision(self, svn_revision): return 12345 - def modified_changelogs(self, git_commit, squash): + def modified_changelogs(self, git_commit): # Ideally we'd return something more interesting here. The problem is # that LandDiff will try to actually read the patch from disk! return [] - def commit_message_for_this_commit(self, git_commit, squash): + def commit_message_for_this_commit(self, git_commit): commit_message = Mock() commit_message.message = lambda:"This is a fake commit message that is at least 50 characters." return commit_message @@ -515,6 +515,7 @@ class MockStatusServer(object): def results_url_for_status(self, status_id): return "http://dummy_url" + class MockExecute(Mock): def __init__(self, should_log): self._should_log = should_log @@ -537,6 +538,11 @@ class MockExecute(Mock): return "MOCK output of child process" +class MockOptions(Mock): + no_squash = False + squash = False + + class MockRietveld(): def __init__(self, executive, dryrun=False): diff --git a/WebKitTools/Scripts/webkitpy/tool/multicommandtool.py b/WebKitTools/Scripts/webkitpy/tool/multicommandtool.py index 7940c06..12ede2e 100644 --- a/WebKitTools/Scripts/webkitpy/tool/multicommandtool.py +++ b/WebKitTools/Scripts/webkitpy/tool/multicommandtool.py @@ -39,6 +39,10 @@ from webkitpy.tool.grammar import pluralize from webkitpy.common.system.deprecated_logging import log +class TryAgain(Exception): + pass + + class Command(object): name = None show_in_main_help = False @@ -299,6 +303,12 @@ class MultiCommandTool(object): log(failure_reason) return 0 # FIXME: Should this really be 0? - result = command.check_arguments_and_execute(options, args, self) + while True: + try: + result = command.check_arguments_and_execute(options, args, self) + break + except TryAgain, e: + pass + self.command_completed() return result diff --git a/WebKitTools/Scripts/webkitpy/tool/multicommandtool_unittest.py b/WebKitTools/Scripts/webkitpy/tool/multicommandtool_unittest.py index 268ebf0..c19095c 100644 --- a/WebKitTools/Scripts/webkitpy/tool/multicommandtool_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/multicommandtool_unittest.py @@ -32,7 +32,7 @@ import unittest from optparse import make_option from webkitpy.common.system.outputcapture import OutputCapture -from webkitpy.tool.multicommandtool import MultiCommandTool, Command +from webkitpy.tool.multicommandtool import MultiCommandTool, Command, TryAgain class TrivialCommand(Command): @@ -44,10 +44,26 @@ class TrivialCommand(Command): def execute(self, options, args, tool): pass + class UncommonCommand(TrivialCommand): name = "uncommon" show_in_main_help = False + +class LikesToRetry(Command): + name = "likes-to-retry" + show_in_main_help = True + + def __init__(self, **kwargs): + Command.__init__(self, "help text", **kwargs) + self.execute_count = 0 + + def execute(self, options, args, tool): + self.execute_count += 1 + if self.execute_count < 2: + raise TryAgain() + + class CommandTest(unittest.TestCase): def test_name_with_arguments(self): command_with_args = TrivialCommand(argument_names="ARG1 ARG2") @@ -109,6 +125,12 @@ class MultiCommandToolTest(unittest.TestCase): exit_code = OutputCapture().assert_outputs(self, tool.main, [main_args], expected_stdout=expected_stdout, expected_stderr=expected_stderr) self.assertEqual(exit_code, expected_exit_code) + def test_retry(self): + likes_to_retry = LikesToRetry() + tool = TrivialTool(commands=[likes_to_retry]) + tool.main(["tool", "likes-to-retry"]) + self.assertEqual(likes_to_retry.execute_count, 2) + def test_global_help(self): tool = TrivialTool(commands=[TrivialCommand(), UncommonCommand()]) expected_common_commands_help = """Usage: trivial-tool [options] COMMAND [ARGS] diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py b/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py index 20f8bbf..8f0d153 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py @@ -27,6 +27,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from webkitpy.common.system.deprecated_logging import log +from webkitpy.common.system.executive import ScriptError from webkitpy.common.config.ports import WebKitPort from webkitpy.tool.steps.options import Options @@ -34,6 +35,10 @@ from webkitpy.tool.steps.options import Options class AbstractStep(object): def __init__(self, tool, options): self._tool = tool + if options.no_squash: + raise ScriptError('--no-squash has been removed. Use "--git-commit=HEAD.." or "-g HEAD.." to operate on the working copy.') + if options.squash: + raise ScriptError('--squash has been removed. It is now the default behavior if --git-commit is omitted.') self._options = options self._port = None @@ -53,8 +58,8 @@ class AbstractStep(object): return self._port _well_known_keys = { - "diff": lambda self, state: self._tool.scm().create_patch(self._options.git_commit, self._options.squash), - "changelogs": lambda self, state: self._tool.checkout().modified_changelogs(self._options.git_commit, self._options.squash), + "diff": lambda self, state: self._tool.scm().create_patch(self._options.git_commit), + "changelogs": lambda self, state: self._tool.checkout().modified_changelogs(self._options.git_commit), "bug_title": lambda self, state: self._tool.bugs.fetch_bug(state["bug_id"]).title(), } @@ -69,8 +74,9 @@ class AbstractStep(object): @classmethod def options(cls): return [ - # We need these options here because cached_lookup uses them. :( + # We need this option here because cached_lookup uses it. :( Options.git_commit, + # FIXME: Get rid of these. Options.no_squash, Options.squash, ] diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/applypatchwithlocalcommit.py b/WebKitTools/Scripts/webkitpy/tool/steps/applypatchwithlocalcommit.py index d6b026d..3dcd8d9 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/applypatchwithlocalcommit.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/applypatchwithlocalcommit.py @@ -39,5 +39,5 @@ class ApplyPatchWithLocalCommit(ApplyPatch): def run(self, state): ApplyPatch.run(self, state) if self._options.local_commit: - commit_message = self._tool.checkout().commit_message_for_this_commit(git_commit=None, squash=False) + commit_message = self._tool.checkout().commit_message_for_this_commit(git_commit=None) self._tool.scm().commit_locally_with_message(commit_message.message() or state["patch"].name()) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle.py b/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle.py index 93e6215..af38214 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle.py @@ -40,8 +40,6 @@ class CheckStyle(AbstractStep): Options.non_interactive, Options.check_style, Options.git_commit, - Options.no_squash, - Options.squash, ] def run(self, state): @@ -53,10 +51,6 @@ class CheckStyle(AbstractStep): if self._options.git_commit: args.append("--git-commit") args.append(self._options.git_commit) - if self._tool.scm().should_squash(self._options.squash): - args.append("--squash") - else: - args.append("--no-squash") try: self._run_script("check-webkit-style", args) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle_unittest.py deleted file mode 100644 index a23ea1b..0000000 --- a/WebKitTools/Scripts/webkitpy/tool/steps/checkstyle_unittest.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2009 Google Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import unittest - -from webkitpy.common.system.executive import ScriptError -from webkitpy.thirdparty.mock import Mock -from webkitpy.tool.mocktool import MockTool -from webkitpy.tool.steps.checkstyle import CheckStyle - - -class CheckStyleTest(unittest.TestCase): - def test_should_squash_error(self): - """should_squash can throw an error. That error should not be eaten by CheckStyle.""" - def should_squash(squash): - raise ScriptError(message="Dummy error") - - tool = MockTool() - tool._scm.should_squash = should_squash - step = CheckStyle(tool, Mock()) - self.assertRaises(ScriptError, step.run, []) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py index 4e7f9e6..0a56564 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py @@ -29,13 +29,12 @@ import unittest from webkitpy.common.system.outputcapture import OutputCapture -from webkitpy.thirdparty.mock import Mock -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool from webkitpy.tool.steps.closebugforlanddiff import CloseBugForLandDiff class CloseBugForLandDiffTest(unittest.TestCase): def test_empty_state(self): capture = OutputCapture() - step = CloseBugForLandDiff(MockTool(), Mock()) + step = CloseBugForLandDiff(MockTool(), MockOptions()) expected_stderr = "Committed r49824: <http://trac.webkit.org/changeset/49824>\nNo bug id provided.\n" capture.assert_outputs(self, step.run, [{"commit_text" : "Mock commit text"}], expected_stderr=expected_stderr) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/commit.py b/WebKitTools/Scripts/webkitpy/tool/steps/commit.py index 7bf8b8a..9f93120 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/commit.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/commit.py @@ -26,6 +26,9 @@ # (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.common.checkout.scm import AuthenticationError, AmbiguousCommitError +from webkitpy.common.system.executive import ScriptError +from webkitpy.common.system.user import User from webkitpy.tool.steps.abstractstep import AbstractStep from webkitpy.tool.steps.options import Options @@ -35,13 +38,38 @@ class Commit(AbstractStep): def options(cls): return AbstractStep.options() + [ Options.git_commit, - Options.no_squash, - Options.squash, ] + def _commit_warning(self, error): + working_directory_message = "" if error.working_directory_is_clean else " and working copy changes" + return ('There are %s local commits%s. Everything will be committed as a single commit. ' + 'To avoid this prompt, set "git config webkit-patch.squash true".' % ( + error.num_local_commits, working_directory_message)) + def run(self, state): - commit_message = self._tool.checkout().commit_message_for_this_commit(self._options.git_commit, self._options.squash) - if len(commit_message.message()) < 50: + self._commit_message = self._tool.checkout().commit_message_for_this_commit(self._options.git_commit).message() + if len(self._commit_message) < 50: raise Exception("Attempted to commit with a commit message shorter than 50 characters. Either your patch is missing a ChangeLog or webkit-patch may have a bug.") - state["commit_text"] = self._tool.scm().commit_with_message(commit_message.message(), - git_commit=self._options.git_commit, squash=self._options.squash) + + self._state = state + + username = None + force_squash = False + + num_tries = 0 + while num_tries < 3: + num_tries += 1 + + try: + self._state["commit_text"] = self._tool.scm().commit_with_message(self._commit_message, git_commit=self._options.git_commit, username=username, force_squash=force_squash) + break; + except AmbiguousCommitError, e: + if self._tool.user.confirm(self._commit_warning(e)): + force_squash = True + else: + # This will correctly interrupt the rest of the commit process. + raise ScriptError(message="Did not commit") + except AuthenticationError, e: + username = self._tool.user.prompt("%s login: " % e.server_host, repeat=5) + if not username: + raise ScriptError("You need to specify the username on %s to perform the commit as." % self.svn_server_host) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/createbug.py b/WebKitTools/Scripts/webkitpy/tool/steps/createbug.py index cd043d6..0ab6f68 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/createbug.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/createbug.py @@ -36,6 +36,7 @@ class CreateBug(AbstractStep): return AbstractStep.options() + [ Options.cc, Options.component, + Options.blocks, ] def run(self, state): @@ -45,4 +46,7 @@ class CreateBug(AbstractStep): cc = self._options.cc if not cc: cc = state.get("bug_cc") - state["bug_id"] = self._tool.bugs.create_bug(state["bug_title"], state["bug_description"], blocked=state.get("bug_blocked"), component=self._options.component, cc=cc) + blocks = self._options.blocks + if not blocks: + blocks = state.get("bug_blocked") + state["bug_id"] = self._tool.bugs.create_bug(state["bug_title"], state["bug_description"], blocked=blocks, component=self._options.component, cc=cc) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/options.py b/WebKitTools/Scripts/webkitpy/tool/steps/options.py index fa36f73..9c73f5a 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/options.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/options.py @@ -29,6 +29,7 @@ from optparse import make_option class Options(object): + blocks = make_option("--blocks", action="store", dest="blocks", default=None, help="Bug number which the created bug blocks.") build = make_option("--build", action="store_true", dest="build", default=False, help="Build and run run-webkit-tests before committing.") build_style = make_option("--build-style", action="store", dest="build_style", default=None, help="Whether to build debug, release, or both.") cc = make_option("--cc", action="store", type="string", dest="cc", help="Comma-separated list of email addresses to carbon-copy.") @@ -42,11 +43,11 @@ class Options(object): description = make_option("-m", "--description", action="store", type="string", dest="description", help="Description string for the attachment (default: \"patch\")") email = make_option("--email", action="store", type="string", dest="email", help="Email address to use in ChangeLogs.") force_clean = make_option("--force-clean", action="store_true", dest="force_clean", default=False, help="Clean working directory before applying patches (removes local changes and commits)") -# FIXME: Make commit ranges treat each commit separately instead of squashing them into one. - git_commit = make_option("--git-commit", action="store", dest="git_commit", help="Local git commit to upload/land. If a range, the commits are squashed into one.") + git_commit = make_option("-g", "--git-commit", action="store", dest="git_commit", help="Operate on a local commit. If a range, the commits are squashed into one. HEAD.. operates on working copy changes only.") local_commit = make_option("--local-commit", action="store_true", dest="local_commit", default=False, help="Make a local commit for each applied patch") - no_squash = make_option("--no-squash", action="store_false", dest="squash", help="Don't squash local commits into one on upload/land (git-only).") non_interactive = make_option("--non-interactive", action="store_true", dest="non_interactive", default=False, help="Never prompt the user, fail as fast as possible.") + # FIXME: Remove --no-squash, once people have adjusted to using --git-commit. + no_squash = make_option("--no-squash", action="store_true", dest="no_squash", default=False, help="Obsolete. Use --git-commit=HEAD.. instead.") obsolete_patches = make_option("--no-obsolete", action="store_false", dest="obsolete_patches", default=True, help="Do not obsolete old patches before posting this one.") open_bug = make_option("--open-bug", action="store_true", dest="open_bug", default=False, help="Opens the associated bug in a browser.") parent_command = make_option("--parent-command", action="store", dest="parent_command", default=None, help="(Internal) The command that spawned this instance.") @@ -55,6 +56,7 @@ class Options(object): request_commit = make_option("--request-commit", action="store_true", dest="request_commit", default=False, help="Mark the patch as needing auto-commit after review.") review = make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review.") reviewer = make_option("-r", "--reviewer", action="store", type="string", dest="reviewer", help="Update ChangeLogs to say Reviewed by REVIEWER.") - squash = make_option("-s", "--squash", action="store_true", dest="squash", help="Squash all local commits into one on upload/land (git-only).") + # FIXME: Remove --squash, once people have adjusted to using --git-commit. + squash = make_option("-s", "--squash", action="store_true", dest="squash", default=False, help="Obsolete. This is now the default behavior.") test = make_option("--test", action="store_true", dest="test", default=False, help="Run run-webkit-tests before committing.") update = make_option("--no-update", action="store_false", dest="update", default=True, help="Don't update the working directory.") diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog.py b/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog.py index 7f0c1a8..ce04024 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog.py @@ -43,8 +43,6 @@ class PrepareChangeLog(AbstractStep): Options.quiet, Options.email, Options.git_commit, - Options.no_squash, - Options.squash, ] def _ensure_bug_url(self, state): @@ -69,10 +67,9 @@ class PrepareChangeLog(AbstractStep): args.append("--bug=%s" % state["bug_id"]) if self._options.email: args.append("--email=%s" % self._options.email) - if self._tool.scm().should_squash(self._options.squash): - args.append("--merge-base=%s" % self._tool.scm().remote_merge_base()) - if self._options.git_commit: - args.append("--git-commit=%s" % self._options.git_commit) + + if self._tool.scm().supports_local_commits(): + args.append("--merge-base=%s" % self._tool.scm().merge_base(self._options.git_commit)) try: self._tool.executive.run_and_throw_if_fail(args, self._options.quiet) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog_unittest.py index 1d0db75..eceffdf 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog_unittest.py @@ -31,15 +31,14 @@ import unittest from webkitpy.common.checkout.changelog_unittest import ChangeLogTest from webkitpy.common.system.outputcapture import OutputCapture -from webkitpy.thirdparty.mock import Mock -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool from webkitpy.tool.steps.preparechangelog import PrepareChangeLog class PrepareChangeLogTest(ChangeLogTest): def test_ensure_bug_url(self): capture = OutputCapture() - step = PrepareChangeLog(MockTool(), Mock()) + step = PrepareChangeLog(MockTool(), MockOptions()) changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog) changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8")) state = { diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py b/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py index 4d299fa..0e78bc2 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py @@ -36,7 +36,7 @@ class PrepareChangeLogForRevert(AbstractStep): def run(self, state): # This could move to prepare-ChangeLog by adding a --revert= option. self._run_script("prepare-ChangeLog") - changelog_paths = self._tool.checkout().modified_changelogs(git_commit=None, squash=False) + changelog_paths = self._tool.checkout().modified_changelogs(git_commit=None) bug_url = self._tool.bugs.bug_url_for_bug_id(state["bug_id"]) if state["bug_id"] else None for changelog_path in changelog_paths: # FIXME: Seems we should prepare the message outside of changelogs.py and then just pass in diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py index 1fd2bad..766801b 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py @@ -30,8 +30,7 @@ import unittest from webkitpy.common.system.outputcapture import OutputCapture from webkitpy.common.config.ports import WebKitPort -from webkitpy.thirdparty.mock import Mock -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool from webkitpy.tool.steps.update import Update from webkitpy.tool.steps.runtests import RunTests from webkitpy.tool.steps.promptforbugortitle import PromptForBugOrTitle @@ -42,13 +41,13 @@ class StepsTest(unittest.TestCase): if not tool: tool = MockTool() if not options: - options = Mock() + options = MockOptions() if not state: state = {} step(tool, options).run(state) def test_update_step(self): - options = Mock() + options = MockOptions() options.update = True expected_stderr = "Updating working directory\n" OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr) @@ -63,7 +62,7 @@ class StepsTest(unittest.TestCase): OutputCapture().assert_outputs(self, self._run_step, [RunTests], expected_stderr=expected_stderr) def test_runtests_leopard_commit_queue_hack(self): - mock_options = Mock() + mock_options = MockOptions() mock_options.non_interactive = True step = RunTests(MockTool(log_executive=True), mock_options) # FIXME: We shouldn't use a real port-object here, but there is too much to mock at the moment. diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py index 0534718..a037422 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py @@ -29,18 +29,17 @@ import unittest from webkitpy.common.system.outputcapture import OutputCapture -from webkitpy.thirdparty.mock import Mock -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool from webkitpy.tool.steps.updatechangelogswithreviewer import UpdateChangeLogsWithReviewer class UpdateChangeLogsWithReviewerTest(unittest.TestCase): def test_guess_reviewer_from_bug(self): capture = OutputCapture() - step = UpdateChangeLogsWithReviewer(MockTool(), Mock()) + step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions()) expected_stderr = "0 reviewed patches on bug 75, cannot infer reviewer.\n" capture.assert_outputs(self, step._guess_reviewer_from_bug, [75], expected_stderr=expected_stderr) def test_empty_state(self): capture = OutputCapture() - step = UpdateChangeLogsWithReviewer(MockTool(), Mock()) + step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions()) capture.assert_outputs(self, step.run, [{}]) diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py b/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py index ef4baa2..e46b790 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreviewer.py @@ -40,8 +40,6 @@ class UpdateChangeLogsWithReviewer(AbstractStep): return AbstractStep.options() + [ Options.git_commit, Options.reviewer, - Options.no_squash, - Options.squash, ] def _guess_reviewer_from_bug(self, bug_id): diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer.py b/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer.py index 9f4d44e..bdf729e 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer.py @@ -41,8 +41,6 @@ class ValidateReviewer(AbstractStep): def options(cls): return AbstractStep.options() + [ Options.git_commit, - Options.no_squash, - Options.squash, ] # FIXME: This should probably move onto ChangeLogEntry diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer_unittest.py index 9105102..d9b856a 100644 --- a/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer_unittest.py +++ b/WebKitTools/Scripts/webkitpy/tool/steps/validatereviewer_unittest.py @@ -30,8 +30,7 @@ import unittest from webkitpy.common.checkout.changelog import ChangeLogEntry from webkitpy.common.system.outputcapture import OutputCapture -from webkitpy.thirdparty.mock import Mock -from webkitpy.tool.mocktool import MockTool +from webkitpy.tool.mocktool import MockOptions, MockTool from webkitpy.tool.steps.validatereviewer import ValidateReviewer class ValidateReviewerTest(unittest.TestCase): @@ -48,7 +47,7 @@ class ValidateReviewerTest(unittest.TestCase): self.assertEqual(step._has_valid_reviewer(entry), expected) def test_has_valid_reviewer(self): - step = ValidateReviewer(MockTool(), Mock()) + step = ValidateReviewer(MockTool(), MockOptions()) self._test_review_text(step, "Reviewed by Eric Seidel.", True) self._test_review_text(step, "Reviewed by Eric Seidel", True) # Not picky about the '.' self._test_review_text(step, "Reviewed by Eric.", False) |