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

abarth at webkit.org abarth at webkit.org
Thu Apr 8 00:36:07 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit e5822650a30dc92bc143c6ef372654e7dd427714
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 15 05:21:33 2009 +0000

    2009-12-14  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            [bzt] Kill LandingSequence
            https://bugs.webkit.org/show_bug.cgi?id=32464
    
            Removes LandingSequence in favor of StepSequence.  This required
            changing the Step API slightly to carry a general notion of state
            instead of carrying patches specifically.
    
            * Scripts/modules/buildsteps.py:
            * Scripts/modules/commands/download.py:
            * Scripts/modules/commands/queues.py:
            * Scripts/modules/landingsequence.py: Removed.
            * Scripts/modules/stepsequence.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52129 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 741c681..17cda56 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,20 @@
+2009-12-14  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        [bzt] Kill LandingSequence
+        https://bugs.webkit.org/show_bug.cgi?id=32464
+
+        Removes LandingSequence in favor of StepSequence.  This required
+        changing the Step API slightly to carry a general notion of state
+        instead of carrying patches specifically.
+
+        * Scripts/modules/buildsteps.py:
+        * Scripts/modules/commands/download.py:
+        * Scripts/modules/commands/queues.py:
+        * Scripts/modules/landingsequence.py: Removed.
+        * Scripts/modules/stepsequence.py:
+
 2009-12-14  Robert Hogan  <robert at roberthogan.net>
 
         Reviewed by Eric Seidel.
diff --git a/WebKitTools/Scripts/modules/buildsteps.py b/WebKitTools/Scripts/modules/buildsteps.py
index 425b912..d08f635 100644
--- a/WebKitTools/Scripts/modules/buildsteps.py
+++ b/WebKitTools/Scripts/modules/buildsteps.py
@@ -47,13 +47,13 @@ class CommandOptions(object):
     test = make_option("--no-test", action="store_false", dest="test", default=True, help="Commit without running run-webkit-tests.")
     close_bug = make_option("--no-close", action="store_false", dest="close_bug", default=True, help="Leave bug open after landing.")
     port = make_option("--port", action="store", dest="port", default=None, help="Specify a port (e.g., mac, qt, gtk, ...).")
+    reviewer = make_option("-r", "--reviewer", action="store", type="string", dest="reviewer", help="Update ChangeLogs to say Reviewed by REVIEWER.")
 
 
 class AbstractStep(object):
-    def __init__(self, tool, options, patch=None):
+    def __init__(self, tool, options):
         self._tool = tool
         self._options = options
-        self._patch = patch
         self._port = None
 
     def _run_script(self, script_name, quiet=False, port=WebKitPort):
@@ -71,18 +71,18 @@ class AbstractStep(object):
     def options(cls):
         return []
 
-    def run(self, tool):
+    def run(self, state):
         raise NotImplementedError, "subclasses must implement"
 
 
 class PrepareChangelogStep(AbstractStep):
-    def run(self):
+    def run(self, state):
         self._run_script("prepare-ChangeLog")
 
 
 class CleanWorkingDirectoryStep(AbstractStep):
-    def __init__(self, tool, options, patch=None, allow_local_commits=False):
-        AbstractStep.__init__(self, tool, options, patch)
+    def __init__(self, tool, options, allow_local_commits=False):
+        AbstractStep.__init__(self, tool, options)
         self._allow_local_commits = allow_local_commits
 
     @classmethod
@@ -92,7 +92,7 @@ class CleanWorkingDirectoryStep(AbstractStep):
             CommandOptions.clean,
         ]
 
-    def run(self):
+    def run(self, state):
         os.chdir(self._tool.scm().checkout_root)
         if not self._allow_local_commits:
             self._tool.scm().ensure_no_local_commits(self._options.force_clean)
@@ -108,7 +108,7 @@ class UpdateStep(AbstractStep):
             CommandOptions.port,
         ]
 
-    def run(self):
+    def run(self, state):
         if not self._options.update:
             return
         log("Updating working directory")
@@ -122,9 +122,9 @@ class ApplyPatchStep(AbstractStep):
             CommandOptions.non_interactive,
         ]
 
-    def run(self):
-        log("Processing patch %s from bug %s." % (self._patch["id"], self._patch["bug_id"]))
-        self._tool.scm().apply_patch(self._patch, force=self._options.non_interactive)
+    def run(self, state):
+        log("Processing patch %s from bug %s." % (state["patch"]["id"], state["patch"]["bug_id"]))
+        self._tool.scm().apply_patch(state["patch"], force=self._options.non_interactive)
 
 
 class EnsureBuildersAreGreenStep(AbstractStep):
@@ -134,7 +134,7 @@ class EnsureBuildersAreGreenStep(AbstractStep):
             CommandOptions.check_builders,
         ]
 
-    def run(self):
+    def run(self, state):
         if not self._options.check_builders:
             return
         red_builders_names = self._tool.buildbot.red_core_builders_names()
@@ -144,6 +144,41 @@ class EnsureBuildersAreGreenStep(AbstractStep):
         error("Builders [%s] are red, please do not commit.\nSee http://%s.\nPass --ignore-builders to bypass this check." % (", ".join(red_builders_names), self._tool.buildbot.buildbot_host))
 
 
+class UpdateChangelogsWithReviewerStep(AbstractStep):
+    @classmethod
+    def options(cls):
+        return [
+            CommandOptions.reviewer,
+        ]
+
+    def guess_reviewer_from_bug(self, bug_id):
+        patches = self._tool.bugs.fetch_reviewed_patches_from_bug(bug_id)
+        if len(patches) != 1:
+            log("%s on bug %s, cannot infer reviewer." % (pluralize("reviewed patch", len(patches)), bug_id))
+            return None
+        patch = patches[0]
+        reviewer = patch["reviewer"]
+        log("Guessing \"%s\" as reviewer from attachment %s on bug %s." % (reviewer, patch["id"], bug_id))
+        return reviewer
+
+    def run(self, state):
+        bug_id = state["patch"]["bug_id"]
+        reviewer = self._options.reviewer
+        if not reviewer:
+            if not bug_id:
+                log("No bug id provided and --reviewer= not provided.  Not updating ChangeLogs with reviewer.")
+                return
+            reviewer = self.guess_reviewer_from_bug(bug_id)
+
+        if not reviewer:
+            log("Failed to guess reviewer from bug %s and --reviewer= not provided.  Not updating ChangeLogs with reviewer." % bug_id)
+            return
+
+        os.chdir(self._tool.scm().checkout_root)
+        for changelog_path in self._tool.scm().modified_changelogs():
+            ChangeLog(changelog_path).set_reviewer(reviewer)
+
+
 class BuildStep(AbstractStep):
     @classmethod
     def options(cls):
@@ -152,7 +187,7 @@ class BuildStep(AbstractStep):
             CommandOptions.quiet,
         ]
 
-    def run(self):
+    def run(self, state):
         if not self._options.build:
             return
         log("Building WebKit")
@@ -160,7 +195,7 @@ class BuildStep(AbstractStep):
 
 
 class CheckStyleStep(AbstractStep):
-    def run(self):
+    def run(self, state):
         self._run_script("check-webkit-style")
 
 
@@ -175,7 +210,7 @@ class RunTestsStep(AbstractStep):
             CommandOptions.port,
         ]
 
-    def run(self):
+    def run(self, state):
         if not self._options.build:
             return
         if not self._options.test:
@@ -190,15 +225,15 @@ class RunTestsStep(AbstractStep):
 
 
 class CommitStep(AbstractStep):
-    def run(self):
+    def run(self, state):
         commit_message = self._tool.scm().commit_message_for_this_commit()
-        return self._tool.scm().commit_with_message(commit_message.message())
+        state["commit_text"] =  self._tool.scm().commit_with_message(commit_message.message())
 
 
 class ClosePatchStep(AbstractStep):
-    def run(self, commit_log):
-        comment_text = bug_comment_from_commit_text(self._tool.scm(), commit_log)
-        self._tool.bugs.clear_attachment_flags(self._patch["id"], comment_text)
+    def run(self, state):
+        comment_text = bug_comment_from_commit_text(self._tool.scm(), state["commit_text"])
+        self._tool.bugs.clear_attachment_flags(state["patch"]["id"], comment_text)
 
 
 class CloseBugStep(AbstractStep):
@@ -208,18 +243,41 @@ class CloseBugStep(AbstractStep):
             CommandOptions.close_bug,
         ]
 
-    def run(self):
+    def run(self, state):
         if not self._options.close_bug:
             return
         # Check to make sure there are no r? or r+ patches on the bug before closing.
         # Assume that r- patches are just previous patches someone forgot to obsolete.
-        patches = self._tool.bugs.fetch_patches_from_bug(self._patch["bug_id"])
+        patches = self._tool.bugs.fetch_patches_from_bug(state["patch"]["bug_id"])
         for patch in patches:
             review_flag = patch.get("review")
             if review_flag == "?" or review_flag == "+":
                 log("Not closing bug %s as attachment %s has review=%s.  Assuming there are more patches to land from this bug." % (patch["bug_id"], patch["id"], review_flag))
                 return
-        self._tool.bugs.close_bug_as_fixed(self._patch["bug_id"], "All reviewed patches have been landed.  Closing bug.")
+        self._tool.bugs.close_bug_as_fixed(state["patch"]["bug_id"], "All reviewed patches have been landed.  Closing bug.")
+
+
+class CloseBugForLandDiffStep(AbstractStep):
+    @classmethod
+    def options(cls):
+        return [
+            CommandOptions.close_bug,
+        ]
+
+    def run(self, state):
+        comment_text = bug_comment_from_commit_text(self._tool.scm(), state["commit_text"])
+        bug_id = state["patch"]["bug_id"]
+        if bug_id:
+            log("Updating bug %s" % bug_id)
+            if self._options.close_bug:
+                self._tool.bugs.close_bug_as_fixed(bug_id, comment_text)
+            else:
+                # FIXME: We should a smart way to figure out if the patch is attached
+                # to the bug, and if so obsolete it.
+                self._tool.bugs.post_comment_to_bug(bug_id, comment_text)
+        else:
+            log(comment_text)
+            log("No bug id provided.")
 
 
 # FIXME: This class is a dinosaur and should be extinct soon.
diff --git a/WebKitTools/Scripts/modules/commands/download.py b/WebKitTools/Scripts/modules/commands/download.py
index 2acd69f..9a85aef 100644
--- a/WebKitTools/Scripts/modules/commands/download.py
+++ b/WebKitTools/Scripts/modules/commands/download.py
@@ -33,12 +33,12 @@ import os
 from optparse import make_option
 
 from modules.bugzilla import parse_bug_id
-from modules.buildsteps import CommandOptions, BuildSteps, EnsureBuildersAreGreenStep, CleanWorkingDirectoryStep, UpdateStep, ApplyPatchStep, BuildStep, CheckStyleStep, PrepareChangelogStep
+# FIXME: This list is rediculous.  We need to learn the ways of __all__.
+from modules.buildsteps import CommandOptions, BuildSteps, EnsureBuildersAreGreenStep, UpdateChangelogsWithReviewerStep, CleanWorkingDirectoryStep, UpdateStep, ApplyPatchStep, BuildStep, CheckStyleStep, RunTestsStep, CommitStep, ClosePatchStep, CloseBugStep, CloseBugForLandDiffStep, PrepareChangelogStep
 from modules.changelogs import ChangeLog
 from modules.comments import bug_comment_from_commit_text
 from modules.executive import ScriptError
 from modules.grammar import pluralize
-from modules.landingsequence import LandingSequence
 from modules.logging import error, log
 from modules.multicommandtool import Command
 from modules.stepsequence import StepSequence
@@ -101,9 +101,9 @@ class WebKitApplyingScripts:
     @staticmethod
     def setup_for_patch_apply(tool, options):
         clean_step = CleanWorkingDirectoryStep(tool, options, allow_local_commits=True)
-        clean_step.run()
+        clean_step.run({})
         update_step = UpdateStep(tool, options)
-        update_step.run()
+        update_step.run({})
 
     @staticmethod
     def apply_patches_with_options(scm, patches, options):
@@ -118,80 +118,29 @@ class WebKitApplyingScripts:
                 scm.commit_locally_with_message(commit_message.message() or patch["name"])
 
 
-class LandDiffSequence(LandingSequence):
-    def run(self):
-        self.check_builders()
-        self.build()
-        self.test()
-        commit_log = self.commit()
-        self.close_bug(commit_log)
-
-    def close_bug(self, commit_log):
-        comment_test = bug_comment_from_commit_text(self._tool.scm(), commit_log)
-        bug_id = self._patch["bug_id"]
-        if bug_id:
-            log("Updating bug %s" % bug_id)
-            if self._options.close_bug:
-                self._tool.bugs.close_bug_as_fixed(bug_id, comment_test)
-            else:
-                # FIXME: We should a smart way to figure out if the patch is attached
-                # to the bug, and if so obsolete it.
-                self._tool.bugs.post_comment_to_bug(bug_id, comment_test)
-        else:
-            log(comment_test)
-            log("No bug id provided.")
-
-
 class LandDiff(Command):
     name = "land-diff"
     show_in_main_help = True
     def __init__(self):
-        options = [
-            make_option("-r", "--reviewer", action="store", type="string", dest="reviewer", help="Update ChangeLogs to say Reviewed by REVIEWER."),
-        ]
-        options += BuildSteps.build_options()
-        options += BuildSteps.land_options()
-        Command.__init__(self, "Land the current working directory diff and updates the associated bug if any", "[BUGID]", options=options)
-
-    def guess_reviewer_from_bug(self, bugs, bug_id):
-        patches = bugs.fetch_reviewed_patches_from_bug(bug_id)
-        if len(patches) != 1:
-            log("%s on bug %s, cannot infer reviewer." % (pluralize("reviewed patch", len(patches)), bug_id))
-            return None
-        patch = patches[0]
-        reviewer = patch["reviewer"]
-        log("Guessing \"%s\" as reviewer from attachment %s on bug %s." % (reviewer, patch["id"], bug_id))
-        return reviewer
-
-    def update_changelogs_with_reviewer(self, reviewer, bug_id, tool):
-        if not reviewer:
-            if not bug_id:
-                log("No bug id provided and --reviewer= not provided.  Not updating ChangeLogs with reviewer.")
-                return
-            reviewer = self.guess_reviewer_from_bug(tool.bugs, bug_id)
-
-        if not reviewer:
-            log("Failed to guess reviewer from bug %s and --reviewer= not provided.  Not updating ChangeLogs with reviewer." % bug_id)
-            return
-
-        for changelog_path in tool.scm().modified_changelogs():
-            ChangeLog(changelog_path).set_reviewer(reviewer)
+        self._sequence = StepSequence([
+            EnsureBuildersAreGreenStep,
+            UpdateChangelogsWithReviewerStep,
+            EnsureBuildersAreGreenStep,
+            BuildStep,
+            RunTestsStep,
+            CommitStep,
+            CloseBugForLandDiffStep,
+        ])
+        Command.__init__(self, "Land the current working directory diff and updates the associated bug if any", "[BUGID]", options=self._sequence.options())
 
     def execute(self, options, args, tool):
         bug_id = (args and args[0]) or parse_bug_id(tool.scm().create_patch())
-
-        EnsureBuildersAreGreenStep(tool, options).run()
-
-        os.chdir(tool.scm().checkout_root)
-        self.update_changelogs_with_reviewer(options.reviewer, bug_id, tool)
-
         fake_patch = {
             "id": None,
-            "bug_id": bug_id
+            "bug_id": bug_id,
         }
-
-        sequence = LandDiffSequence(fake_patch, options, tool)
-        sequence.run()
+        state = {"patch": fake_patch}
+        self._sequence.run_and_handle_errors(tool, options, state)
 
 
 class AbstractPatchProcessingCommand(Command):
@@ -242,8 +191,10 @@ class CheckStyle(AbstractPatchProcessingCommand):
     def _prepare_to_process(self, options, args, tool):
         pass
 
+    # FIXME: Add a base class to share this code.
     def _process_patch(self, patch, options, args, tool):
-        self._sequence.run_and_handle_errors(tool, options, patch)
+        state = {"patch": patch}
+        self._sequence.run_and_handle_errors(tool, options, state)
 
 
 class BuildAttachment(AbstractPatchProcessingCommand):
@@ -264,24 +215,35 @@ class BuildAttachment(AbstractPatchProcessingCommand):
     def _prepare_to_process(self, options, args, tool):
         pass
 
+    # FIXME: Add a base class to share this code.
     def _process_patch(self, patch, options, args, tool):
-        self._sequence.run_and_handle_errors(tool, options, patch)
+        state = {"patch": patch}
+        self._sequence.run_and_handle_errors(tool, options, state)
 
 
 class AbstractPatchLandingCommand(AbstractPatchProcessingCommand):
     def __init__(self, help_text, args_description):
-        options = BuildSteps.cleaning_options()
-        options += BuildSteps.build_options()
-        options += BuildSteps.land_options()
-        AbstractPatchProcessingCommand.__init__(self, help_text, args_description, options)
+        self._sequence = StepSequence([
+            CleanWorkingDirectoryStep,
+            UpdateStep,
+            ApplyPatchStep,
+            EnsureBuildersAreGreenStep,
+            BuildStep,
+            RunTestsStep,
+            CommitStep,
+            ClosePatchStep,
+            CloseBugStep,
+        ])
+        AbstractPatchProcessingCommand.__init__(self, help_text, args_description, self._sequence.options())
 
     def _prepare_to_process(self, options, args, tool):
         # Check the tree status first so we can fail early.
-        EnsureBuildersAreGreenStep(tool, options).run()
+        EnsureBuildersAreGreenStep(tool, options).run({})
 
+    # FIXME: Add a base class to share this code.
     def _process_patch(self, patch, options, args, tool):
-        sequence = LandingSequence(patch, options, tool)
-        sequence.run_and_handle_errors()
+        state = {"patch": patch}
+        self._sequence.run_and_handle_errors(tool, options, state)
 
 
 class LandAttachment(AbstractPatchLandingCommand):
@@ -328,7 +290,7 @@ class Rollout(Command):
 
         # Second, make new ChangeLog entries for this rollout.
         # This could move to prepare-ChangeLog by adding a --revert= option.
-        PrepareChangelogStep(tool, None).run()
+        PrepareChangelogStep(tool, None).run({})
         for changelog_path in changelog_paths:
             ChangeLog(changelog_path).update_for_revert(revision)
 
@@ -354,8 +316,8 @@ class Rollout(Command):
             else:
                 log("Failed to parse bug number from diff.  No bugs will be updated/reopened after the rollout.")
 
-        CleanWorkingDirectoryStep(tool, options).run()
-        UpdateStep(tool, options).run()
+        CleanWorkingDirectoryStep(tool, options).run({})
+        UpdateStep(tool, options).run({})
         tool.scm().apply_reverse_diff(revision)
         self._create_changelogs_for_revert(tool, revision)
 
diff --git a/WebKitTools/Scripts/modules/commands/queues.py b/WebKitTools/Scripts/modules/commands/queues.py
index 53b9e48..ef83a67 100644
--- a/WebKitTools/Scripts/modules/commands/queues.py
+++ b/WebKitTools/Scripts/modules/commands/queues.py
@@ -35,11 +35,11 @@ from optparse import make_option
 
 from modules.executive import ScriptError
 from modules.grammar import pluralize
-from modules.landingsequence import LandingSequence, LandingSequenceErrorHandler
 from modules.logging import error, log
 from modules.multicommandtool import Command
 from modules.patchcollection import PersistentPatchCollection, PersistentPatchCollectionDelegate
 from modules.statusbot import StatusBot
+from modules.stepsequence import StepSequenceErrorHandler
 from modules.workqueue import WorkQueue, WorkQueueDelegate
 
 class AbstractQueue(Command, WorkQueueDelegate):
@@ -104,7 +104,7 @@ class AbstractQueue(Command, WorkQueueDelegate):
         return work_queue.run()
 
 
-class CommitQueue(AbstractQueue, LandingSequenceErrorHandler):
+class CommitQueue(AbstractQueue, StepSequenceErrorHandler):
     name = "commit-queue"
     def __init__(self):
         AbstractQueue.__init__(self)
@@ -136,14 +136,14 @@ class CommitQueue(AbstractQueue, LandingSequenceErrorHandler):
     def handle_unexpected_error(self, patch, message):
         self.tool.bugs.reject_patch_from_commit_queue(patch["id"], message)
 
-    # LandingSequenceErrorHandler methods
+    # StepSequenceErrorHandler methods
 
     @classmethod
-    def handle_script_error(cls, tool, patch, script_error):
-        tool.bugs.reject_patch_from_commit_queue(patch["id"], script_error.message_with_output())
+    def handle_script_error(cls, tool, state, script_error):
+        tool.bugs.reject_patch_from_commit_queue(state["patch"]["id"], script_error.message_with_output())
 
 
-class AbstractReviewQueue(AbstractQueue, PersistentPatchCollectionDelegate, LandingSequenceErrorHandler):
+class AbstractReviewQueue(AbstractQueue, PersistentPatchCollectionDelegate, StepSequenceErrorHandler):
     def __init__(self, options=None):
         AbstractQueue.__init__(self, options)
 
@@ -179,10 +179,10 @@ class AbstractReviewQueue(AbstractQueue, PersistentPatchCollectionDelegate, Land
     def handle_unexpected_error(self, patch, message):
         log(message)
 
-    # LandingSequenceErrorHandler methods
+    # StepSequenceErrorHandler methods
 
     @classmethod
-    def handle_script_error(cls, tool, patch, script_error):
+    def handle_script_error(cls, tool, state, script_error):
         log(script_error.message_with_output())
 
 
@@ -205,12 +205,12 @@ class StyleQueue(AbstractReviewQueue):
             raise e
 
     @classmethod
-    def handle_script_error(cls, tool, patch, script_error):
+    def handle_script_error(cls, tool, state, script_error):
         command = script_error.script_args
         if type(command) is list:
             command = command[0]
         # FIXME: We shouldn't need to use a regexp here.  ScriptError should
         #        have a better API.
         if re.search("check-webkit-style", command):
-            message = "Attachment %s did not pass %s:\n\n%s" % (patch["id"], cls.name, script_error.message_with_output(output_limit=5*1024))
-            tool.bugs.post_comment_to_bug(patch["bug_id"], message, cc=cls.watchers)
+            message = "Attachment %s did not pass %s:\n\n%s" % (state["patch"]["id"], cls.name, script_error.message_with_output(output_limit=5*1024))
+            tool.bugs.post_comment_to_bug(state["patch"]["bug_id"], message, cc=cls.watchers)
diff --git a/WebKitTools/Scripts/modules/landingsequence.py b/WebKitTools/Scripts/modules/landingsequence.py
deleted file mode 100644
index 90683f4..0000000
--- a/WebKitTools/Scripts/modules/landingsequence.py
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2009, Google Inc. All rights reserved.
-# Copyright (c) 2009 Apple 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 modules.comments import bug_comment_from_commit_text
-from modules.executive import ScriptError
-from modules.logging import log
-from modules.scm import CheckoutNeedsUpdate
-from modules.webkitport import WebKitPort
-from modules.workqueue import WorkQueue
-from modules.buildsteps import CleanWorkingDirectoryStep, UpdateStep, ApplyPatchStep, EnsureBuildersAreGreenStep, BuildStep, RunTestsStep, CommitStep, ClosePatchStep, CloseBugStep
-
-
-class LandingSequenceErrorHandler():
-    @classmethod
-    def handle_script_error(cls, tool, patch, script_error):
-        raise NotImplementedError, "subclasses must implement"
-
-# FIXME: This class is slowing being killed and replaced with StepSequence.
-class LandingSequence:
-    def __init__(self, patch, options, tool):
-        self._patch = patch
-        self._options = options
-        self._tool = tool
-        self._port = WebKitPort.port(self._options.port)
-
-    def run(self):
-        self.clean()
-        self.update()
-        self.apply_patch()
-        self.check_builders()
-        self.build()
-        self.test()
-        commit_log = self.commit()
-        self.close_patch(commit_log)
-        self.close_bug()
-
-    def run_and_handle_errors(self):
-        try:
-            self.run()
-        except CheckoutNeedsUpdate, e:
-            log("Commit failed because the checkout is out of date.  Please update and try again.")
-            log("You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results.")
-            WorkQueue.exit_after_handled_error(e)
-        except ScriptError, e:
-            if not self._options.quiet:
-                log(e.message_with_output())
-            if self._options.parent_command:
-                command = self._tool.command_by_name(self._options.parent_command)
-                command.handle_script_error(self._tool, self._patch, e)
-            WorkQueue.exit_after_handled_error(e)
-
-    def clean(self):
-        step = CleanWorkingDirectoryStep(self._tool, self._options)
-        step.run()
-
-    def update(self):
-        step = UpdateStep(self._tool, self._options)
-        step.run()
-
-    def apply_patch(self):
-        step = ApplyPatchStep(self._tool, self._options, self._patch)
-        step.run()
-
-    def check_builders(self):
-        step = EnsureBuildersAreGreenStep(self._tool, self._options)
-        step.run()
-
-    def build(self):
-        step = BuildStep(self._tool, self._options)
-        step.run()
-
-    def test(self):
-        step = RunTestsStep(self._tool, self._options)
-        step.run()
-
-    def commit(self):
-        step = CommitStep(self._tool, self._options)
-        return step.run()
-
-    def close_patch(self, commit_log):
-        step = ClosePatchStep(self._tool, self._options, self._patch)
-        step.run(commit_log)
-
-    def close_bug(self):
-        step = CloseBugStep(self._tool, self._options, self._patch)
-        step.run()
diff --git a/WebKitTools/Scripts/modules/stepsequence.py b/WebKitTools/Scripts/modules/stepsequence.py
index 6f085c9..0e43c34 100644
--- a/WebKitTools/Scripts/modules/stepsequence.py
+++ b/WebKitTools/Scripts/modules/stepsequence.py
@@ -33,6 +33,12 @@ from modules.scm import CheckoutNeedsUpdate
 from modules.workqueue import WorkQueue
 
 
+class StepSequenceErrorHandler():
+    @classmethod
+    def handle_script_error(cls, tool, patch, script_error):
+        raise NotImplementedError, "subclasses must implement"
+
+
 class StepSequence(object):
     def __init__(self, steps):
         self._steps = steps
@@ -48,13 +54,15 @@ class StepSequence(object):
         collected_options = sorted(set(collected_options))
         return collected_options
 
-    def _run(self, tool, options, patch):
+    def _run(self, tool, options, state):
         for step in self._steps:
-            step(tool, options, patch).run()
+            step(tool, options).run(state)
 
-    def run_and_handle_errors(self, tool, options, patch=None):
+    def run_and_handle_errors(self, tool, options, state=None):
+        if not state:
+            state = {}
         try:
-            self._run(tool, options, patch)
+            self._run(tool, options, state)
         except CheckoutNeedsUpdate, e:
             log("Commit failed because the checkout is out of date.  Please update and try again.")
             log("You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results.")
@@ -64,5 +72,5 @@ class StepSequence(object):
                 log(e.message_with_output())
             if options.parent_command:
                 command = tool.command_by_name(options.parent_command)
-                command.handle_script_error(tool, patch, e)
+                command.handle_script_error(tool, state, e)
             WorkQueue.exit_after_handled_error(e)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list