Commit aed0d47d authored by abarth@webkit.org's avatar abarth@webkit.org

2011-01-28 Adam Barth <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Add webkit-patch roll-chromium-deps
        https://bugs.webkit.org/show_bug.cgi?id=53288

        This command updates the Source/WebKit/chromium/DEPS file with the
        last-known good revision of Chromium (or a revision specified on the
        command line).  I'd eventually like to turn this into a SheriffBot
        command, but this is the first step.

        This patch somewhat sprawled because I needed to move a bunch of code
        out of ChangeLog that should never have been there in the first place.
        Also, I had to fix a bug in MockUser in order to test the new command.

        * Scripts/webkitpy/common/checkout/api.py:
        * Scripts/webkitpy/common/checkout/changelog.py:
        * Scripts/webkitpy/common/checkout/changelog_unittest.py:
        * Scripts/webkitpy/common/checkout/deps.py: Added.
        * Scripts/webkitpy/common/config/urls.py:
        * Scripts/webkitpy/tool/commands/__init__.py:
        * Scripts/webkitpy/tool/commands/download_unittest.py:
        * Scripts/webkitpy/tool/commands/roll.py: Added.
        * Scripts/webkitpy/tool/commands/roll_unittest.py: Added.
        * Scripts/webkitpy/tool/commands/upload_unittest.py:
        * Scripts/webkitpy/tool/mocktool.py:
        * Scripts/webkitpy/tool/steps/__init__.py:
        * Scripts/webkitpy/tool/steps/preparechangelogfordepsroll.py: Added.
        * Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
        * Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py: Added.
        * Scripts/webkitpy/tool/steps/suggestreviewers_unittest.py:
        * Scripts/webkitpy/tool/steps/updatechromiumdeps.py: Added.
        * Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f1a40a73
2011-01-28 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
Add webkit-patch roll-chromium-deps
https://bugs.webkit.org/show_bug.cgi?id=53288
This command updates the Source/WebKit/chromium/DEPS file with the
last-known good revision of Chromium (or a revision specified on the
command line). I'd eventually like to turn this into a SheriffBot
command, but this is the first step.
This patch somewhat sprawled because I needed to move a bunch of code
out of ChangeLog that should never have been there in the first place.
Also, I had to fix a bug in MockUser in order to test the new command.
* Scripts/webkitpy/common/checkout/api.py:
* Scripts/webkitpy/common/checkout/changelog.py:
* Scripts/webkitpy/common/checkout/changelog_unittest.py:
* Scripts/webkitpy/common/checkout/deps.py: Added.
* Scripts/webkitpy/common/config/urls.py:
* Scripts/webkitpy/tool/commands/__init__.py:
* Scripts/webkitpy/tool/commands/download_unittest.py:
* Scripts/webkitpy/tool/commands/roll.py: Added.
* Scripts/webkitpy/tool/commands/roll_unittest.py: Added.
* Scripts/webkitpy/tool/commands/upload_unittest.py:
* Scripts/webkitpy/tool/mocktool.py:
* Scripts/webkitpy/tool/steps/__init__.py:
* Scripts/webkitpy/tool/steps/preparechangelogfordepsroll.py: Added.
* Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
* Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py: Added.
* Scripts/webkitpy/tool/steps/suggestreviewers_unittest.py:
* Scripts/webkitpy/tool/steps/updatechromiumdeps.py: Added.
* Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py:
2011-01-27 Greg Coletta <greg.coletta@nokia.com>
Reviewed by Laszlo Gombos.
......@@ -33,6 +33,7 @@ from webkitpy.common.config import urls
from webkitpy.common.checkout.changelog import ChangeLog
from webkitpy.common.checkout.commitinfo import CommitInfo
from webkitpy.common.checkout.scm import CommitMessage
from webkitpy.common.checkout.deps import DEPS
from webkitpy.common.memoized import memoized
from webkitpy.common.net.bugzilla import parse_bug_id
from webkitpy.common.system.executive import Executive, run_command, ScriptError
......@@ -148,6 +149,9 @@ class Checkout(object):
except ScriptError, e:
pass # We might not have ChangeLogs.
def chromium_deps(self):
return DEPS(os.path.join(self._scm.checkout_root, "Source", "WebKit", "chromium", "DEPS"))
def apply_patch(self, patch, force=False):
# It's possible that the patch was not made from the root directory.
# We should detect and handle that case.
......
......@@ -36,9 +36,7 @@ import textwrap
from webkitpy.common.system.deprecated_logging import log
from webkitpy.common.config.committers import CommitterList
from webkitpy.common.config import urls
from webkitpy.common.net.bugzilla import parse_bug_id
from webkitpy.tool.grammar import join_with_separators
class ChangeLogEntry(object):
......@@ -145,29 +143,14 @@ class ChangeLog(object):
lines = [self._wrap_line(line) for line in message.splitlines()]
return "\n".join(lines)
# This probably does not belong in changelogs.py
def _message_for_revert(self, revision_list, reason, bug_url):
message = "Unreviewed, rolling out %s.\n" % join_with_separators(['r' + str(revision) for revision in revision_list])
for revision in revision_list:
message += "%s\n" % urls.view_revision_url(revision)
if bug_url:
message += "%s\n" % bug_url
# Add an extra new line after the rollout links, before any reason.
message += "\n"
if reason:
message += "%s\n\n" % reason
return self._wrap_lines(message)
def update_for_revert(self, revision_list, reason, bug_url=None):
def update_with_unreviewed_message(self, message):
reviewed_by_regexp = re.compile(
"%sReviewed by NOBODY \(OOPS!\)\." % self._changelog_indent)
removing_boilerplate = False
# inplace=1 creates a backup file and re-directs stdout to the file
for line in fileinput.FileInput(self.path, inplace=1):
if reviewed_by_regexp.search(line):
message_lines = self._message_for_revert(revision_list,
reason,
bug_url)
message_lines = self._wrap_lines(message)
print reviewed_by_regexp.sub(message_lines, line),
# Remove all the ChangeLog boilerplate between the Reviewed by
# line and the first changed file.
......
......@@ -142,89 +142,3 @@ class ChangeLogTest(unittest.TestCase):
expected_contents = changelog_contents.replace("Need a short description and bug URL (OOPS!)", expected_message)
os.remove(changelog_path)
self.assertEquals(actual_contents, expected_contents)
_revert_message = """ Unreviewed, rolling out r12345.
http://trac.webkit.org/changeset/12345
http://example.com/123
This is a very long reason which should be long enough so that
_message_for_revert will need to wrap it. We'll also include
a
https://veryveryveryveryverylongbugurl.com/reallylongbugthingy.cgi?bug_id=12354
link so that we can make sure we wrap that right too.
"""
def test_message_for_revert(self):
changelog = ChangeLog("/fake/path")
long_reason = "This is a very long reason which should be long enough so that _message_for_revert will need to wrap it. We'll also include a https://veryveryveryveryverylongbugurl.com/reallylongbugthingy.cgi?bug_id=12354 link so that we can make sure we wrap that right too."
message = changelog._message_for_revert([12345], long_reason, "http://example.com/123")
self.assertEquals(message, self._revert_message)
_revert_entry_with_bug_url = '''2009-08-19 Eric Seidel <eric@webkit.org>
Unreviewed, rolling out r12345.
http://trac.webkit.org/changeset/12345
http://example.com/123
Reason
* Scripts/bugzilla-tool:
'''
_revert_entry_without_bug_url = '''2009-08-19 Eric Seidel <eric@webkit.org>
Unreviewed, rolling out r12345.
http://trac.webkit.org/changeset/12345
Reason
* Scripts/bugzilla-tool:
'''
_multiple_revert_entry_with_bug_url = '''2009-08-19 Eric Seidel <eric@webkit.org>
Unreviewed, rolling out r12345, r12346, and r12347.
http://trac.webkit.org/changeset/12345
http://trac.webkit.org/changeset/12346
http://trac.webkit.org/changeset/12347
http://example.com/123
Reason
* Scripts/bugzilla-tool:
'''
_multiple_revert_entry_without_bug_url = '''2009-08-19 Eric Seidel <eric@webkit.org>
Unreviewed, rolling out r12345, r12346, and r12347.
http://trac.webkit.org/changeset/12345
http://trac.webkit.org/changeset/12346
http://trac.webkit.org/changeset/12347
Reason
* Scripts/bugzilla-tool:
'''
def _assert_update_for_revert_output(self, args, expected_entry):
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"))
changelog = ChangeLog(changelog_path)
changelog.update_for_revert(*args)
actual_entry = changelog.latest_entry()
os.remove(changelog_path)
self.assertEquals(actual_entry.contents(), expected_entry)
self.assertEquals(actual_entry.reviewer_text(), None)
# These checks could be removed to allow this to work on other entries:
self.assertEquals(actual_entry.author_name(), "Eric Seidel")
self.assertEquals(actual_entry.author_email(), "eric@webkit.org")
def test_update_for_revert(self):
self._assert_update_for_revert_output([[12345], "Reason"], self._revert_entry_without_bug_url)
self._assert_update_for_revert_output([[12345], "Reason", "http://example.com/123"], self._revert_entry_with_bug_url)
self._assert_update_for_revert_output([[12345, 12346, 12347], "Reason"], self._multiple_revert_entry_without_bug_url)
self._assert_update_for_revert_output([[12345, 12346, 12347], "Reason", "http://example.com/123"], self._multiple_revert_entry_with_bug_url)
if __name__ == '__main__':
unittest.main()
# Copyright (C) 2011, 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.
#
# WebKit's Python module for parsing and modifying ChangeLog files
import codecs
import fileinput
import os.path
import re
import textwrap
class DEPS(object):
_variable_regexp = r"\s+'%s':\s+'(?P<value>\d+)'"
def __init__(self, path):
self._path = path
def read_variable(self, name):
pattern = re.compile(self._variable_regexp % name)
for line in fileinput.FileInput(self._path):
match = pattern.match(line)
if match:
return int(match.group("value"))
def write_variable(self, name, value):
pattern = re.compile(self._variable_regexp % name)
replacement_line = " '%s': '%s'" % (name, value)
# inplace=1 creates a backup file and re-directs stdout to the file
for line in fileinput.FileInput(self._path, inplace=1):
if pattern.match(line):
print replacement_line
continue
# Trailing comma suppresses printing newline
print line,
......@@ -34,5 +34,6 @@ def view_source_url(local_path):
def view_revision_url(revision_number):
return "http://trac.webkit.org/changeset/%s" % revision_number
chromium_lkgr_url = "http://chromium-status.appspot.com/lkgr"
contribution_guidelines = "http://webkit.org/coding/contributing.html"
......@@ -10,5 +10,6 @@ from webkitpy.tool.commands.queries import *
from webkitpy.tool.commands.queues import *
from webkitpy.tool.commands.rebaseline import Rebaseline
from webkitpy.tool.commands.rebaselineserver import RebaselineServer
from webkitpy.tool.commands.roll import *
from webkitpy.tool.commands.sheriffbot import *
from webkitpy.tool.commands.upload import *
......@@ -32,7 +32,7 @@ from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.tool.mocktool import MockOptions, MockTool
class CommandsTest(unittest.TestCase):
def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=MockOptions(), tool=MockTool()):
def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", expected_exception=None, options=MockOptions(), tool=MockTool()):
options.blocks = None
options.cc = 'MOCK cc'
options.component = 'MOCK component'
......@@ -45,4 +45,4 @@ class CommandsTest(unittest.TestCase):
options.quiet = True
options.reviewer = 'MOCK reviewer'
command.bind_to_tool(tool)
OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr, expected_exception=expected_exception)
......@@ -200,7 +200,13 @@ where ATTACHMENT_ID is the ID of this attachment.
self.assert_execute_outputs(CreateRollout(), ["855 852 854", "Reason"], options=self._default_options(), expected_stderr=expected_stderr)
def test_rollout(self):
expected_stderr = "Preparing rollout for bug 42.\nUpdating working directory\nRunning prepare-ChangeLog\nMOCK: user.open_url: file://...\nBuilding WebKit\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\n"
expected_stdout = "Was that diff correct?\n"
self.assert_execute_outputs(Rollout(), [852, "Reason"], options=self._default_options(), expected_stdout=expected_stdout, expected_stderr=expected_stderr)
expected_stderr = """Preparing rollout for bug 42.
Updating working directory
Running prepare-ChangeLog
MOCK: user.open_url: file://...
Was that diff correct?
Building WebKit
Committed r49824: <http://trac.webkit.org/changeset/49824>
"""
self.assert_execute_outputs(Rollout(), [852, "Reason"], options=self._default_options(), expected_stderr=expected_stderr)
# Copyright (c) 2011 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.
from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
import webkitpy.tool.steps as steps
class RollChromiumDEPS(AbstractSequencedCommand):
name = "roll-chromium-deps"
help_text = "Updates Chromium DEPS (defaults to the last-known good revision of Chromium)"
argument_names = "[CHROMIUM_REVISION]"
steps = [
steps.UpdateChromiumDEPS,
steps.PrepareChangeLogForDEPSRoll,
steps.ConfirmDiff,
steps.Commit,
]
def _prepare_state(self, options, args, tool):
return {
"chromium_revision": (args and args[0]),
}
# Copyright (C) 2011 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.
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.commands.commandtest import CommandsTest
from webkitpy.tool.commands.roll import *
from webkitpy.tool.mocktool import MockOptions, MockTool
class RollCommandsTest(CommandsTest):
def test_update_chromium_deps(self):
expected_stderr = """Updating Chromium DEPS to 6764
MOCK: MockDEPS.write_variable(chromium_rev, 6764)
Running prepare-ChangeLog
MOCK: user.open_url: file://...
Was that diff correct?
Committed r49824: <http://trac.webkit.org/changeset/49824>
"""
self.assert_execute_outputs(RollChromiumDEPS(), [6764], expected_stderr=expected_stderr)
def test_update_chromium_deps_older_revision(self):
expected_stderr = """Current Chromium DEPS revision 6564 is newer than 5764.
ERROR: Unable to update Chromium DEPS
"""
self.assert_execute_outputs(RollChromiumDEPS(), [5764], expected_stderr=expected_stderr, expected_exception=SystemExit)
......@@ -61,12 +61,12 @@ class UploadCommandsTest(CommandsTest):
options.suggest_reviewers = False
expected_stderr = """Running check-webkit-style
MOCK: user.open_url: file://...
Was that diff correct?
Obsoleting 2 old patches on bug 42
MOCK add_patch_to_bug: bug_id=42, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
MOCK: user.open_url: http://example.com/42
"""
expected_stdout = "Was that diff correct?\n"
self.assert_execute_outputs(Post(), [42], options=options, expected_stdout=expected_stdout, expected_stderr=expected_stderr)
self.assert_execute_outputs(Post(), [42], options=options, expected_stderr=expected_stderr)
def test_land_safely(self):
expected_stderr = "Obsoleting 2 old patches on bug 42\nMOCK add_patch_to_bug: bug_id=42, description=Patch for landing, mark_for_review=False, mark_for_commit_queue=False, mark_for_landing=True\n"
......@@ -90,12 +90,12 @@ MOCK: user.open_url: http://example.com/42
options.suggest_reviewers = False
expected_stderr = """Running check-webkit-style
MOCK: user.open_url: file://...
Was that diff correct?
Obsoleting 2 old patches on bug 42
MOCK add_patch_to_bug: bug_id=42, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
MOCK: user.open_url: http://example.com/42
"""
expected_stdout = "Was that diff correct?\n"
self.assert_execute_outputs(Upload(), [42], options=options, expected_stdout=expected_stdout, expected_stderr=expected_stderr)
self.assert_execute_outputs(Upload(), [42], options=options, expected_stderr=expected_stderr)
def test_mark_bug_fixed(self):
tool = MockTool()
......@@ -106,6 +106,7 @@ MOCK: user.open_url: http://example.com/42
expected_stderr = """Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.
Revision: 9876
MOCK: user.open_url: http://example.com/42
Is this correct?
Adding comment to Bug 42.
MOCK bug comment: bug_id=42, cc=None
--- Begin comment ---
......@@ -115,8 +116,7 @@ Committed r9876: <http://trac.webkit.org/changeset/9876>
--- End comment ---
"""
expected_stdout = "Is this correct?\n"
self.assert_execute_outputs(MarkBugFixed(), [], expected_stdout=expected_stdout, expected_stderr=expected_stderr, tool=tool, options=options)
self.assert_execute_outputs(MarkBugFixed(), [], expected_stderr=expected_stderr, tool=tool, options=options)
def test_edit_changelog(self):
self.assert_execute_outputs(EditChangeLogs(), [])
......@@ -495,6 +495,14 @@ class MockSCM(Mock):
return 0
class MockDEPS(object):
def read_variable(self, name):
return 6564
def write_variable(self, name, value):
log("MOCK: MockDEPS.write_variable(%s, %s)" % (name, value))
class MockCheckout(object):
_committer_list = CommitterList()
......@@ -528,6 +536,9 @@ class MockCheckout(object):
commit_message.message = lambda:"This is a fake commit message that is at least 50 characters."
return commit_message
def chromium_deps(self):
return MockDEPS()
def apply_patch(self, patch, force=False):
pass
......@@ -561,7 +572,7 @@ class MockUser(object):
pass
def confirm(self, message=None, default='y'):
print message
log(message)
return default == 'y'
def can_open_url(self):
......
......@@ -47,6 +47,7 @@ from webkitpy.tool.steps.options import Options
from webkitpy.tool.steps.postdiff import PostDiff
from webkitpy.tool.steps.postdiffforcommit import PostDiffForCommit
from webkitpy.tool.steps.postdiffforrevert import PostDiffForRevert
from webkitpy.tool.steps.preparechangelogfordepsroll import PrepareChangeLogForDEPSRoll
from webkitpy.tool.steps.preparechangelogforrevert import PrepareChangeLogForRevert
from webkitpy.tool.steps.preparechangelog import PrepareChangeLog
from webkitpy.tool.steps.promptforbugortitle import PromptForBugOrTitle
......@@ -55,6 +56,7 @@ from webkitpy.tool.steps.revertrevision import RevertRevision
from webkitpy.tool.steps.runtests import RunTests
from webkitpy.tool.steps.suggestreviewers import SuggestReviewers
from webkitpy.tool.steps.updatechangelogswithreviewer import UpdateChangeLogsWithReviewer
from webkitpy.tool.steps.updatechromiumdeps import UpdateChromiumDEPS
from webkitpy.tool.steps.update import Update
from webkitpy.tool.steps.validatechangelogs import ValidateChangeLogs
from webkitpy.tool.steps.validatereviewer import ValidateReviewer
# Copyright (C) 2011 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 os
from webkitpy.common.checkout.changelog import ChangeLog
from webkitpy.tool.steps.abstractstep import AbstractStep
class PrepareChangeLogForDEPSRoll(AbstractStep):
def run(self, state):
self._run_script("prepare-ChangeLog")
changelog_paths = self._tool.checkout().modified_changelogs(git_commit=None)
for changelog_path in changelog_paths:
ChangeLog(changelog_path).update_with_unreviewed_message("Rolled DEPS.\n\n")
......@@ -29,16 +29,32 @@
import os
from webkitpy.common.checkout.changelog import ChangeLog
from webkitpy.common.config import urls
from webkitpy.tool.grammar import join_with_separators
from webkitpy.tool.steps.abstractstep import AbstractStep
class PrepareChangeLogForRevert(AbstractStep):
@classmethod
def _message_for_revert(cls, revision_list, reason, bug_url=None):
message = "Unreviewed, rolling out %s.\n" % join_with_separators(['r' + str(revision) for revision in revision_list])
for revision in revision_list:
message += "%s\n" % urls.view_revision_url(revision)
if bug_url:
message += "%s\n" % bug_url
# Add an extra new line after the rollout links, before any reason.
message += "\n"
if reason:
message += "%s\n\n" % reason
return message
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)
bug_url = self._tool.bugs.bug_url_for_bug_id(state["bug_id"]) if state["bug_id"] else None
message = self._message_for_revert(state["revision_list"], state["reason"], bug_url)
for changelog_path in changelog_paths:
# FIXME: Seems we should prepare the message outside of changelogs.py and then just pass in
# text that we want to use to replace the reviewed by line.
ChangeLog(changelog_path).update_for_revert(state["revision_list"], state["reason"], bug_url)
ChangeLog(changelog_path).update_with_unreviewed_message(message)
# Copyright (C) 2011 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.
from __future__ import with_statement
import codecs
import os
import tempfile
import unittest
from webkitpy.common.checkout.changelog import ChangeLog
from webkitpy.common.checkout.changelog_unittest import ChangeLogTest
from webkitpy.tool.steps.preparechangelogforrevert import *
class UpdateChangeLogsForRevertTest(unittest.TestCase):
@staticmethod