2009-11-19 Adam Barth <abarth@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Nov 2009 07:01:26 +0000 (07:01 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Nov 2009 07:01:26 +0000 (07:01 +0000)
        Reviewed by Eric Seidel.

        Abstract AbstractPatchProcessingCommand from AbstractPatchLandingCommand
        https://bugs.webkit.org/show_bug.cgi?id=31707

        This is to help when we implement build-attachment.

        * Scripts/bugzilla-tool:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51232 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/bugzilla-tool

index b1d20897bd983d2c41060e1c9fadf6882a6b09a0..77f6a728be6eba69df7c3e6dd226959454f35c25 100644 (file)
@@ -1,3 +1,14 @@
+2009-11-19  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Abstract AbstractPatchProcessingCommand from AbstractPatchLandingCommand
+        https://bugs.webkit.org/show_bug.cgi?id=31707
+
+        This is to help when we implement build-attachment.
+
+        * Scripts/bugzilla-tool:
+
 2009-11-19  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index fe34945e387df4855a3bbd0bc90add8bf1add8e3..7ac18029201ab92e69ac5cd404ab3505182ef22c 100755 (executable)
@@ -386,13 +386,14 @@ class LandDiff(Command):
             log("No bug id provided.")
 
 
-class AbstractPatchLandingCommand(Command):
-    def __init__(self, description, args_description):
-        options = WebKitLandingScripts.cleaning_options() + WebKitLandingScripts.land_options()
+class AbstractPatchProcessingCommand(Command):
+    def __init__(self, description, args_description, options):
         Command.__init__(self, description, args_description, options=options)
 
-    @staticmethod
-    def _fetch_list_of_patches_to_land(options, args, tool):
+    def _fetch_list_of_patches_to_process(self, options, args, tool):
+        raise NotImplementedError, "subclasses must implement"
+
+    def _prepare_to_process(self, options, args, tool):
         raise NotImplementedError, "subclasses must implement"
 
     @staticmethod
@@ -407,26 +408,36 @@ class AbstractPatchLandingCommand(Command):
         if not args:
             error("%s required" % self.argument_names)
 
-        # Check the tree status first so we can fail early.
-        WebKitLandingScripts.ensure_builders_are_green(tool.buildbot, options)
-        WebKitLandingScripts.prepare_clean_working_directory(tool.scm(), options)
-
-        patches = self._fetch_list_of_patches_to_land(options, args, tool)
+        self._prepare_to_process(options, args, tool)
+        patches = self._fetch_list_of_patches_to_process(options, args, tool)
 
         # It's nice to print out total statistics.
         bugs_to_patches = self._collect_patches_by_bug(patches)
-        log("Landing %s from %s." % (pluralize("patch", len(patches)), pluralize("bug", len(bugs_to_patches))))
+        log("Processing %s from %s." % (pluralize("patch", len(patches)), pluralize("bug", len(bugs_to_patches))))
 
         for patch in patches:
-            WebKitLandingScripts.land_patch_and_handle_errors(patch, options, tool)
+            self._process_patch(patch, options, args, tool)
+
+
+class AbstractPatchLandingCommand(AbstractPatchProcessingCommand):
+    def __init__(self, description, args_description):
+        options = WebKitLandingScripts.cleaning_options() + WebKitLandingScripts.land_options()
+        AbstractPatchProcessingCommand.__init__(self, description, args_description, options)
+
+    def _prepare_to_process(self, options, args, tool):
+        # Check the tree status first so we can fail early.
+        WebKitLandingScripts.ensure_builders_are_green(tool.buildbot, options)
+        WebKitLandingScripts.prepare_clean_working_directory(tool.scm(), options)
+
+    def _process_patch(self, patch, options, args, tool):
+        WebKitLandingScripts.land_patch_and_handle_errors(patch, options, tool)
 
 
 class LandAttachment(AbstractPatchLandingCommand):
     def __init__(self):
         AbstractPatchLandingCommand.__init__(self, "Lands a patches from bugzilla, optionally building and testing them first", "ATTACHMENT_ID [ATTACHMENT_IDS]")
 
-    @staticmethod
-    def _fetch_list_of_patches_to_land(options, args, tool):
+    def _fetch_list_of_patches_to_process(self, options, args, tool):
         return map(lambda patch_id: tool.bugs.fetch_attachment(patch_id), args)
 
 
@@ -434,8 +445,7 @@ class LandPatches(AbstractPatchLandingCommand):
     def __init__(self):
         AbstractPatchLandingCommand.__init__(self, "Lands all patches on the given bugs, optionally building and testing them first", "BUGID [BUGIDS]")
 
-    @staticmethod
-    def _fetch_list_of_patches_to_land(options, args, tool):
+    def _fetch_list_of_patches_to_process(self, options, args, tool):
         all_patches = []
         for bug_id in args:
             patches = tool.bugs.fetch_reviewed_patches_from_bug(bug_id)