[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:13 UTC 2010


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

    2009-12-14  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            [bzt] Add AbstractPatchSequencingCommand to remove redundant code
            https://bugs.webkit.org/show_bug.cgi?id=32468
    
            Redundant code is bad.  This patch moves us towards more declarative
            commands.
    
            * Scripts/modules/commands/download.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52132 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index e004c29..d353a12 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -2,6 +2,18 @@
 
         Reviewed by Eric Seidel.
 
+        [bzt] Add AbstractPatchSequencingCommand to remove redundant code
+        https://bugs.webkit.org/show_bug.cgi?id=32468
+
+        Redundant code is bad.  This patch moves us towards more declarative
+        commands.
+
+        * Scripts/modules/commands/download.py:
+
+2009-12-14  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
         [bzt] Kill WebKitApplyingScripts
         https://bugs.webkit.org/show_bug.cgi?id=32467
 
diff --git a/WebKitTools/Scripts/modules/commands/download.py b/WebKitTools/Scripts/modules/commands/download.py
index 779a159..8966baf 100644
--- a/WebKitTools/Scripts/modules/commands/download.py
+++ b/WebKitTools/Scripts/modules/commands/download.py
@@ -114,75 +114,79 @@ class AbstractPatchProcessingCommand(Command):
             self._process_patch(patch, options, args, tool)
 
 
-class CheckStyle(AbstractPatchProcessingCommand):
-    name = "check-style"
-    show_in_main_help = False
-    def __init__(self):
-        self._sequence = StepSequence([
-            CleanWorkingDirectoryStep,
-            UpdateStep,
-            ApplyPatchStep,
-            CheckStyleStep,
-        ])
-        AbstractPatchProcessingCommand.__init__(self, "Run check-webkit-style on the specified attachments", "ATTACHMENT_ID [ATTACHMENT_IDS]", self._sequence.options())
+class AbstractPatchSequencingCommand(AbstractPatchProcessingCommand):
+    prepare_steps = None
+    main_steps = None
 
-    def _fetch_list_of_patches_to_process(self, options, args, tool):
-        return map(lambda patch_id: tool.bugs.fetch_attachment(patch_id), args)
+    @staticmethod
+    def _create_step_sequence(steps):
+        if not steps:
+            return None, []
+        step_sequence = StepSequence(steps)
+        return step_sequence, step_sequence.options()
+
+    def __init__(self, help_text, args_description):
+        options = []
+        self._prepare_sequence, prepare_options = self._create_step_sequence(self.prepare_steps)
+        self._main_sequence, main_options = self._create_step_sequence(self.main_steps)
+        options = sorted(set(prepare_options + main_options))
+        AbstractPatchProcessingCommand.__init__(self, help_text, args_description, options)
 
     def _prepare_to_process(self, options, args, tool):
-        pass
+        if self._prepare_sequence:
+            self._prepare_sequence.run_and_handle_errors(tool, options)
 
-    # FIXME: Add a base class to share this code.
     def _process_patch(self, patch, options, args, tool):
-        state = {"patch": patch}
-        self._sequence.run_and_handle_errors(tool, options, state)
+        if self._main_sequence:
+            state = {"patch": patch}
+            self._main_sequence.run_and_handle_errors(tool, options, state)
 
 
-class BuildAttachment(AbstractPatchProcessingCommand):
-    name = "build-attachment"
+class CheckStyle(AbstractPatchSequencingCommand):
+    name = "check-style"
     show_in_main_help = False
+    main_steps = [
+        CleanWorkingDirectoryStep,
+        UpdateStep,
+        ApplyPatchStep,
+        CheckStyleStep,
+    ]
     def __init__(self):
-        self._sequence = StepSequence([
-            CleanWorkingDirectoryStep,
-            UpdateStep,
-            ApplyPatchStep,
-            BuildStep,
-        ])
-        AbstractPatchProcessingCommand.__init__(self, "Apply and build patches from bugzilla", "ATTACHMENT_ID [ATTACHMENT_IDS]", self._sequence.options())
+        AbstractPatchSequencingCommand.__init__(self, "Run check-webkit-style on the specified attachments", "ATTACHMENT_ID [ATTACHMENT_IDS]")
 
     def _fetch_list_of_patches_to_process(self, options, args, tool):
         return map(lambda patch_id: tool.bugs.fetch_attachment(patch_id), args)
 
-    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):
-        state = {"patch": patch}
-        self._sequence.run_and_handle_errors(tool, options, state)
+class BuildAttachment(AbstractPatchSequencingCommand):
+    name = "build-attachment"
+    show_in_main_help = False
+    main_steps = [
+        CleanWorkingDirectoryStep,
+        UpdateStep,
+        ApplyPatchStep,
+        BuildStep,
+    ]
+    def __init__(self):
+        AbstractPatchSequencingCommand.__init__(self, "Apply and build patches from bugzilla", "ATTACHMENT_ID [ATTACHMENT_IDS]")
 
+    def _fetch_list_of_patches_to_process(self, options, args, tool):
+        return map(lambda patch_id: tool.bugs.fetch_attachment(patch_id), args)
 
-class AbstractPatchApplyingCommand(AbstractPatchProcessingCommand):
-    def __init__(self, help_text, args_description):
-        self._prepare_sequence = StepSequence([
-            CleanWorkingDirectoryWithLocalCommitsStep,
-            UpdateStep,
-        ])
-        self._main_sequence  = StepSequence([
-            ApplyPatchWithLocalCommitStep,
-        ])
-        options = sorted(set(self._prepare_sequence.options() + self._main_sequence.options()))
-        AbstractPatchProcessingCommand.__init__(self, help_text, args_description, options)
+
+class AbstractPatchApplyingCommand(AbstractPatchSequencingCommand):
+    prepare_steps = [
+        CleanWorkingDirectoryWithLocalCommitsStep,
+        UpdateStep,
+    ]
+    main_steps = [
+        ApplyPatchWithLocalCommitStep,
+    ]
 
     def _prepare_to_process(self, options, args, tool):
         if options.local_commit and not tool.scm().supports_local_commits():
             error("--local-commit passed, but %s does not support local commits" % scm.display_name())
-        self._prepare_sequence.run_and_handle_errors(tool, options)
-
-    # FIXME: Add a base class to share this code.
-    def _process_patch(self, patch, options, args, tool):
-        state = {"patch": patch}
-        self._main_sequence.run_and_handle_errors(tool, options, state)
+        AbstractPatchSequencingCommand._prepare_to_process(self, options, args, tool)
 
 
 class ApplyAttachment(AbstractPatchApplyingCommand):
@@ -210,29 +214,21 @@ class ApplyPatches(AbstractPatchApplyingCommand):
         return all_patches
 
 
-class AbstractPatchLandingCommand(AbstractPatchProcessingCommand):
-    def __init__(self, help_text, args_description):
-        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({})
-
-    # FIXME: Add a base class to share this code.
-    def _process_patch(self, patch, options, args, tool):
-        state = {"patch": patch}
-        self._sequence.run_and_handle_errors(tool, options, state)
+class AbstractPatchLandingCommand(AbstractPatchSequencingCommand):
+    prepare_steps = [
+        EnsureBuildersAreGreenStep,
+    ]
+    main_steps = [
+        CleanWorkingDirectoryStep,
+        UpdateStep,
+        ApplyPatchStep,
+        EnsureBuildersAreGreenStep,
+        BuildStep,
+        RunTestsStep,
+        CommitStep,
+        ClosePatchStep,
+        CloseBugStep,
+    ]
 
 
 class LandAttachment(AbstractPatchLandingCommand):

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list