3 final class PhabricatorRepositoryManagementMaintenanceWorkflow
4 extends PhabricatorRepositoryManagementWorkflow
{
6 protected function didConstruct() {
8 ->setName('maintenance')
10 "**maintenance** --start __message__ __repository__ ...\n".
11 "**maintenance** --stop __repository__")
13 pht('Set or clear read-only mode for repository maintenance.'))
20 'Put repositories into maintenance mode.'),
25 'Take repositories out of maintenance mode, returning them '.
29 'name' => 'repositories',
35 public function execute(PhutilArgumentParser
$args) {
36 $viewer = $this->getViewer();
38 $repositories = $this->loadRepositories($args, 'repositories');
40 throw new PhutilArgumentUsageException(
41 pht('Specify one or more repositories to act on.'));
44 $message = $args->getArg('start');
45 $is_start = (bool)strlen($message);
46 $is_stop = $args->getArg('stop');
48 if (!$is_start && !$is_stop) {
49 throw new PhutilArgumentUsageException(
51 'Use "--start <message>" to put repositories into maintenance '.
52 'mode, or "--stop" to take them out of maintenance mode.'));
55 if ($is_start && $is_stop) {
56 throw new PhutilArgumentUsageException(
58 'Specify either "--start" or "--stop", but not both.'));
61 $content_source = $this->newContentSource();
62 $diffusion_phid = id(new PhabricatorDiffusionApplication())->getPHID();
65 $new_value = $message;
70 foreach ($repositories as $repository) {
73 $xactions[] = $repository->getApplicationTransactionTemplate()
75 PhabricatorRepositoryMaintenanceTransaction
::TRANSACTIONTYPE
)
76 ->setNewValue($new_value);
78 $repository->getApplicationTransactionEditor()
80 ->setActingAsPHID($diffusion_phid)
81 ->setContentSource($content_source)
82 ->setContinueOnNoEffect(true)
83 ->setContinueOnMissingFields(true)
84 ->applyTransactions($repository, $xactions);
90 'Put repository "%s" into maintenance mode.',
91 $repository->getDisplayName()));
96 'Took repository "%s" out of maintenance mode.',
97 $repository->getDisplayName()));