Differential D14924 Diff 36062 src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php
Show All 22 Lines | $this | ||||
->setArguments( | ->setArguments( | ||||
array( | array( | ||||
array( | array( | ||||
'name' => 'revision', | 'name' => 'revision', | ||||
'wildcard' => true, | 'wildcard' => true, | ||||
), | ), | ||||
array( | array( | ||||
'name' => 'all', | 'name' => 'all', | ||||
'param' => 'callsign or phid', | 'param' => 'repository', | ||||
'help' => pht( | 'help' => pht( | ||||
'Reparse all commits in the specified repository. This mode '. | 'Reparse all commits in the specified repository. This mode '. | ||||
'queues parsers into the task queue; you must run taskmasters '. | 'queues parsers into the task queue; you must run taskmasters '. | ||||
'to actually do the parses. Use with __%s__ to run '. | 'to actually do the parses. Use with __%s__ to run '. | ||||
'the tasks locally instead of with taskmasters.', | 'the tasks locally instead of with taskmasters.', | ||||
'--force-local'), | '--force-local'), | ||||
), | ), | ||||
array( | array( | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | if ($reparse_owners && !$force) { | ||||
if (!phutil_console_confirm(pht('Are you ready to continue?'))) { | if (!phutil_console_confirm(pht('Are you ready to continue?'))) { | ||||
throw new PhutilArgumentUsageException(pht('Cancelled.')); | throw new PhutilArgumentUsageException(pht('Cancelled.')); | ||||
} | } | ||||
} | } | ||||
$commits = array(); | $commits = array(); | ||||
if ($all_from_repo) { | if ($all_from_repo) { | ||||
$repository = id(new PhabricatorRepository())->loadOneWhere( | $repository = id(new PhabricatorRepositoryQuery()) | ||||
'callsign = %s OR phid = %s', | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
$all_from_repo, | ->withIdentifiers(array($all_from_repo)) | ||||
$all_from_repo); | ->executeOne(); | ||||
if (!$repository) { | if (!$repository) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht('Unknown repository %s!', $all_from_repo)); | pht('Unknown repository "%s"!', $all_from_repo)); | ||||
} | } | ||||
$query = id(new DiffusionCommitQuery()) | $query = id(new DiffusionCommitQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withRepository($repository); | ->withRepository($repository); | ||||
if ($min_timestamp) { | if ($min_timestamp) { | ||||
$query->withEpochRange($min_timestamp, null); | $query->withEpochRange($min_timestamp, null); | ||||
} | } | ||||
if ($importing) { | if ($importing) { | ||||
$query->withImporting(true); | $query->withImporting(true); | ||||
} | } | ||||
$commits = $query->execute(); | $commits = $query->execute(); | ||||
$callsign = $repository->getCallsign(); | |||||
if (!$commits) { | if (!$commits) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'No commits have been discovered in %s repository!', | 'No commits have been discovered in the "%s" repository!', | ||||
$callsign)); | $repository->getDisplayName())); | ||||
} | } | ||||
} else { | } else { | ||||
$commits = array(); | $commits = $this->loadNamedCommits($reparse_what); | ||||
foreach ($reparse_what as $identifier) { | |||||
$matches = null; | |||||
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $identifier, $matches)) { | |||||
throw new PhutilArgumentUsageException(pht( | |||||
"Can't parse commit identifier: %s", | |||||
$identifier)); | |||||
} | |||||
$callsign = $matches[1]; | |||||
$commit_identifier = $matches[2]; | |||||
$repository = id(new PhabricatorRepository())->loadOneWhere( | |||||
'callsign = %s', | |||||
$callsign); | |||||
if (!$repository) { | |||||
throw new PhutilArgumentUsageException(pht( | |||||
"No repository with callsign '%s'!", | |||||
$callsign)); | |||||
} | |||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( | |||||
'repositoryID = %d AND commitIdentifier = %s', | |||||
$repository->getID(), | |||||
$commit_identifier); | |||||
if (!$commit) { | |||||
throw new PhutilArgumentUsageException(pht( | |||||
"No matching commit '%s' in repository '%s'. ". | |||||
"(For git and mercurial repositories, you must specify the entire ". | |||||
"commit hash.)", | |||||
$commit_identifier, | |||||
$callsign)); | |||||
} | |||||
$commits[] = $commit; | |||||
} | |||||
} | } | ||||
if ($all_from_repo && !$force_local) { | if ($all_from_repo && !$force_local) { | ||||
$console->writeOut("%s\n", pht( | $console->writeOut("%s\n", pht( | ||||
"**NOTE**: This script will queue tasks to reparse the data. Once the ". | "**NOTE**: This script will queue tasks to reparse the data. Once the ". | ||||
"tasks have been queued, you need to run Taskmaster daemons to ". | "tasks have been queued, you need to run Taskmaster daemons to ". | ||||
"execute them.\n\n%s", | "execute them.\n\n%s", | ||||
pht( | pht( | ||||
'QUEUEING TASKS (%s Commit(s)):', | 'QUEUEING TASKS (%s Commit(s)):', | ||||
phutil_count($commits)))); | phutil_count($commits)))); | ||||
} | } | ||||
$progress = new PhutilConsoleProgressBar(); | $progress = new PhutilConsoleProgressBar(); | ||||
$progress->setTotal(count($commits)); | $progress->setTotal(count($commits)); | ||||
$tasks = array(); | $tasks = array(); | ||||
foreach ($commits as $commit) { | foreach ($commits as $commit) { | ||||
$repository = $commit->getRepository(); | |||||
if ($importing) { | if ($importing) { | ||||
$status = $commit->getImportStatus(); | $status = $commit->getImportStatus(); | ||||
// Find the first missing import step and queue that up. | // Find the first missing import step and queue that up. | ||||
$reparse_message = false; | $reparse_message = false; | ||||
$reparse_change = false; | $reparse_change = false; | ||||
$reparse_owners = false; | $reparse_owners = false; | ||||
$reparse_herald = false; | $reparse_herald = false; | ||||
if (!($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE)) { | if (!($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE)) { | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |