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

abarth at webkit.org abarth at webkit.org
Wed Apr 7 23:42:38 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit c7602caa5be093485e200e4d9c0d5b806c1d7230
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 16 08:28:18 2009 +0000

    2009-11-16  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Move WorkQueue to its own file
            https://bugs.webkit.org/show_bug.cgi?id=31529
    
            WorkQueue and WorkQueueDelegate are separate concerns from
            bugzilla-tool.  Also added a missing include to logging.py.
    
            * Scripts/bugzilla-tool:
            * Scripts/modules/logging.py:
            * Scripts/modules/workqueue.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51014 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 636dd4d..8cf707f 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,6 +1,20 @@
 2009-11-16  Adam Barth  <abarth at webkit.org>
 
-        Reviewed by Eric Siedel.
+        Reviewed by Eric Seidel.
+
+        Move WorkQueue to its own file
+        https://bugs.webkit.org/show_bug.cgi?id=31529
+
+        WorkQueue and WorkQueueDelegate are separate concerns from
+        bugzilla-tool.  Also added a missing include to logging.py.
+
+        * Scripts/bugzilla-tool:
+        * Scripts/modules/logging.py:
+        * Scripts/modules/workqueue.py:
+
+2009-11-16  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
 
         Move OutputTee to logging.py.
 
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index 6fea61f..192ca3e 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -44,10 +44,11 @@ from optparse import OptionParser, IndentedHelpFormatter, SUPPRESS_USAGE, make_o
 from modules.bugzilla import Bugzilla, parse_bug_id
 from modules.changelogs import ChangeLog
 from modules.comments import bug_comment_from_commit_text
-from modules.logging import error, log, tee, OutputTee
+from modules.logging import error, log, tee
 from modules.scm import CommitMessage, detect_scm_system, ScriptError, CheckoutNeedsUpdate
 from modules.buildbot import BuildBot
 from modules.statusbot import StatusBot
+from modules.workqueue import WorkQueue, WorkQueueDelegate
 
 def plural(noun):
     # This is a dumb plural() implementation which was just enough for our uses.
@@ -674,109 +675,7 @@ class CheckTreeStatus(Command):
             print "%s : %s" % (status_string.ljust(4), builder['name'])
 
 
-class WorkQueueDelegate:
-    def queue_log_path(self):
-        raise NotImplementedError, "subclasses must implement"
-
-    def work_logs_directory(self):
-        raise NotImplementedError, "subclasses must implement"
-
-    def status_host(self):
-        raise NotImplementedError, "subclasses must implement"
-
-    def begin_work_queue(self):
-        raise NotImplementedError, "subclasses must implement"
-
-    def next_work_item(self):
-        raise NotImplementedError, "subclasses must implement"
-
-    def should_proceed_with_work_item(self, work_item):
-        # returns (safe_to_proceed, waiting_message, bug_id)
-        raise NotImplementedError, "subclasses must implement"
-
-    def process_work_item(self, work_item):
-        raise NotImplementedError, "subclasses must implement"
-
-    def handle_unexpected_error(self, work_item, message):
-        raise NotImplementedError, "subclasses must implement"
-
-
-class WorkQueue:
-    def __init__(self, delegate):
-        self._delegate = delegate
-        self._output_tee = OutputTee()
-
-    log_date_format = "%Y-%m-%d %H:%M:%S"
-    sleep_duration_text = "5 mins"
-    seconds_to_sleep = 300
-
-    def run(self):
-        self._begin_logging()
-        self.status_bot = StatusBot(host=self._delegate.status_host())
-
-        self._delegate.begin_work_queue()
-        while (True):
-            self._ensure_work_log_closed()
-            try:
-                work_item = self._delegate.next_work_item()
-                if not work_item:
-                    self._update_status_and_sleep("Empty queue.")
-                    continue
-                (safe_to_proceed, waiting_message, bug_id) = self._delegate.should_proceed_with_work_item(work_item)
-                if not safe_to_proceed:
-                    self._update_status_and_sleep(waiting_message, bug_ig=bug_id)
-                    continue
-                self.status_bot.update_status(waiting_message, bug_id=bug_id)
-            except Exception, e:
-                # Don't try tell the status bot, in case telling it causes an exception.
-                self._sleep("Exception while preparing queue: %s." % e)
-                continue
-
-            self._open_work_log(bug_id)
-            try:
-                self._delegate.process_work_item(work_item)
-            except ScriptError, e:
-                # exit(2) is a special exit code we use to indicate that the error was already
-                # handled by and we should keep looping anyway.
-                if e.exit_code == 2:
-                    continue
-                message = "Unexpected failure when landing patch!  Please file a bug against bugzilla-tool.\n%s" % e.message_with_output()
-                self._delegate.handle_unexpected_error(work_item, message)
-        # Never reached.
-        self._ensure_work_log_closed()
-
-    def _begin_logging(self):
-        self._queue_log = self._output_tee.add_log(self._delegate.queue_log_path())
-        self._work_log = None
-
-    def _open_work_log(self, bug_id):
-        work_log_path = os.path.join(self._delegate.work_logs_directory(), "%s.log" % bug_id)
-        self._work_log = self._output_tee.add_log(work_log_path)
-
-    def _ensure_work_log_closed(self):
-        # If we still have a bug log open, close it.
-        if self._work_log:
-            self._output_tee.remove_log(self._work_log)
-            self._work_log = None
-
-    @classmethod
-    def _sleep_message(cls, message):
-        wake_time = datetime.now() + timedelta(seconds=cls.seconds_to_sleep)
-        return "%s Sleeping until %s (%s)." % (message, wake_time.strftime(cls.log_date_format), cls.sleep_duration_text)
-
-    @classmethod
-    def _sleep(cls, message):
-        log(cls._sleep_message(message))
-        time.sleep(cls.seconds_to_sleep)
-
-    def _update_status_and_sleep(self, message):
-        status_message = self._sleep_message(message)
-        self.status_bot.update_status(status_message)
-        log(status_message)
-        time.sleep(self.seconds_to_sleep)
-
-
-class LandPatchesFromCommitQueue(Command):
+class LandPatchesFromCommitQueue(Command, WorkQueueDelegate):
     def __init__(self):
         options = [
             make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Do not ask the user for confirmation before running the queue.  Dangerous!"),
diff --git a/WebKitTools/Scripts/modules/logging.py b/WebKitTools/Scripts/modules/logging.py
index e8c8be6..7b7cec5 100644
--- a/WebKitTools/Scripts/modules/logging.py
+++ b/WebKitTools/Scripts/modules/logging.py
@@ -29,6 +29,7 @@
 #
 # WebKit's Python module for logging
 
+import os
 import sys
 
 def log(string):
diff --git a/WebKitTools/Scripts/modules/workqueue.py b/WebKitTools/Scripts/modules/workqueue.py
new file mode 100644
index 0000000..379dfb6
--- /dev/null
+++ b/WebKitTools/Scripts/modules/workqueue.py
@@ -0,0 +1,139 @@
+#!/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.
+
+import os
+import time
+
+from datetime import datetime, timedelta
+
+from logging import log, OutputTee
+from scm import ScriptError
+from statusbot import StatusBot
+
+class WorkQueueDelegate:
+    def queue_log_path(self):
+        raise NotImplementedError, "subclasses must implement"
+
+    def work_logs_directory(self):
+        raise NotImplementedError, "subclasses must implement"
+
+    def status_host(self):
+        raise NotImplementedError, "subclasses must implement"
+
+    def begin_work_queue(self):
+        raise NotImplementedError, "subclasses must implement"
+
+    def next_work_item(self):
+        raise NotImplementedError, "subclasses must implement"
+
+    def should_proceed_with_work_item(self, work_item):
+        # returns (safe_to_proceed, waiting_message, bug_id)
+        raise NotImplementedError, "subclasses must implement"
+
+    def process_work_item(self, work_item):
+        raise NotImplementedError, "subclasses must implement"
+
+    def handle_unexpected_error(self, work_item, message):
+        raise NotImplementedError, "subclasses must implement"
+
+
+class WorkQueue:
+    def __init__(self, delegate):
+        self._delegate = delegate
+        self._output_tee = OutputTee()
+
+    log_date_format = "%Y-%m-%d %H:%M:%S"
+    sleep_duration_text = "5 mins"
+    seconds_to_sleep = 300
+
+    def run(self):
+        self._begin_logging()
+        self.status_bot = StatusBot(host=self._delegate.status_host())
+
+        self._delegate.begin_work_queue()
+        while (True):
+            self._ensure_work_log_closed()
+            try:
+                work_item = self._delegate.next_work_item()
+                if not work_item:
+                    self._update_status_and_sleep("Empty queue.")
+                    continue
+                (safe_to_proceed, waiting_message, bug_id) = self._delegate.should_proceed_with_work_item(work_item)
+                if not safe_to_proceed:
+                    self._update_status_and_sleep(waiting_message, bug_ig=bug_id)
+                    continue
+                self.status_bot.update_status(waiting_message, bug_id=bug_id)
+            except Exception, e:
+                # Don't try tell the status bot, in case telling it causes an exception.
+                self._sleep("Exception while preparing queue: %s." % e)
+                continue
+
+            self._open_work_log(bug_id)
+            try:
+                self._delegate.process_work_item(work_item)
+            except ScriptError, e:
+                # exit(2) is a special exit code we use to indicate that the error was already
+                # handled by and we should keep looping anyway.
+                if e.exit_code == 2:
+                    continue
+                message = "Unexpected failure when landing patch!  Please file a bug against bugzilla-tool.\n%s" % e.message_with_output()
+                self._delegate.handle_unexpected_error(work_item, message)
+        # Never reached.
+        self._ensure_work_log_closed()
+
+    def _begin_logging(self):
+        self._queue_log = self._output_tee.add_log(self._delegate.queue_log_path())
+        self._work_log = None
+
+    def _open_work_log(self, bug_id):
+        work_log_path = os.path.join(self._delegate.work_logs_directory(), "%s.log" % bug_id)
+        self._work_log = self._output_tee.add_log(work_log_path)
+
+    def _ensure_work_log_closed(self):
+        # If we still have a bug log open, close it.
+        if self._work_log:
+            self._output_tee.remove_log(self._work_log)
+            self._work_log = None
+
+    @classmethod
+    def _sleep_message(cls, message):
+        wake_time = datetime.now() + timedelta(seconds=cls.seconds_to_sleep)
+        return "%s Sleeping until %s (%s)." % (message, wake_time.strftime(cls.log_date_format), cls.sleep_duration_text)
+
+    @classmethod
+    def _sleep(cls, message):
+        log(cls._sleep_message(message))
+        time.sleep(cls.seconds_to_sleep)
+
+    def _update_status_and_sleep(self, message):
+        status_message = self._sleep_message(message)
+        self.status_bot.update_status(status_message)
+        log(status_message)
+        time.sleep(self.seconds_to_sleep)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list