Commit fb19322c authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

Renaming CleanWorkingDirectory step to DiscardLocalChanges to make

functionality match the name.
https://bugs.webkit.org/show_bug.cgi?id=106870

Patch by Tim 'mithro' Ansell <mithro@mithis.com> on 2013-01-15
Reviewed by Adam Barth.

* Scripts/webkitpy/tool/commands/download.py:
(Clean):
(Update):
(Build):
(BuildAndTest):
(CheckStyle):
(BuildAttachment):
(BuildAndTestAttachment):
(AbstractPatchApplyingCommand):
(ApplyWatchList):
(AbstractPatchLandingCommand):
(CreateRollout):
* Scripts/webkitpy/tool/steps/__init__.py:
* Scripts/webkitpy/tool/steps/cleanworkingdirectory.py:
(CleanWorkingDirectory.options):
(CleanWorkingDirectory.run):
* Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py:
* Scripts/webkitpy/tool/steps/discardlocalchanges.py: Copied from Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory.py.
* Scripts/webkitpy/tool/steps/discardlocalchanges_unittest.py: Copied from Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@139771 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 37eb0350
2013-01-15 Tim 'mithro' Ansell <mithro@mithis.com>
Renaming CleanWorkingDirectory step to DiscardLocalChanges to make
functionality match the name.
https://bugs.webkit.org/show_bug.cgi?id=106870
Reviewed by Adam Barth.
* Scripts/webkitpy/tool/commands/download.py:
(Clean):
(Update):
(Build):
(BuildAndTest):
(CheckStyle):
(BuildAttachment):
(BuildAndTestAttachment):
(AbstractPatchApplyingCommand):
(ApplyWatchList):
(AbstractPatchLandingCommand):
(CreateRollout):
* Scripts/webkitpy/tool/steps/__init__.py:
* Scripts/webkitpy/tool/steps/cleanworkingdirectory.py:
(CleanWorkingDirectory.options):
(CleanWorkingDirectory.run):
* Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py:
* Scripts/webkitpy/tool/steps/discardlocalchanges.py: Copied from Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory.py.
* Scripts/webkitpy/tool/steps/discardlocalchanges_unittest.py: Copied from Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py.
2013-01-15 Zan Dobersek <zandobersek@gmail.com>
 
[Autotools] Add support for WebKit2-only builds
......
......@@ -47,7 +47,7 @@ class Clean(AbstractSequencedCommand):
name = "clean"
help_text = "Clean the working copy"
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
]
def _prepare_state(self, options, args, tool):
......@@ -58,7 +58,7 @@ class Update(AbstractSequencedCommand):
name = "update"
help_text = "Update working copy (used internally)"
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
]
......@@ -67,7 +67,7 @@ class Build(AbstractSequencedCommand):
name = "build"
help_text = "Update working copy and build"
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.Build,
]
......@@ -80,7 +80,7 @@ class BuildAndTest(AbstractSequencedCommand):
name = "build-and-test"
help_text = "Update working copy, build, and run the tests"
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.Build,
steps.RunTests,
......@@ -235,7 +235,7 @@ class CheckStyle(AbstractPatchSequencingCommand, ProcessAttachmentsMixin):
help_text = "Run check-webkit-style on the specified attachments"
argument_names = "ATTACHMENT_ID [ATTACHMENT_IDS]"
main_steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.ApplyPatch,
steps.CheckStyle,
......@@ -247,7 +247,7 @@ class BuildAttachment(AbstractPatchSequencingCommand, ProcessAttachmentsMixin):
help_text = "Apply and build patches from bugzilla"
argument_names = "ATTACHMENT_ID [ATTACHMENT_IDS]"
main_steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.ApplyPatch,
steps.Build,
......@@ -259,7 +259,7 @@ class BuildAndTestAttachment(AbstractPatchSequencingCommand, ProcessAttachmentsM
help_text = "Apply, build, and test patches from bugzilla"
argument_names = "ATTACHMENT_ID [ATTACHMENT_IDS]"
main_steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.ApplyPatch,
steps.Build,
......@@ -270,7 +270,7 @@ class BuildAndTestAttachment(AbstractPatchSequencingCommand, ProcessAttachmentsM
class AbstractPatchApplyingCommand(AbstractPatchSequencingCommand):
prepare_steps = [
steps.EnsureLocalCommitIfNeeded,
steps.CleanWorkingDirectoryWithLocalCommits,
steps.CleanWorkingDirectory,
steps.Update,
]
main_steps = [
......@@ -299,7 +299,7 @@ class ApplyWatchList(AbstractPatchSequencingCommand, ProcessAttachmentsMixin):
help_text = "Applies the watchlist to the specified attachments"
argument_names = "ATTACHMENT_ID [ATTACHMENT_IDS]"
main_steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.ApplyPatch,
steps.ApplyWatchList,
......@@ -310,7 +310,7 @@ Downloads the attachment, applies it locally, runs the watchlist against it, and
class AbstractPatchLandingCommand(AbstractPatchSequencingCommand):
main_steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.ApplyPatch,
steps.ValidateChangeLogs,
......@@ -413,7 +413,7 @@ Applies the inverse diff for the provided revision(s).
Creates an appropriate rollout ChangeLog, including a trac link and bug link.
"""
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.RevertRevision,
steps.PrepareChangeLogForRevert,
......@@ -424,7 +424,7 @@ class CreateRollout(AbstractRolloutPrepCommand):
name = "create-rollout"
help_text = "Creates a bug to track the broken SVN revision(s) and uploads a rollout patch."
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.RevertRevision,
steps.CreateBug,
......@@ -470,7 +470,7 @@ Opens the generated ChangeLogs in $EDITOR.
Shows the prepared diff for confirmation.
Commits the revert and updates the bug (including re-opening the bug if necessary)."""
steps = [
steps.CleanWorkingDirectory,
steps.DiscardLocalChanges,
steps.Update,
steps.RevertRevision,
steps.PrepareChangeLogForRevert,
......
......@@ -35,13 +35,13 @@ from webkitpy.tool.steps.attachtobug import AttachToBug
from webkitpy.tool.steps.build import Build
from webkitpy.tool.steps.checkstyle import CheckStyle
from webkitpy.tool.steps.cleanworkingdirectory import CleanWorkingDirectory
from webkitpy.tool.steps.cleanworkingdirectorywithlocalcommits import CleanWorkingDirectoryWithLocalCommits
from webkitpy.tool.steps.closebug import CloseBug
from webkitpy.tool.steps.closebugforlanddiff import CloseBugForLandDiff
from webkitpy.tool.steps.closepatch import ClosePatch
from webkitpy.tool.steps.commit import Commit
from webkitpy.tool.steps.confirmdiff import ConfirmDiff
from webkitpy.tool.steps.createbug import CreateBug
from webkitpy.tool.steps.discardlocalchanges import DiscardLocalChanges
from webkitpy.tool.steps.editchangelog import EditChangeLog
from webkitpy.tool.steps.ensurebugisopenandassigned import EnsureBugIsOpenAndAssigned
from webkitpy.tool.steps.ensurelocalcommitifneeded import EnsureLocalCommitIfNeeded
......
......@@ -32,9 +32,6 @@ from webkitpy.common.system.executive import ScriptError
class CleanWorkingDirectory(AbstractStep):
def __init__(self, tool, options, allow_local_commits=False):
AbstractStep.__init__(self, tool, options)
self._allow_local_commits = allow_local_commits
@classmethod
def options(cls):
......@@ -46,10 +43,8 @@ class CleanWorkingDirectory(AbstractStep):
def run(self, state):
if not self._options.clean:
return
if not self._allow_local_commits:
if self._tool.scm().has_local_commits() and not self._options.force_clean:
raise ScriptError("Repository has local commits, pass --force-clean to continue.")
self._tool.scm().discard_local_commits()
if self._tool.scm().has_working_directory_changes() and not self._options.force_clean:
raise ScriptError("Working directory has changes, pass --force-clean to continue.")
self._tool.scm().discard_working_directory_changes()
......@@ -41,16 +41,6 @@ class CleanWorkingDirectoryTest(unittest.TestCase):
step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=False))
tool._scm.has_working_directory_changes = lambda: True
self.assertRaises(ScriptError, step.run, {})
self.assertEqual(tool._scm.discard_local_commits.call_count, 0)
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 0)
def test_run_local_commits_no_force(self):
tool = MockTool()
tool._scm = Mock()
step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=False))
tool._scm.has_local_commits = lambda: True
self.assertRaises(ScriptError, step.run, {})
self.assertEqual(tool._scm.discard_local_commits.call_count, 0)
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 0)
def test_run_working_directory_changes_force(self):
......@@ -59,16 +49,6 @@ class CleanWorkingDirectoryTest(unittest.TestCase):
step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=True))
tool._scm.has_working_directory_changes = lambda: True
step.run({})
self.assertEqual(tool._scm.discard_local_commits.call_count, 1)
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 1)
def test_run_local_commits_force(self):
tool = MockTool()
tool._scm = Mock()
step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=True))
tool._scm.has_local_commits = lambda: True
step.run({})
self.assertEqual(tool._scm.discard_local_commits.call_count, 1)
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 1)
def test_run_no_local_changes(self):
......@@ -78,7 +58,6 @@ class CleanWorkingDirectoryTest(unittest.TestCase):
tool._scm.has_working_directory_changes = lambda: False
tool._scm.has_local_commits = lambda: False
step.run({})
self.assertEqual(tool._scm.discard_local_commits.call_count, 1)
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 1)
def test_no_clean(self):
......@@ -86,5 +65,4 @@ class CleanWorkingDirectoryTest(unittest.TestCase):
tool._scm = Mock()
step = CleanWorkingDirectory(tool, MockOptions(clean=False))
step.run({})
self.assertEqual(tool._scm.discard_local_commits.call_count, 0)
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 0)
# Copyright (C) 2010 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
......@@ -13,7 +13,7 @@
# * 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
......@@ -26,9 +26,27 @@
# (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.steps.cleanworkingdirectory import CleanWorkingDirectory
from webkitpy.tool.steps.abstractstep import AbstractStep
from webkitpy.tool.steps.options import Options
from webkitpy.common.system.executive import ScriptError
class CleanWorkingDirectoryWithLocalCommits(CleanWorkingDirectory):
def __init__(self, tool, options):
# FIXME: This a bit of a hack. Consider doing this more cleanly.
CleanWorkingDirectory.__init__(self, tool, options, allow_local_commits=True)
class DiscardLocalChanges(AbstractStep):
@classmethod
def options(cls):
return AbstractStep.options() + [
Options.clean,
Options.force_clean,
]
def run(self, state):
if not self._options.clean:
return
if not self._options.force_clean:
if self._tool.scm().has_working_directory_changes():
raise ScriptError("Working directory has changes, pass --force-clean to continue.")
if self._tool.scm().has_local_commits():
raise ScriptError("Repository has local commits, pass --force-clean to continue.")
self._tool.scm().discard_local_changes()
# Copyright (C) 2010 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.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockOptions, MockTool
from webkitpy.tool.steps.discardlocalchanges import DiscardLocalChanges
from webkitpy.common.system.executive import ScriptError
class DiscardLocalChangesTest(unittest.TestCase):
def test_skip_on_clean(self):
tool = MockTool()
tool._scm = Mock()
step = DiscardLocalChanges(tool, MockOptions(clean=False))
step.run({})
self.assertEqual(tool._scm.discard_local_changes.call_count, 0)
def test_working_changes_exist_with_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: True
tool._scm.has_local_commits = lambda: False
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
step.run({})
self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
def test_local_commits_exist_with_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: False
tool._scm.has_local_commits = lambda: True
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
step.run({})
self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
def test_local_commits_and_working_changes_exist_with_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: True
tool._scm.has_local_commits = lambda: True
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
step.run({})
self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
def test_no_changes_exist_with_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: False
tool._scm.has_local_commits = lambda: False
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
step.run({})
self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
def test_error_working_changes_exist_without_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: True
tool._scm.has_local_commits = lambda: False
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=False))
self.assertRaises(ScriptError, step.run, {})
self.assertEqual(tool._scm.discard_local_changes.call_count, 0)
def test_error_local_commits_exist_without_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: False
tool._scm.has_local_commits = lambda: True
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=False))
self.assertRaises(ScriptError, step.run, {})
self.assertEqual(tool._scm.discard_local_changes.call_count, 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