Changeset 52130 in webkit


Ignore:
Timestamp:
Dec 14, 2009 9:31:03 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-12-14 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

[bzt] Convert rollout to StepSequence
https://bugs.webkit.org/show_bug.cgi?id=32406

  • Scripts/modules/buildsteps.py:
  • Scripts/modules/commands/download.py:
  • Scripts/modules/commands/download_unittest.py:
  • Scripts/modules/mock_bugzillatool.py:
Location:
trunk/WebKitTools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r52129 r52130  
     12009-12-14  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [bzt] Convert rollout to StepSequence
     6        https://bugs.webkit.org/show_bug.cgi?id=32406
     7
     8        * Scripts/modules/buildsteps.py:
     9        * Scripts/modules/commands/download.py:
     10        * Scripts/modules/commands/download_unittest.py:
     11        * Scripts/modules/mock_bugzillatool.py:
     12
    1132009-12-14  Adam Barth  <abarth@webkit.org>
    214
  • trunk/WebKitTools/Scripts/modules/buildsteps.py

    r52129 r52130  
    3434from modules.logging import log, error
    3535from modules.webkitport import WebKitPort
     36from modules.changelogs import ChangeLog
    3637
    3738
     
    4950    port = make_option("--port", action="store", dest="port", default=None, help="Specify a port (e.g., mac, qt, gtk, ...).")
    5051    reviewer = make_option("-r", "--reviewer", action="store", type="string", dest="reviewer", help="Update ChangeLogs to say Reviewed by REVIEWER.")
     52    complete_rollout = make_option("--complete-rollout", action="store_true", dest="complete_rollout", help="Commit the revert and re-open the original bug.")
    5153
    5254
     
    7678
    7779
     80# FIXME: Unify with StepSequence?  I'm not sure yet which is the better design.
     81class MetaStep(AbstractStep):
     82    substeps = [] # Override in subclasses
     83    def __init__(self, tool, options):
     84        AbstractStep.__init__(self, tool, options)
     85        self._step_instances = []
     86        for step_class in self.substeps:
     87            self._step_instances.append(step_class(tool, options))
     88
     89    @staticmethod
     90    def _collect_options_from_steps(steps):
     91        collected_options = []
     92        for step in steps:
     93            collected_options = collected_options + step.options()
     94        return collected_options
     95
     96    @classmethod
     97    def options(cls):
     98        return cls._collect_options_from_steps(cls.substeps)
     99
     100    def run(self, state):
     101        for step in self._step_instances:
     102             step.run(state)
     103
     104
    78105class PrepareChangelogStep(AbstractStep):
    79106    def run(self, state):
    80107        self._run_script("prepare-ChangeLog")
     108
     109
     110class PrepareChangelogForRevertStep(AbstractStep):
     111    def run(self, state):
     112        # First, discard the ChangeLog changes from the rollout.
     113        os.chdir(self._tool.scm().checkout_root)
     114        changelog_paths = self._tool.scm().modified_changelogs()
     115        self._tool.scm().revert_files(changelog_paths)
     116
     117        # Second, make new ChangeLog entries for this rollout.
     118        # This could move to prepare-ChangeLog by adding a --revert= option.
     119        self._run_script("prepare-ChangeLog")
     120        for changelog_path in changelog_paths:
     121            ChangeLog(changelog_path).update_for_revert(state["revision"])
    81122
    82123
     
    126167        log("Processing patch %s from bug %s." % (state["patch"]["id"], state["patch"]["bug_id"]))
    127168        self._tool.scm().apply_patch(state["patch"], force=self._options.non_interactive)
     169
     170
     171class RevertRevisionStep(AbstractStep):
     172    def run(self, state):
     173        self._tool.scm().apply_reverse_diff(state["revision"])
    128174
    129175
     
    281327
    282328
     329class CompleteRollout(MetaStep):
     330    substeps = [
     331        BuildStep,
     332        CommitStep,
     333    ]
     334
     335    @classmethod
     336    def options(cls):
     337        collected_options = cls._collect_options_from_steps(cls.substeps)
     338        collected_options.append(CommandOptions.complete_rollout)
     339        return collected_options
     340
     341    def run(self, state):
     342        bug_id = state["bug_id"]
     343        # FIXME: Fully automated rollout is not 100% idiot-proof yet, so for now just log with instructions on how to complete the rollout.
     344        # Once we trust rollout we will remove this option.
     345        if not self._options.complete_rollout:
     346            log("\nNOTE: Rollout support is experimental.\nPlease verify the rollout diff and use \"bugzilla-tool land-diff %s\" to commit the rollout." % bug_id)
     347            return
     348
     349        MetaStep.run(self, state)
     350
     351        if not bug_id:
     352            log(state["commit_text"])
     353            log("No bugs were updated or re-opened to reflect this rollout.")
     354            return
     355        # FIXME: I'm not sure state["commit_text"] is quite right here.
     356        self._tool.bugs.reopen_bug(bug_id, state["commit_text"])
     357
     358
    283359# FIXME: This class is a dinosaur and should be extinct soon.
    284360class BuildSteps:
  • trunk/WebKitTools/Scripts/modules/commands/download.py

    r52129 r52130  
    3535from modules.bugzilla import parse_bug_id
    3636# FIXME: This list is rediculous.  We need to learn the ways of __all__.
    37 from modules.buildsteps import CommandOptions, BuildSteps, EnsureBuildersAreGreenStep, UpdateChangelogsWithReviewerStep, CleanWorkingDirectoryStep, UpdateStep, ApplyPatchStep, BuildStep, CheckStyleStep, RunTestsStep, CommitStep, ClosePatchStep, CloseBugStep, CloseBugForLandDiffStep, PrepareChangelogStep
     37from modules.buildsteps import CommandOptions, BuildSteps, EnsureBuildersAreGreenStep, UpdateChangelogsWithReviewerStep, CleanWorkingDirectoryStep, UpdateStep, ApplyPatchStep, BuildStep, CheckStyleStep, RunTestsStep, CommitStep, ClosePatchStep, CloseBugStep, CloseBugForLandDiffStep, PrepareChangelogStep, PrepareChangelogForRevertStep, RevertRevisionStep, CompleteRollout
    3838from modules.changelogs import ChangeLog
    3939from modules.comments import bug_comment_from_commit_text
     
    272272
    273273
    274 # FIXME: Requires unit test.
    275274class Rollout(Command):
    276275    name = "rollout"
    277276    show_in_main_help = True
    278277    def __init__(self):
    279         options = BuildSteps.cleaning_options()
    280         options += BuildSteps.build_options()
    281         options += BuildSteps.land_options()
    282         options.append(make_option("--complete-rollout", action="store_true", dest="complete_rollout", help="Commit the revert and re-open the original bug."))
    283         Command.__init__(self, "Revert the given revision in the working copy and optionally commit the revert and re-open the original bug", "REVISION [BUGID]", options=options)
    284 
    285     @staticmethod
    286     def _create_changelogs_for_revert(tool, revision):
    287         # First, discard the ChangeLog changes from the rollout.
    288         changelog_paths = tool.scm().modified_changelogs()
    289         tool.scm().revert_files(changelog_paths)
    290 
    291         # Second, make new ChangeLog entries for this rollout.
    292         # This could move to prepare-ChangeLog by adding a --revert= option.
    293         PrepareChangelogStep(tool, None).run({})
    294         for changelog_path in changelog_paths:
    295             ChangeLog(changelog_path).update_for_revert(revision)
     278        self._sequence = StepSequence([
     279            CleanWorkingDirectoryStep,
     280            UpdateStep,
     281            RevertRevisionStep,
     282            PrepareChangelogForRevertStep,
     283            CompleteRollout,
     284        ])
     285        Command.__init__(self, "Revert the given revision in the working copy and optionally commit the revert and re-open the original bug", "REVISION [BUGID]", options=self._sequence.options())
    296286
    297287    @staticmethod
     
    317307                log("Failed to parse bug number from diff.  No bugs will be updated/reopened after the rollout.")
    318308
    319         CleanWorkingDirectoryStep(tool, options).run({})
    320         UpdateStep(tool, options).run({})
    321         tool.scm().apply_reverse_diff(revision)
    322         self._create_changelogs_for_revert(tool, revision)
    323 
    324         # FIXME: Fully automated rollout is not 100% idiot-proof yet, so for now just log with instructions on how to complete the rollout.
    325         # Once we trust rollout we will remove this option.
    326         if not options.complete_rollout:
    327             log("\nNOTE: Rollout support is experimental.\nPlease verify the rollout diff and use \"bugzilla-tool land-diff %s\" to commit the rollout." % bug_id)
    328         else:
    329             # FIXME: This function does not exist!!
    330             # comment_text = WebKitLandingScripts.build_and_commit(tool.scm(), options)
    331             raise ScriptError("OOPS! This option is not implemented (yet).")
    332             self._reopen_bug_after_rollout(tool, bug_id, comment_text)
     309        state = {
     310            "revision": revision,
     311            "bug_id": bug_id,
     312        }
     313        self._sequence.run_and_handle_errors(tool, options, state)
  • trunk/WebKitTools/Scripts/modules/commands/download_unittest.py

    r52025 r52130  
    4545        options.test = True
    4646        options.close_bug = True
     47        options.complete_rollout = False
    4748        return options
    4849
     
    8485        expected_stderr = "2 reviewed patches found on bug 42.\nProcessing 2 patches from 1 bug.\nUpdating working directory\nProcessing patch 197 from bug 42.\nBuilding WebKit\nUpdating working directory\nProcessing patch 128 from bug 42.\nBuilding WebKit\n"
    8586        self.assert_execute_outputs(LandPatches(), [42], options=self._default_options(), expected_stderr=expected_stderr)
     87
     88    def test_rollout(self):
     89        expected_stderr = "Updating working directory\nRunning prepare-ChangeLog\n\nNOTE: Rollout support is experimental.\nPlease verify the rollout diff and use \"bugzilla-tool land-diff 12345\" to commit the rollout.\n"
     90        self.assert_execute_outputs(Rollout(), [852], options=self._default_options(), expected_stderr=expected_stderr)
     91
     92    def test_complete_rollout(self):
     93        options = self._default_options()
     94        options.complete_rollout = True
     95        expected_stderr = "Will re-open bug 12345 after rollout.\nUpdating working directory\nRunning prepare-ChangeLog\nBuilding WebKit\n"
     96        self.assert_execute_outputs(Rollout(), [852], options=options, expected_stderr=expected_stderr)
  • trunk/WebKitTools/Scripts/modules/mock_bugzillatool.py

    r51972 r52130  
    134134        raise Exception("Bogus commit_id in commit_message_for_local_commit.")
    135135
     136    def diff_for_revision(self, revision):
     137        return "DiffForRevision%s\nhttp://bugs.webkit.org/show_bug.cgi?id=12345" % revision
     138
    136139    def modified_changelogs(self):
    137140        # Ideally we'd return something more interesting here.
Note: See TracChangeset for help on using the changeset viewer.