From 1b51b741351ddbe927856fc6da1a5f31dfd031c5 Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 16 Oct 2012 10:21:56 -0700 Subject: [PATCH] Provide a hook for aborted workflow Summary: We start Sandcastle push when `arc diff` starts. If `arc diff` throws then HHVM waits for finishing the futures. We need to kill them sooner. Test Plan: Will implement the hook. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3713 --- scripts/arcanist.php | 28 +++++++++++---------- src/configuration/ArcanistConfiguration.php | 10 +++++++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index f6a41de3..64938ede 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -319,26 +319,28 @@ try { $config->didRunWorkflow($command, $workflow, $err); exit((int)$err); -} catch (ArcanistUsageException $ex) { - echo phutil_console_format( - "**Usage Exception:** %s\n", - $ex->getMessage()); +} catch (Exception $ex) { + $is_usage = ($ex instanceof ArcanistUsageException); + if ($is_usage) { + echo phutil_console_format( + "**Usage Exception:** %s\n", + $ex->getMessage()); + } + + $config->didAbortWorkflow($command, $workflow, $ex); + if ($config_trace_mode) { echo "\n"; throw $ex; } - exit(1); -} catch (Exception $ex) { - if ($config_trace_mode) { - throw $ex; + if (!$is_usage) { + echo phutil_console_format( + "**Exception**\n%s\n%s\n", + $ex->getMessage(), + "(Run with --trace for a full exception trace.)"); } - echo phutil_console_format( - "**Exception**\n%s\n%s\n", - $ex->getMessage(), - "(Run with --trace for a full exception trace.)"); - exit(1); } diff --git a/src/configuration/ArcanistConfiguration.php b/src/configuration/ArcanistConfiguration.php index 696b8e77..f8af6909 100644 --- a/src/configuration/ArcanistConfiguration.php +++ b/src/configuration/ArcanistConfiguration.php @@ -29,7 +29,7 @@ * - create, replace, or disable workflows by overriding buildWorkflow() * and buildAllWorkflows(); * - add additional steps before or after workflows run by overriding - * willRunWorkflow() or didRunWorkflow(); and + * willRunWorkflow() or didRunWorkflow() or didAbortWorkflow(); and * - add new flags to existing workflows by overriding * getCustomArgumentsForCommand(). * @@ -93,6 +93,14 @@ class ArcanistConfiguration { // This is a hook. } + public function didAbortWorkflow( + $command, + ArcanistBaseWorkflow $workflow, + Exception $ex) { + + // This is a hook. + } + public function getCustomArgumentsForCommand($command) { return array(); }