Changeset 52131 in webkit
- Timestamp:
- Dec 14, 2009 9:32:03 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r52130 r52131 1 2009-12-14 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 [bzt] Kill WebKitApplyingScripts 6 https://bugs.webkit.org/show_bug.cgi?id=32467 7 8 Ah! I've been wanting to do this for a long time. This patch brings 9 the applying commands into the patch processing fold. 10 11 * Scripts/bugzilla-tool: 12 * Scripts/modules/buildsteps.py: 13 * Scripts/modules/commands/download.py: 14 * Scripts/modules/commands/download_unittest.py: 15 * Scripts/modules/mock_bugzillatool.py: 16 1 17 2009-12-14 Adam Barth <abarth@webkit.org> 2 18 -
trunk/WebKitTools/Scripts/bugzilla-tool
r51889 r52131 35 35 from modules.bugzilla import Bugzilla 36 36 from modules.buildbot import BuildBot 37 from modules.buildsteps import BuildSteps38 37 from modules.commands.download import * 39 38 from modules.commands.early_warning_system import * … … 56 55 self._scm = None 57 56 self._status = None 58 self.steps = BuildSteps()59 57 60 58 def dry_run_callback(self, option, opt, value, parser): -
trunk/WebKitTools/Scripts/modules/buildsteps.py
r52130 r52131 45 45 parent_command = make_option("--parent-command", action="store", dest="parent_command", default=None, help="(Internal) The command that spawned this instance.") 46 46 update = make_option("--no-update", action="store_false", dest="update", default=True, help="Don't update the working directory.") 47 local_commit = make_option("--local-commit", action="store_true", dest="local_commit", default=False, help="Make a local commit for each applied patch") 47 48 build = make_option("--no-build", action="store_false", dest="build", default=True, help="Commit without building first, implies --no-test.") 48 49 test = make_option("--no-test", action="store_false", dest="test", default=True, help="Commit without running run-webkit-tests.") … … 142 143 143 144 145 class CleanWorkingDirectoryWithLocalCommitsStep(CleanWorkingDirectoryStep): 146 def __init__(self, tool, options): 147 # FIXME: This a bit of a hack. Consider doing this more cleanly. 148 CleanWorkingDirectoryStep.__init__(self, tool, options, allow_local_commits=True) 149 150 144 151 class UpdateStep(AbstractStep): 145 152 @classmethod … … 172 179 def run(self, state): 173 180 self._tool.scm().apply_reverse_diff(state["revision"]) 181 182 183 class ApplyPatchWithLocalCommitStep(ApplyPatchStep): 184 @classmethod 185 def options(cls): 186 return [ 187 CommandOptions.local_commit, 188 ] + ApplyPatchStep.options() 189 190 def run(self, state): 191 ApplyPatchStep.run(self, state) 192 if self._options.local_commit: 193 commit_message = self._tool.scm().commit_message_for_this_commit() 194 self._tool.scm().commit_locally_with_message(commit_message.message() or state["patch"]["name"]) 174 195 175 196 … … 355 376 # FIXME: I'm not sure state["commit_text"] is quite right here. 356 377 self._tool.bugs.reopen_bug(bug_id, state["commit_text"]) 357 358 359 # FIXME: This class is a dinosaur and should be extinct soon.360 class BuildSteps:361 # FIXME: The options should really live on each "Step" object.362 @staticmethod363 def cleaning_options():364 return [365 CommandOptions.force_clean,366 CommandOptions.clean,367 ]368 369 # FIXME: These distinctions are bogus. We need a better model for handling options.370 @staticmethod371 def build_options():372 return [373 CommandOptions.check_builders,374 CommandOptions.quiet,375 CommandOptions.non_interactive,376 CommandOptions.parent_command,377 CommandOptions.port,378 ]379 380 @staticmethod381 def land_options():382 return [383 CommandOptions.update,384 CommandOptions.build,385 CommandOptions.test,386 CommandOptions.close_bug,387 ]388 -
trunk/WebKitTools/Scripts/modules/commands/download.py
r52130 r52131 35 35 from modules.bugzilla import parse_bug_id 36 36 # 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, PrepareChangelogForRevertStep, RevertRevisionStep, CompleteRollout37 from modules.buildsteps import CommandOptions, EnsureBuildersAreGreenStep, UpdateChangelogsWithReviewerStep, CleanWorkingDirectoryStep, CleanWorkingDirectoryWithLocalCommitsStep, UpdateStep, ApplyPatchStep, ApplyPatchWithLocalCommitStep, BuildStep, CheckStyleStep, RunTestsStep, CommitStep, ClosePatchStep, CloseBugStep, CloseBugForLandDiffStep, PrepareChangelogStep, PrepareChangelogForRevertStep, RevertRevisionStep, CompleteRollout 38 38 from modules.changelogs import ChangeLog 39 39 from modules.comments import bug_comment_from_commit_text … … 60 60 61 61 62 class ApplyAttachment(Command):63 name = "apply-attachment"64 show_in_main_help = True65 def __init__(self):66 options = WebKitApplyingScripts.apply_options()67 options += BuildSteps.cleaning_options()68 Command.__init__(self, "Apply an attachment to the local working directory", "ATTACHMENT_ID", options=options)69 70 def execute(self, options, args, tool):71 WebKitApplyingScripts.setup_for_patch_apply(tool, options)72 attachment_id = args[0]73 attachment = tool.bugs.fetch_attachment(attachment_id)74 WebKitApplyingScripts.apply_patches_with_options(tool.scm(), [attachment], options)75 76 77 class ApplyPatches(Command):78 name = "apply-patches"79 show_in_main_help = True80 def __init__(self):81 options = WebKitApplyingScripts.apply_options()82 options += BuildSteps.cleaning_options()83 Command.__init__(self, "Apply reviewed patches from provided bugs to the local working directory", "BUGID", options=options)84 85 def execute(self, options, args, tool):86 WebKitApplyingScripts.setup_for_patch_apply(tool, options)87 bug_id = args[0]88 patches = tool.bugs.fetch_reviewed_patches_from_bug(bug_id)89 WebKitApplyingScripts.apply_patches_with_options(tool.scm(), patches, options)90 91 92 class WebKitApplyingScripts:93 @staticmethod94 def apply_options():95 return [96 make_option("--no-update", action="store_false", dest="update", default=True, help="Don't update the working directory before applying patches"),97 make_option("--local-commit", action="store_true", dest="local_commit", default=False, help="Make a local commit for each applied patch"),98 CommandOptions.port,99 ]100 101 @staticmethod102 def setup_for_patch_apply(tool, options):103 clean_step = CleanWorkingDirectoryStep(tool, options, allow_local_commits=True)104 clean_step.run({})105 update_step = UpdateStep(tool, options)106 update_step.run({})107 108 @staticmethod109 def apply_patches_with_options(scm, patches, options):110 if options.local_commit and not scm.supports_local_commits():111 error("--local-commit passed, but %s does not support local commits" % scm.display_name())112 113 for patch in patches:114 log("Applying attachment %s from bug %s" % (patch["id"], patch["bug_id"]))115 scm.apply_patch(patch)116 if options.local_commit:117 commit_message = scm.commit_message_for_this_commit()118 scm.commit_locally_with_message(commit_message.message() or patch["name"])119 120 121 62 class LandDiff(Command): 122 63 name = "land-diff" … … 220 161 state = {"patch": patch} 221 162 self._sequence.run_and_handle_errors(tool, options, state) 163 164 165 class AbstractPatchApplyingCommand(AbstractPatchProcessingCommand): 166 def __init__(self, help_text, args_description): 167 self._prepare_sequence = StepSequence([ 168 CleanWorkingDirectoryWithLocalCommitsStep, 169 UpdateStep, 170 ]) 171 self._main_sequence = StepSequence([ 172 ApplyPatchWithLocalCommitStep, 173 ]) 174 options = sorted(set(self._prepare_sequence.options() + self._main_sequence.options())) 175 AbstractPatchProcessingCommand.__init__(self, help_text, args_description, options) 176 177 def _prepare_to_process(self, options, args, tool): 178 if options.local_commit and not tool.scm().supports_local_commits(): 179 error("--local-commit passed, but %s does not support local commits" % scm.display_name()) 180 self._prepare_sequence.run_and_handle_errors(tool, options) 181 182 # FIXME: Add a base class to share this code. 183 def _process_patch(self, patch, options, args, tool): 184 state = {"patch": patch} 185 self._main_sequence.run_and_handle_errors(tool, options, state) 186 187 188 class ApplyAttachment(AbstractPatchApplyingCommand): 189 name = "apply-attachment" 190 show_in_main_help = True 191 def __init__(self): 192 AbstractPatchApplyingCommand.__init__(self, "Apply an attachment to the local working directory", "ATTACHMENT_ID [ATTACHMENT_IDS]") 193 194 def _fetch_list_of_patches_to_process(self, options, args, tool): 195 return map(lambda patch_id: tool.bugs.fetch_attachment(patch_id), args) 196 197 198 class ApplyPatches(AbstractPatchApplyingCommand): 199 name = "apply-patches" 200 show_in_main_help = True 201 def __init__(self): 202 AbstractPatchApplyingCommand.__init__(self, "Apply reviewed patches from provided bugs to the local working directory", "BUGID [BUGIDS]") 203 204 def _fetch_list_of_patches_to_process(self, options, args, tool): 205 all_patches = [] 206 for bug_id in args: 207 patches = tool.bugs.fetch_reviewed_patches_from_bug(bug_id) 208 log("%s found on bug %s." % (pluralize("reviewed patch", len(patches)), bug_id)) 209 all_patches += patches 210 return all_patches 222 211 223 212 -
trunk/WebKitTools/Scripts/modules/commands/download_unittest.py
r52130 r52131 56 56 options.update = True 57 57 options.local_commit = True 58 expected_stderr = "Updating working directory\n Applying attachment 197 from bug 42\n"58 expected_stderr = "Updating working directory\nProcessing 1 patch from 1 bug.\nProcessing patch 197 from bug 42.\n" 59 59 self.assert_execute_outputs(ApplyAttachment(), [197], options=options, expected_stderr=expected_stderr) 60 60 … … 63 63 options.update = True 64 64 options.local_commit = True 65 expected_stderr = "Updating working directory\n Applying attachment 197 from bug 42\nApplying attachment 128 from bug 42\n"65 expected_stderr = "Updating working directory\n2 reviewed patches found on bug 42.\nProcessing 2 patches from 1 bug.\nProcessing patch 197 from bug 42.\nProcessing patch 128 from bug 42.\n" 66 66 self.assert_execute_outputs(ApplyPatches(), [42], options=options, expected_stderr=expected_stderr) 67 67
Note: See TracChangeset
for help on using the changeset viewer.