Summary: Ref T13552. This older view mostly duplicates other code and has only two callsites: - The "Commits" section of user profile pages. - The "Ambiguous Hash" page when you visit a commit hash page which is an ambiguous prefix of two or more commit hashes. Replace both with "DiffusionCommitGraphView". Test Plan: - Visited profile page, clicked "Commits". - Visited an ambiguous hash page (`rPbd3c23`). Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21412
146 lines
3.8 KiB
PHP
146 lines
3.8 KiB
PHP
<?php
|
|
|
|
final class DiffusionHistoryController extends DiffusionController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
require_celerity_resource('diffusion-css');
|
|
|
|
$viewer = $this->getViewer();
|
|
$drequest = $this->getDiffusionRequest();
|
|
$repository = $drequest->getRepository();
|
|
|
|
$pager = id(new PHUIPagerView())
|
|
->readFromRequest($request);
|
|
|
|
$params = array(
|
|
'commit' => $drequest->getCommit(),
|
|
'path' => $drequest->getPath(),
|
|
'offset' => $pager->getOffset(),
|
|
'limit' => $pager->getPageSize() + 1,
|
|
);
|
|
|
|
$history_results = $this->callConduitWithDiffusionRequest(
|
|
'diffusion.historyquery',
|
|
$params);
|
|
$history = DiffusionPathChange::newFromConduit(
|
|
$history_results['pathChanges']);
|
|
|
|
$history = $pager->sliceResults($history);
|
|
|
|
$identifiers = array();
|
|
foreach ($history as $item) {
|
|
$identifiers[] = $item->getCommitIdentifier();
|
|
}
|
|
|
|
if ($identifiers) {
|
|
$commits = id(new DiffusionCommitQuery())
|
|
->setViewer($viewer)
|
|
->withRepositoryPHIDs(array($repository->getPHID()))
|
|
->withIdentifiers($identifiers)
|
|
->needCommitData(true)
|
|
->needIdentities(true)
|
|
->execute();
|
|
} else {
|
|
$commits = array();
|
|
}
|
|
|
|
$history_list = id(new DiffusionCommitGraphView())
|
|
->setViewer($viewer)
|
|
->setDiffusionRequest($drequest)
|
|
->setHistory($history)
|
|
->setCommits($commits);
|
|
|
|
// NOTE: If we have a path (like "src/"), many nodes in the graph are
|
|
// likely to be missing (since the path wasn't touched by those commits).
|
|
|
|
// If we draw the graph, commits will often appear to be unrelated because
|
|
// intermediate nodes are omitted. Just drop the graph.
|
|
|
|
// The ideal behavior would be to load the entire graph and then connect
|
|
// ancestors appropriately, but this would currrently be prohibitively
|
|
// expensive in the general case.
|
|
|
|
$show_graph = !strlen($drequest->getPath());
|
|
if ($show_graph) {
|
|
$history_list
|
|
->setParents($history_results['parents'])
|
|
->setIsHead(!$pager->getOffset())
|
|
->setIsTail(!$pager->getHasMorePages());
|
|
}
|
|
|
|
$header = $this->buildHeader($drequest);
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
array(
|
|
'branch' => true,
|
|
'path' => true,
|
|
'view' => 'history',
|
|
));
|
|
$crumbs->setBorder(true);
|
|
|
|
$title = array(
|
|
pht('History'),
|
|
$repository->getDisplayName(),
|
|
);
|
|
|
|
$pager = id(new PHUIBoxView())
|
|
->addClass('mlb')
|
|
->appendChild($pager);
|
|
|
|
$tabs = $this->buildTabsView('history');
|
|
|
|
$view = id(new PHUITwoColumnView())
|
|
->setHeader($header)
|
|
->setTabs($tabs)
|
|
->setFooter(array(
|
|
$history_list,
|
|
$pager,
|
|
));
|
|
|
|
return $this->newPage()
|
|
->setTitle($title)
|
|
->setCrumbs($crumbs)
|
|
->appendChild($view)
|
|
->addClass('diffusion-history-view');
|
|
}
|
|
|
|
private function buildHeader(DiffusionRequest $drequest) {
|
|
$viewer = $this->getViewer();
|
|
$repository = $drequest->getRepository();
|
|
|
|
$no_path = !strlen($drequest->getPath());
|
|
if ($no_path) {
|
|
$header_text = pht('History');
|
|
} else {
|
|
$header_text = $this->renderPathLinks($drequest, $mode = 'history');
|
|
}
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setUser($viewer)
|
|
->setHeader($header_text)
|
|
->setHeaderIcon('fa-clock-o');
|
|
|
|
if (!$repository->isSVN()) {
|
|
$branch_tag = $this->renderBranchTag($drequest);
|
|
$header->addTag($branch_tag);
|
|
}
|
|
|
|
if ($drequest->getSymbolicCommit()) {
|
|
$symbolic_tag = $this->renderSymbolicCommit($drequest);
|
|
$header->addTag($symbolic_tag);
|
|
}
|
|
|
|
return $header;
|
|
|
|
}
|
|
|
|
}
|