Skip to content

Commit

Permalink
[webkit-patch] Remove land-cowhand, undeprecate rebaseline-server
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=221991

Reviewed by Jonathan Bedard.

This gets rid of the two last deprecated annotations, and then goes
through and deletes a lot of dead code in webkitpy.tool, as we haven't
previously done a proper cleanup from the prior removals.

* Tools/Scripts/webkitpy/common/system/outputtee.py:
(Tee.write):
(OutputTee): Deleted.
(OutputTee.__init__): Deleted.
(OutputTee.add_log): Deleted.
(OutputTee.remove_log): Deleted.
(OutputTee._open_log_file): Deleted.
(OutputTee._tee_outputs_to_files): Deleted.
* Tools/Scripts/webkitpy/test/main.py:
(main):
* Tools/Scripts/webkitpy/tool/bot/botinfo.py: Removed.
* Tools/Scripts/webkitpy/tool/bot/botinfo_unittest.py: Removed.
* Tools/Scripts/webkitpy/tool/bot/queueengine.py:
(QueueEngine):
(QueueEngine.exit_after_handled_error):
(TerminateQueue): Deleted.
(QueueEngineDelegate): Deleted.
(QueueEngineDelegate.queue_log_path): Deleted.
(QueueEngineDelegate.work_item_log_path): Deleted.
(QueueEngineDelegate.begin_work_queue): Deleted.
(QueueEngineDelegate.should_continue_work_queue): Deleted.
(QueueEngineDelegate.next_work_item): Deleted.
(QueueEngineDelegate.process_work_item): Deleted.
(QueueEngineDelegate.handle_unexpected_error): Deleted.
(QueueEngine.__init__): Deleted.
(QueueEngine.run): Deleted.
(QueueEngine._stopping): Deleted.
(QueueEngine._begin_logging): Deleted.
(QueueEngine._open_work_log): Deleted.
(QueueEngine._ensure_work_log_closed): Deleted.
(QueueEngine._now): Deleted.
(QueueEngine._sleep_message): Deleted.
(QueueEngine._sleep): Deleted.
* Tools/Scripts/webkitpy/tool/bot/queueengine_unittest.py: Removed.
* Tools/Scripts/webkitpy/tool/commands/__init__.py:
* Tools/Scripts/webkitpy/tool/commands/abstractlocalservercommand.py:
* Tools/Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py:
* Tools/Scripts/webkitpy/tool/commands/commandtest.py:
* Tools/Scripts/webkitpy/tool/commands/download.py:
(_prepare_state):
(ProcessBugsMixin._fetch_list_of_patches_to_process):
(LandCowhand): Deleted.
(LandCowhand._prepare_state): Deleted.
(ProcessURLsMixin): Deleted.
(ProcessURLsMixin._fetch_list_of_patches_to_process): Deleted.
* Tools/Scripts/webkitpy/tool/commands/download_unittest.py:
(test_land_cowhand): Deleted.
* Tools/Scripts/webkitpy/tool/commands/format.py:
* Tools/Scripts/webkitpy/tool/commands/prettydiff.py:
* Tools/Scripts/webkitpy/tool/commands/queries.py:
* Tools/Scripts/webkitpy/tool/commands/queues.py: Removed.
* Tools/Scripts/webkitpy/tool/commands/queues_unittest.py: Removed.
* Tools/Scripts/webkitpy/tool/commands/queuestest.py: Removed.
* Tools/Scripts/webkitpy/tool/commands/rebaselineserver.py:
(TestConfig.__init__):
* Tools/Scripts/webkitpy/tool/commands/stepsequence.py:
(StepSequenceErrorHandler): Deleted.
(StepSequenceErrorHandler.handle_script_error): Deleted.
(StepSequenceErrorHandler.handle_checkout_needs_update): Deleted.
* Tools/Scripts/webkitpy/tool/commands/suggestnominations.py:
* Tools/Scripts/webkitpy/tool/commands/upload.py:
* Tools/Scripts/webkitpy/tool/commands/upload_unittest.py:
* Tools/Scripts/webkitpy/tool/comments.py:
* Tools/Scripts/webkitpy/tool/main.py:
* Tools/Scripts/webkitpy/tool/mocktool.py:
* Tools/Scripts/webkitpy/tool/multicommandtool.py:
* Tools/Scripts/webkitpy/tool/multicommandtool_unittest.py:
* Tools/Scripts/webkitpy/tool/servers/gardeningserver.py: Removed.
* Tools/Scripts/webkitpy/tool/servers/gardeningserver_unittest.py: Removed.
* Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py:
* Tools/Scripts/webkitpy/tool/steps/__init__.py:
* Tools/Scripts/webkitpy/tool/steps/addradar.py:
* Tools/Scripts/webkitpy/tool/steps/applywatchlist.py:
* Tools/Scripts/webkitpy/tool/steps/applywatchlist_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/attachtobug.py: Removed.
* Tools/Scripts/webkitpy/tool/steps/checkpatchrelevance.py: Removed.
* Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory.py:
* Tools/Scripts/webkitpy/tool/steps/cleanworkingdirectory_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/commit.py:
* Tools/Scripts/webkitpy/tool/steps/commit_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/confirmdiff.py:
* Tools/Scripts/webkitpy/tool/steps/discardlocalchanges.py:
* Tools/Scripts/webkitpy/tool/steps/discardlocalchanges_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/formatcppfiles.py:
* Tools/Scripts/webkitpy/tool/steps/haslanded.py: Removed.
* Tools/Scripts/webkitpy/tool/steps/haslanded_unittest.py: Removed.
* Tools/Scripts/webkitpy/tool/steps/metastep.py: Removed.
* Tools/Scripts/webkitpy/tool/steps/preparechangelog_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert.py:
* Tools/Scripts/webkitpy/tool/steps/preparechangelogforrevert_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/sortxcodeprojectfiles.py:
(SortXcodeProjectFiles.run):
* Tools/Scripts/webkitpy/tool/steps/steps_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/suggestreviewers_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py:
* Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py:
* Tools/Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py:

Canonical link: https://commits.webkit.org/271648@main
  • Loading branch information
gsnedders committed Dec 7, 2023
1 parent b6d6257 commit ba8968d
Show file tree
Hide file tree
Showing 58 changed files with 130 additions and 1,952 deletions.
40 changes: 0 additions & 40 deletions Tools/Scripts/webkitpy/common/system/outputtee.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
# (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 codecs
import os
import sys


# Simple class to split output between multiple destinations
class Tee:
Expand All @@ -41,39 +37,3 @@ def __init__(self, *files):
def write(self, bytes):
for file in self.files:
file.write(bytes)


class OutputTee:
def __init__(self):
self._original_stdout = None
self._original_stderr = None
self._files_for_output = []

def add_log(self, path):
log_file = self._open_log_file(path)
self._files_for_output.append(log_file)
self._tee_outputs_to_files(self._files_for_output)
return log_file

def remove_log(self, log_file):
self._files_for_output.remove(log_file)
self._tee_outputs_to_files(self._files_for_output)
log_file.close()

@staticmethod
def _open_log_file(log_path):
(log_directory, log_name) = os.path.split(log_path)
if log_directory and not os.path.exists(log_directory):
os.makedirs(log_directory)
return codecs.open(log_path, "a+", "utf-8")

def _tee_outputs_to_files(self, files):
if not self._original_stdout:
self._original_stdout = sys.stdout
self._original_stderr = sys.stderr
if files and len(files):
sys.stdout = Tee(self._original_stdout, *files)
sys.stderr = Tee(self._original_stderr, *files)
else:
sys.stdout = self._original_stdout
sys.stderr = self._original_stderr
6 changes: 1 addition & 5 deletions Tools/Scripts/webkitpy/test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,19 @@ def main():
"webkitpy.test.finder_unittest",
"webkitpy.test.main_unittest",
"webkitpy.test.runner_unittest",
"webkitpy.tool.bot.botinfo_unittest",
"webkitpy.tool.bot.queueengine_unittest",
"webkitpy.tool.commands.applywatchlistlocal_unittest",
"webkitpy.tool.commands.download_unittest",
"webkitpy.tool.commands.queues_unittest",
"webkitpy.tool.commands.suggestnominations_unittest",
"webkitpy.tool.commands.upload_unittest",
"webkitpy.tool.mocktool_unittest",
"webkitpy.tool.multicommandtool_unittest",
"webkitpy.tool.servers.gardeningserver_unittest",
"webkitpy.tool.servers.rebaselineserver_unittest",
"webkitpy.tool.servers.reflectionhandler_unittest",
"webkitpy.tool.steps.applywatchlist_unittest",
"webkitpy.tool.steps.cleanworkingdirectory_unittest",
"webkitpy.tool.steps.closebugforlanddiff_unittest",
"webkitpy.tool.steps.commit_unittest",
"webkitpy.tool.steps.discardlocalchanges_unittest",
"webkitpy.tool.steps.haslanded_unittest",
"webkitpy.tool.steps.preparechangelog_unittest",
"webkitpy.tool.steps.preparechangelogforrevert_unittest",
"webkitpy.tool.steps.steps_unittest",
Expand Down Expand Up @@ -335,6 +330,7 @@ def main():
}

all_tests = set(tester.finder.find_names([], True))
assert len(py2_tests - all_tests) == 0, py2_tests - all_tests

if sys.version_info < (3,):
tester.expect_error_on_import(
Expand Down
37 changes: 0 additions & 37 deletions Tools/Scripts/webkitpy/tool/bot/botinfo.py

This file was deleted.

40 changes: 0 additions & 40 deletions Tools/Scripts/webkitpy/tool/bot/botinfo_unittest.py

This file was deleted.

126 changes: 0 additions & 126 deletions Tools/Scripts/webkitpy/tool/bot/queueengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,141 +29,15 @@

import logging
import sys
import traceback

from datetime import datetime, timedelta

from webkitpy.common.host import Host
from webkitpy.common.system import logutils
from webkitpy.common.system.executive import ScriptError
from webkitpy.common.system.outputtee import OutputTee

_log = logging.getLogger(__name__)


# FIXME: This will be caught by "except Exception:" blocks, we should consider
# making this inherit from SystemExit instead (or BaseException, except that's not recommended).
class TerminateQueue(Exception):
pass


class QueueEngineDelegate:
def queue_log_path(self):
raise NotImplementedError('subclasses must implement')

def work_item_log_path(self, work_item):
raise NotImplementedError('subclasses must implement')

def begin_work_queue(self):
raise NotImplementedError('subclasses must implement')

def should_continue_work_queue(self):
raise NotImplementedError('subclasses must implement')

def next_work_item(self):
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 QueueEngine:
def __init__(self, name, delegate, wakeup_event, seconds_to_sleep=120):
self._name = name
self._delegate = delegate
self._wakeup_event = wakeup_event
self._output_tee = OutputTee()
self._seconds_to_sleep = seconds_to_sleep

log_date_format = "%Y-%m-%d %H:%M:%S"
handled_error_code = 2

# Child processes exit with a special code to the parent queue process can detect the error was handled.
@classmethod
def exit_after_handled_error(cls, error):
_log.error(error)
sys.exit(cls.handled_error_code)

def run(self):
self._begin_logging()

self._delegate.begin_work_queue()
while (self._delegate.should_continue_work_queue()):
try:
self._ensure_work_log_closed()
work_item = self._delegate.next_work_item()
if not work_item:
self._sleep("No work item.")
continue

try:
if not self._delegate.process_work_item(work_item):
_log.warning("Unable to process work item.")
continue
except ScriptError as e:
self._open_work_log(work_item)
self._work_log.write(e.message_with_output(output_limit=5000))
# Use a special exit code to indicate that the error was already
# handled in the child process and we should just keep looping.
if e.exit_code == self.handled_error_code:
continue
message = "Unexpected failure when processing patch! Please file a bug against webkit-patch.\n%s" % e.message_with_output(output_limit=5000)
self._delegate.handle_unexpected_error(work_item, message)
except TerminateQueue:
self._stopping("TerminateQueue exception received.")
return 0
except KeyboardInterrupt:
self._stopping("User terminated queue.")
return 1
except Exception:
traceback.print_exc()
# Don't try tell the status bot, in case telling it causes an exception.
self._sleep("Exception while preparing queue")
self._stopping("Delegate terminated queue.")
return 0

def _stopping(self, message):
_log.info(message)
logging.getLogger("webkitpy").removeHandler(self._log_handler)
# Be careful to shut down our OutputTee or the unit tests will be unhappy.
self._ensure_work_log_closed()
self._output_tee.remove_log(self._queue_log)

def _begin_logging(self):
_queue_log_path = self._delegate.queue_log_path()
# We are using logging.getLogger("webkitpy") instead of _log since we want to capture all messages logged from webkitpy modules.
self._log_handler = logutils.configure_logger_to_log_to_file(logging.getLogger("webkitpy"), _queue_log_path, Host().filesystem)
self._queue_log = self._output_tee.add_log(_queue_log_path)
self._work_log = None

def _open_work_log(self, work_item):
work_item_log_path = self._delegate.work_item_log_path(work_item)
if not work_item_log_path:
return
self._work_log = self._output_tee._open_log_file(work_item_log_path)

def _ensure_work_log_closed(self):
# If we still have a bug log open, close it.
if self._work_log:
self._work_log.close()
self._work_log = None

def _now(self):
"""Overriden by the unit tests to allow testing _sleep_message"""
return datetime.now()

def _sleep_message(self, message):
wake_time = self._now() + timedelta(seconds=self._seconds_to_sleep)
if self._seconds_to_sleep < 3 * 60:
sleep_duration_text = str(self._seconds_to_sleep) + ' seconds'
else:
sleep_duration_text = str(round(self._seconds_to_sleep / 60)) + ' minutes'
return "%s Sleeping until %s (%s)." % (message, wake_time.strftime(self.log_date_format), sleep_duration_text)

def _sleep(self, message):
_log.info(self._sleep_message(message))
self._wakeup_event.wait(self._seconds_to_sleep)
self._wakeup_event.clear()
Loading

0 comments on commit ba8968d

Please sign in to comment.