[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:51:07 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 73101cd75cb936c2f622b9c91fcdb890f956fa60
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 28 17:06:28 2009 +0000

    2009-12-28  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            [bzt] Create an ASAD command for uploading a patch
            https://bugs.webkit.org/show_bug.cgi?id=32979
    
            The create-review command goes through the whole process of preparing a
            code review, including creating a bug, editing the ChangeLogs, and
            uploading the patch.  It is indeed the All Sing, All Dance upload
            command.
    
            * Scripts/modules/buildsteps.py:
            * Scripts/modules/commands/upload.py:
            * Scripts/modules/commands/upload_unittest.py:
            * Scripts/modules/mock_bugzillatool.py:
            * Scripts/modules/user.py:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52599 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 310eef4..08aa6e2 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,23 @@
 2009-12-28  Adam Barth  <abarth at webkit.org>
 
+        Reviewed by Eric Seidel.
+
+        [bzt] Create an ASAD command for uploading a patch
+        https://bugs.webkit.org/show_bug.cgi?id=32979
+
+        The create-review command goes through the whole process of preparing a
+        code review, including creating a bug, editing the ChangeLogs, and
+        uploading the patch.  It is indeed the All Sing, All Dance upload
+        command.
+
+        * Scripts/modules/buildsteps.py:
+        * Scripts/modules/commands/upload.py:
+        * Scripts/modules/commands/upload_unittest.py:
+        * Scripts/modules/mock_bugzillatool.py:
+        * Scripts/modules/user.py:
+
+2009-12-28  Adam Barth  <abarth at webkit.org>
+
         Unreviewed "build" fix (with test!).
 
         * Scripts/modules/bugzilla.py:
diff --git a/WebKitTools/Scripts/modules/buildsteps.py b/WebKitTools/Scripts/modules/buildsteps.py
index e8d151b..338376d 100644
--- a/WebKitTools/Scripts/modules/buildsteps.py
+++ b/WebKitTools/Scripts/modules/buildsteps.py
@@ -59,6 +59,7 @@ class CommandOptions(object):
     description = make_option("-m", "--description", action="store", type="string", dest="description", help="Description string for the attachment (default: \"patch\")")
     cc = make_option("--cc", action="store", type="string", dest="cc", help="Comma-separated list of email addresses to carbon-copy.")
     component = make_option("--component", action="store", type="string", dest="component", help="Component for the new bug.")
+    confirm = make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Skip confirmation steps.")
 
 
 class AbstractStep(object):
@@ -160,6 +161,11 @@ class PrepareChangeLogStep(AbstractStep):
         self._tool.executive.run_and_throw_if_fail(args, self._options.quiet)
 
 
+class EditChangeLogStep(AbstractStep):
+    def run(self, state):
+        self._tool.user.edit(self._tool.scm().modified_changelogs())
+
+
 class ObsoletePatchesOnBugStep(AbstractStep):
     @classmethod
     def options(cls):
@@ -179,7 +185,32 @@ class ObsoletePatchesOnBugStep(AbstractStep):
             self._tool.bugs.obsolete_attachment(patch["id"])
 
 
-class PostDiffToBugStep(AbstractStep):
+class AbstractDiffStep(AbstractStep):
+    def diff(self, state):
+        diff = state.get("diff")
+        if not diff:
+            diff = self._tool.scm().create_patch()
+            state["diff"] = diff
+        return diff
+
+
+class ConfirmDiffStep(AbstractDiffStep):
+    @classmethod
+    def options(cls):
+        return [
+            CommandOptions.confirm,
+        ]
+
+    def run(self, state):
+        if not self._options.confirm:
+            return
+        diff = self.diff(state)
+        self._tool.user.page(diff)
+        if not self._tool.user.confirm():
+            error("User declined to continue.")
+
+
+class PostDiffToBugStep(AbstractDiffStep):
     @classmethod
     def options(cls):
         return [
@@ -189,7 +220,7 @@ class PostDiffToBugStep(AbstractStep):
         ]
 
     def run(self, state):
-        diff = state.get("diff") or self._tool.scm().create_patch()
+        diff = self.diff(state)
         diff_file = StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object
         description = self._options.description or "Patch"
         self._tool.bugs.add_patch_to_bug(state["bug_id"], diff_file, description, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit)
diff --git a/WebKitTools/Scripts/modules/commands/upload.py b/WebKitTools/Scripts/modules/commands/upload.py
index 98d3ee9..a8619c0 100644
--- a/WebKitTools/Scripts/modules/commands/upload.py
+++ b/WebKitTools/Scripts/modules/commands/upload.py
@@ -36,7 +36,7 @@ import sys
 from optparse import make_option
 
 from modules.bugzilla import parse_bug_id
-from modules.buildsteps import PrepareChangeLogStep, CommandOptions, ObsoletePatchesOnBugStep, PostDiffToBugStep, PromptForBugOrTitleStep, CreateBugStep
+from modules.buildsteps import PrepareChangeLogStep, EditChangeLogStep, ConfirmDiffStep, CommandOptions, ObsoletePatchesOnBugStep, PostDiffToBugStep, PromptForBugOrTitleStep, CreateBugStep
 from modules.commands.download import AbstractSequencedCommmand
 from modules.comments import bug_comment_from_svn_revision
 from modules.grammar import pluralize
@@ -72,6 +72,7 @@ class PostDiff(AbstractSequencedCommmand):
     argument_names = "[BUGID]"
     show_in_main_help = True
     steps = [
+        ConfirmDiffStep,
         ObsoletePatchesOnBugStep,
         PostDiffToBugStep,
     ]
@@ -104,6 +105,25 @@ class PrepareDiff(AbstractSequencedCommmand):
         return { "bug_id" : bug_id }
 
 
+class CreateReview(AbstractSequencedCommmand):
+    name = "create-review"
+    help_text = "Adds a ChangeLog to the current diff and posts it to a (possibly new) bug"
+    argument_names = "[BUGID]"
+    steps = [
+        PromptForBugOrTitleStep,
+        CreateBugStep,
+        PrepareChangeLogStep,
+        EditChangeLogStep,
+        ConfirmDiffStep,
+        ObsoletePatchesOnBugStep,
+        PostDiffToBugStep,
+    ]
+
+    def _prepare_state(self, options, args, tool):
+        bug_id = args and args[0]
+        return { "bug_id" : bug_id }
+
+
 class PostCommits(Command):
     name = "post-commits"
     show_in_main_help = True
diff --git a/WebKitTools/Scripts/modules/commands/upload_unittest.py b/WebKitTools/Scripts/modules/commands/upload_unittest.py
index 1dd01d1..37f2d4d 100644
--- a/WebKitTools/Scripts/modules/commands/upload_unittest.py
+++ b/WebKitTools/Scripts/modules/commands/upload_unittest.py
@@ -45,3 +45,7 @@ class UploadCommandsTest(CommandsTest):
 
     def test_prepare_diff(self):
         self.assert_execute_outputs(PrepareDiff(), [])
+
+    def test_create_review(self):
+        expected_stderr = "Obsoleting 2 old patches on bug 42\n"
+        self.assert_execute_outputs(CreateReview(), [42], expected_stderr=expected_stderr)
diff --git a/WebKitTools/Scripts/modules/mock_bugzillatool.py b/WebKitTools/Scripts/modules/mock_bugzillatool.py
index 29a4f05..0f396d0 100644
--- a/WebKitTools/Scripts/modules/mock_bugzillatool.py
+++ b/WebKitTools/Scripts/modules/mock_bugzillatool.py
@@ -147,6 +147,15 @@ class MockUser(object):
     def prompt(self, message):
         return "Mock user response"
 
+    def edit(self, files):
+        pass
+
+    def page(self, message):
+        pass
+
+    def confirm(self):
+        return True
+
 
 class MockStatusBot(object):
     def __init__(self):
diff --git a/WebKitTools/Scripts/modules/user.py b/WebKitTools/Scripts/modules/user.py
index 1b023f4..8b72673 100644
--- a/WebKitTools/Scripts/modules/user.py
+++ b/WebKitTools/Scripts/modules/user.py
@@ -26,6 +26,22 @@
 # (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
+import subprocess
+
 class User(object):
     def prompt(self, message):
         return raw_input(message)
+
+    def edit(self, files):
+        editor = os.environ.get("EDITOR") or "vi"
+        subprocess.call([editor] + files)
+
+    def page(self, message):
+        pager = os.environ.get("PAGER") or "less"
+        child_process = subprocess.Popen([pager], stdin=subprocess.PIPE)
+        child_process.communicate(input=message)
+
+    def confirm(self):
+        response = raw_input("\nContinue? [Y/n]: ")
+        return not response or response.lower() == "y"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list