1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-24 15:52:40 +01:00

Clean up push failure messaging in "arc land" slightly

Summary: Ref PHI1808. Currently, push failures are messaged awkwardly. Make this exception handling more selective and the user-facing behavior more readable.

Test Plan: Ran "arc land" against a failing remote, saw a human-readable message instead of a stack trace.

Differential Revision: https://secure.phabricator.com/D21395
This commit is contained in:
epriestley 2020-07-08 13:35:18 -07:00
parent 710bceab10
commit 3633364bb9
5 changed files with 12 additions and 11 deletions

View file

@ -307,6 +307,7 @@ phutil_register_library_map(array(
'ArcanistLandCommit' => 'land/ArcanistLandCommit.php',
'ArcanistLandCommitSet' => 'land/ArcanistLandCommitSet.php',
'ArcanistLandEngine' => 'land/engine/ArcanistLandEngine.php',
'ArcanistLandPushFailureException' => 'land/exception/ArcanistLandPushFailureException.php',
'ArcanistLandSymbol' => 'land/ArcanistLandSymbol.php',
'ArcanistLandTarget' => 'land/ArcanistLandTarget.php',
'ArcanistLandWorkflow' => 'workflow/ArcanistLandWorkflow.php',
@ -1352,6 +1353,7 @@ phutil_register_library_map(array(
'ArcanistLandCommit' => 'Phobject',
'ArcanistLandCommitSet' => 'Phobject',
'ArcanistLandEngine' => 'ArcanistWorkflowEngine',
'ArcanistLandPushFailureException' => 'Exception',
'ArcanistLandSymbol' => 'Phobject',
'ArcanistLandTarget' => 'Phobject',
'ArcanistLandWorkflow' => 'ArcanistArcWorkflow',

View file

@ -491,7 +491,7 @@ final class ArcanistGitLandEngine
$flags_argv,
$into_commit);
if ($err) {
throw new ArcanistUsageException(
throw new ArcanistLandPushFailureException(
pht(
'Submit failed! Fix the error and run "arc land" again.'));
}
@ -509,16 +509,10 @@ final class ArcanistGitLandEngine
$this->newOntoRefArguments($into_commit));
if ($err) {
throw new ArcanistUsageException(
throw new ArcanistLandPushFailureException(
pht(
'Push failed! Fix the error and run "arc land" again.'));
}
// TODO
// if ($this->isGitSvn) {
// $err = phutil_passthru('git svn dcommit');
// $cmd = 'git svn dcommit';
}
protected function reconcileLocalState(

View file

@ -1259,7 +1259,7 @@ abstract class ArcanistLandEngine
try {
$this->pushChange($into_commit);
$this->setHasUnpushedChanges(false);
} catch (Exception $ex) {
} catch (ArcanistLandPushFailureException $ex) {
// TODO: If the push fails, fetch and retry if the remote ref
// has moved ahead of us.
@ -1280,7 +1280,8 @@ abstract class ArcanistLandEngine
continue;
}
throw $ex;
throw new PhutilArgumentUsageException(
$ex->getMessage());
}
if ($need_cascade) {

View file

@ -836,7 +836,7 @@ final class ArcanistMercurialLandEngine
foreach ($body as $command) {
$err = $this->newPassthru('%Ls', $command);
if ($err) {
throw new ArcanistUsageException(
throw new ArcanistLandPushFailureException(
pht(
'Push failed! Fix the error and run "arc land" again.'));
}

View file

@ -0,0 +1,4 @@
<?php
final class ArcanistLandPushFailureException
extends Exception {}