Show additional status information during repository import
Summary: Ref T2350. Fixes T2231. - Adds log flags around discovery. - Adds message flags for "needs update". This is basically an out-of-band hint to the daemons that a repository should be pulled sooner than normal. We set the flag when users push a revision, and expose a Conduit method that `arc land` will be able to use. Test Plan: See screenshots. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Maniphest Tasks: T2350, T2231 Differential Revision: https://secure.phabricator.com/D7467
This commit is contained in:
@@ -563,6 +563,8 @@ final class DiffusionRepositoryEditMainController
|
||||
private function buildRepositoryStatus(
|
||||
PhabricatorRepository $repository) {
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$view = new PHUIStatusListView();
|
||||
|
||||
$messages = id(new PhabricatorRepositoryStatusMessage())
|
||||
@@ -696,7 +698,7 @@ final class DiffusionRepositoryEditMainController
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('time-green')
|
||||
->setTarget(pht('Initializing Working Copy'))
|
||||
->setNote(pht('Daemons are initilizing the working copy.')));
|
||||
->setNote(pht('Daemons are initializing the working copy.')));
|
||||
return $view;
|
||||
default:
|
||||
$view->addItem(
|
||||
@@ -717,6 +719,92 @@ final class DiffusionRepositoryEditMainController
|
||||
}
|
||||
}
|
||||
|
||||
$message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_FETCH);
|
||||
if ($message) {
|
||||
switch ($message->getStatusCode()) {
|
||||
case PhabricatorRepositoryStatusMessage::CODE_ERROR:
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('warning-red')
|
||||
->setTarget(pht('Update Error'))
|
||||
->setNote($message->getParameter('message')));
|
||||
return $view;
|
||||
case PhabricatorRepositoryStatusMessage::CODE_OKAY:
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Updates OK'))
|
||||
->setNote(
|
||||
pht(
|
||||
'Last updated %s.',
|
||||
phabricator_datetime($message->getEpoch(), $viewer))));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('time-orange')
|
||||
->setTarget(pht('Waiting For Update'))
|
||||
->setNote(
|
||||
pht('Waiting for daemons to read updates.')));
|
||||
}
|
||||
|
||||
if ($repository->isImporting()) {
|
||||
$progress = queryfx_all(
|
||||
$repository->establishConnection('r'),
|
||||
'SELECT importStatus, count(*) N FROM %T WHERE repositoryID = %d
|
||||
GROUP BY importStatus',
|
||||
id(new PhabricatorRepositoryCommit())->getTableName(),
|
||||
$repository->getID());
|
||||
|
||||
$done = 0;
|
||||
$total = 0;
|
||||
foreach ($progress as $row) {
|
||||
$total += $row['N'] * 4;
|
||||
$status = $row['importStatus'];
|
||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE) {
|
||||
$done += $row['N'];
|
||||
}
|
||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE) {
|
||||
$done += $row['N'];
|
||||
}
|
||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS) {
|
||||
$done += $row['N'];
|
||||
}
|
||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_HERALD) {
|
||||
$done += $row['N'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($total) {
|
||||
$percentage = 100 * ($done / $total);
|
||||
} else {
|
||||
$percentage = 0;
|
||||
}
|
||||
|
||||
$percentage = sprintf('%.1f%%', $percentage);
|
||||
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('time-green')
|
||||
->setTarget(pht('Importing'))
|
||||
->setNote(
|
||||
pht('%s Complete', $percentage)));
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Fully Imported')));
|
||||
}
|
||||
|
||||
if (idx($messages, PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE)) {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('up')
|
||||
->setTarget(pht('Prioritized'))
|
||||
->setNote(pht('This repository will be updated soon.')));
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user