Add an "importing" state to repositories and clean up the UI
Summary:
Fixes T3217. Ref T776. Ref T1493. Broadly, this introduces a mechanism which works like this:
- When a repository is created, we set an "importing" flag.
- After discovery completes, we check if a repository has no importing commits. Basically, this is the first time we catch up to HEAD.
- If we're caught up, clear the "importing" flag.
This flag lets us fix some issues:
- T3217. Currently, when you import a new repository and users have rules like "Email me on every commit ever" or "trigger an audit on every commit", we take a bunch of publish actions. Instead, implicitly disable publishing during import.
- An imported but un-pulled repository currently has an incomprehensible error on `/diffusion/X/`. Fix that.
- Show more cues in the UI about importing.
- Made some exceptions more specific.
Test Plan:
This is the new screen for a completely new repo, replacing a giant exception:
{F75443}
- Created a repository, saw it "importing".
- Pulled and discovered it.
- Processed its commits.
- Ran discovery again, saw import flag clear.
- Also this repository was empty, which hit some of the other code.
This is the new "parsed empty repository" UI, which isn't good, but is less broken:
{F75446}
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, hach-que
Maniphest Tasks: T3607, T1493, T776, T3217
Differential Revision: https://secure.phabricator.com/D7429
This commit is contained in:
@@ -7,7 +7,8 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$drequest = $this->diffusionRequest;
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$content = array();
|
||||
|
||||
@@ -15,106 +16,108 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
$content[] = $crumbs;
|
||||
|
||||
$content[] = $this->buildPropertiesTable($drequest->getRepository());
|
||||
|
||||
$history_results = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.historyquery',
|
||||
array(
|
||||
'commit' => $drequest->getCommit(),
|
||||
'path' => $drequest->getPath(),
|
||||
'offset' => 0,
|
||||
'limit' => 15));
|
||||
$history = DiffusionPathChange::newFromConduit(
|
||||
$history_results['pathChanges']);
|
||||
|
||||
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
||||
$this->callConduitWithDiffusionRequest(
|
||||
'diffusion.browsequery',
|
||||
array(
|
||||
'path' => $drequest->getPath(),
|
||||
'commit' => $drequest->getCommit(),
|
||||
)));
|
||||
$browse_paths = $browse_results->getPaths();
|
||||
|
||||
$phids = array();
|
||||
foreach ($history as $item) {
|
||||
$data = $item->getCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[$data->getCommitDetail('authorPHID')] = true;
|
||||
}
|
||||
if ($data->getCommitDetail('committerPHID')) {
|
||||
$phids[$data->getCommitDetail('committerPHID')] = true;
|
||||
|
||||
try {
|
||||
$history_results = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.historyquery',
|
||||
array(
|
||||
'commit' => $drequest->getCommit(),
|
||||
'path' => $drequest->getPath(),
|
||||
'offset' => 0,
|
||||
'limit' => 15));
|
||||
$history = DiffusionPathChange::newFromConduit(
|
||||
$history_results['pathChanges']);
|
||||
|
||||
foreach ($history as $item) {
|
||||
$data = $item->getCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[$data->getCommitDetail('authorPHID')] = true;
|
||||
}
|
||||
if ($data->getCommitDetail('committerPHID')) {
|
||||
$phids[$data->getCommitDetail('committerPHID')] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$history_results = null;
|
||||
$history = null;
|
||||
$history_exception = $ex;
|
||||
}
|
||||
|
||||
foreach ($browse_paths as $item) {
|
||||
$data = $item->getLastCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[$data->getCommitDetail('authorPHID')] = true;
|
||||
}
|
||||
if ($data->getCommitDetail('committerPHID')) {
|
||||
$phids[$data->getCommitDetail('committerPHID')] = true;
|
||||
try {
|
||||
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
||||
$this->callConduitWithDiffusionRequest(
|
||||
'diffusion.browsequery',
|
||||
array(
|
||||
'path' => $drequest->getPath(),
|
||||
'commit' => $drequest->getCommit(),
|
||||
)));
|
||||
$browse_paths = $browse_results->getPaths();
|
||||
|
||||
foreach ($browse_paths as $item) {
|
||||
$data = $item->getLastCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[$data->getCommitDetail('authorPHID')] = true;
|
||||
}
|
||||
if ($data->getCommitDetail('committerPHID')) {
|
||||
$phids[$data->getCommitDetail('committerPHID')] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$browse_results = null;
|
||||
$browse_paths = null;
|
||||
$browse_exception = $ex;
|
||||
}
|
||||
|
||||
$phids = array_keys($phids);
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$readme = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.readmequery',
|
||||
array(
|
||||
'paths' => $browse_results->getPathDicts()
|
||||
if ($browse_results) {
|
||||
$readme = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.readmequery',
|
||||
array(
|
||||
'paths' => $browse_results->getPathDicts()
|
||||
));
|
||||
} else {
|
||||
$readme = null;
|
||||
}
|
||||
|
||||
$history_table = new DiffusionHistoryTableView();
|
||||
$history_table->setUser($this->getRequest()->getUser());
|
||||
$history_table->setDiffusionRequest($drequest);
|
||||
$history_table->setHandles($handles);
|
||||
$history_table->setHistory($history);
|
||||
$history_table->loadRevisions();
|
||||
$history_table->setParents($history_results['parents']);
|
||||
$history_table->setIsHead(true);
|
||||
$content[] = $this->buildHistoryTable(
|
||||
$history_results,
|
||||
$history,
|
||||
$history_exception,
|
||||
$handles);
|
||||
|
||||
$callsign = $drequest->getRepository()->getCallsign();
|
||||
$all = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'history',
|
||||
)),
|
||||
),
|
||||
pht('View Full Commit History'));
|
||||
$content[] = $this->buildBrowseTable(
|
||||
$browse_results,
|
||||
$browse_paths,
|
||||
$browse_exception,
|
||||
$handles);
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader(pht("Recent Commits · %s", $all));
|
||||
$panel->appendChild($history_table);
|
||||
$panel->setNoBackground();
|
||||
try {
|
||||
$content[] = $this->buildTagListTable($drequest);
|
||||
} catch (Exception $ex) {
|
||||
if (!$repository->isImporting()) {
|
||||
$content[] = $this->renderStatusMessage(
|
||||
pht('Unable to Load Tags'),
|
||||
$ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$content[] = $panel;
|
||||
|
||||
|
||||
$browse_table = new DiffusionBrowseTableView();
|
||||
$browse_table->setDiffusionRequest($drequest);
|
||||
$browse_table->setHandles($handles);
|
||||
$browse_table->setPaths($browse_paths);
|
||||
$browse_table->setUser($this->getRequest()->getUser());
|
||||
|
||||
$browse_panel = new AphrontPanelView();
|
||||
$browse_panel->setHeader(phutil_tag(
|
||||
'a',
|
||||
array('href' => $drequest->generateURI(array('action' => 'browse'))),
|
||||
pht('Browse Repository')));
|
||||
$browse_panel->appendChild($browse_table);
|
||||
$browse_panel->setNoBackground();
|
||||
|
||||
$content[] = $browse_panel;
|
||||
|
||||
$content[] = $this->buildTagListTable($drequest);
|
||||
|
||||
$content[] = $this->buildBranchListTable($drequest);
|
||||
try {
|
||||
$content[] = $this->buildBranchListTable($drequest);
|
||||
} catch (Exception $ex) {
|
||||
if (!$repository->isImporting()) {
|
||||
$content[] = $this->renderStatusMessage(
|
||||
pht('Unable to Load Branches'),
|
||||
$ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($readme) {
|
||||
$box = new PHUIBoxView();
|
||||
@@ -145,6 +148,15 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
->setUser($user)
|
||||
->setPolicyObject($repository);
|
||||
|
||||
if (!$repository->isTracked()) {
|
||||
$header->setStatus('policy-noone', '', pht('Inactive'));
|
||||
} else if ($repository->isImporting()) {
|
||||
$header->setStatus('time', 'red', pht('Importing...'));
|
||||
} else {
|
||||
$header->setStatus('oh-ok', '', pht('Active'));
|
||||
}
|
||||
|
||||
|
||||
$actions = $this->buildActionList($repository);
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
@@ -333,4 +345,109 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildHistoryTable(
|
||||
$history_results,
|
||||
$history,
|
||||
$history_exception,
|
||||
array $handles) {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
if ($history_exception) {
|
||||
if ($repository->isImporting()) {
|
||||
return $this->renderStatusMessage(
|
||||
pht('Still Importing...'),
|
||||
pht(
|
||||
'This repository is still importing. History is not yet '.
|
||||
'available.'));
|
||||
} else {
|
||||
return $this->renderStatusMessage(
|
||||
pht('Unable to Retrieve History'),
|
||||
$history_exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$history_table = id(new DiffusionHistoryTableView())
|
||||
->setUser($viewer)
|
||||
->setDiffusionRequest($drequest)
|
||||
->setHandles($handles)
|
||||
->setHistory($history);
|
||||
|
||||
// TODO: Super sketchy.
|
||||
$history_table->loadRevisions();
|
||||
|
||||
if ($history_results) {
|
||||
$history_table->setParents($history_results['parents']);
|
||||
}
|
||||
|
||||
$history_table->setIsHead(true);
|
||||
|
||||
$callsign = $drequest->getRepository()->getCallsign();
|
||||
$all = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'history',
|
||||
)),
|
||||
),
|
||||
pht('View Full Commit History'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader(pht("Recent Commits · %s", $all));
|
||||
$panel->appendChild($history_table);
|
||||
$panel->setNoBackground();
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
private function buildBrowseTable(
|
||||
$browse_results,
|
||||
$browse_paths,
|
||||
$browse_exception,
|
||||
array $handles) {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
if ($browse_exception) {
|
||||
if ($repository->isImporting()) {
|
||||
// The history table renders a useful message.
|
||||
return null;
|
||||
} else {
|
||||
return $this->renderStatusMessage(
|
||||
pht('Unable to Retrieve Paths'),
|
||||
$browse_exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$browse_table = id(new DiffusionBrowseTableView())
|
||||
->setUser($viewer)
|
||||
->setDiffusionRequest($drequest)
|
||||
->setHandles($handles);
|
||||
if ($browse_paths) {
|
||||
$browse_table->setPaths($browse_paths);
|
||||
} else {
|
||||
$browse_table->setPaths(array());
|
||||
}
|
||||
|
||||
$browse_uri = $drequest->generateURI(array('action' => 'browse'));
|
||||
|
||||
$browse_panel = new AphrontPanelView();
|
||||
$browse_panel->setHeader(
|
||||
phutil_tag(
|
||||
'a',
|
||||
array('href' => $browse_uri),
|
||||
pht('Browse Repository')));
|
||||
$browse_panel->appendChild($browse_table);
|
||||
$browse_panel->setNoBackground();
|
||||
|
||||
return $browse_panel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user