2011-03-09 02:31:44 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionHistoryController extends DiffusionController {
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
|
|
|
}
|
2017-08-16 21:07:14 +02:00
|
|
|
require_celerity_resource('diffusion-css');
|
2016-01-05 17:13:05 +01:00
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2013-09-23 21:55:23 +02:00
|
|
|
$repository = $drequest->getRepository();
|
2011-04-01 03:46:53 +02:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
->readFromRequest($request);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$params = array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
2016-01-05 17:13:05 +01:00
|
|
|
'offset' => $pager->getOffset(),
|
|
|
|
'limit' => $pager->getPageSize() + 1,
|
2014-10-07 15:01:04 +02:00
|
|
|
);
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$history_results = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.historyquery',
|
|
|
|
$params);
|
|
|
|
$history = DiffusionPathChange::newFromConduit(
|
|
|
|
$history_results['pathChanges']);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$history = $pager->sliceResults($history);
|
|
|
|
|
2020-07-10 20:15:41 +02:00
|
|
|
$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())
|
2017-05-28 02:55:44 +02:00
|
|
|
->setViewer($viewer)
|
2015-09-11 04:28:49 +02:00
|
|
|
->setDiffusionRequest($drequest)
|
2020-07-10 20:15:41 +02:00
|
|
|
->setHistory($history)
|
|
|
|
->setCommits($commits);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2020-07-11 18:24:35 +02:00
|
|
|
// 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());
|
|
|
|
}
|
|
|
|
|
2017-02-17 11:10:15 +01:00
|
|
|
$header = $this->buildHeader($drequest);
|
2013-09-29 00:55:38 +02:00
|
|
|
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'history',
|
|
|
|
));
|
2016-03-17 20:01:22 +01:00
|
|
|
$crumbs->setBorder(true);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2017-05-28 02:55:44 +02:00
|
|
|
$title = array(
|
|
|
|
pht('History'),
|
|
|
|
$repository->getDisplayName(),
|
|
|
|
);
|
|
|
|
|
|
|
|
$pager = id(new PHUIBoxView())
|
|
|
|
->addClass('mlb')
|
|
|
|
->appendChild($pager);
|
|
|
|
|
2017-07-05 23:09:12 +02:00
|
|
|
$tabs = $this->buildTabsView('history');
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
->setHeader($header)
|
2017-07-05 23:09:12 +02:00
|
|
|
->setTabs($tabs)
|
2016-03-17 20:01:22 +01:00
|
|
|
->setFooter(array(
|
2017-05-28 02:55:44 +02:00
|
|
|
$history_list,
|
|
|
|
$pager,
|
2016-03-17 20:01:22 +01:00
|
|
|
));
|
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
return $this->newPage()
|
2017-05-28 02:55:44 +02:00
|
|
|
->setTitle($title)
|
2016-01-05 17:13:05 +01:00
|
|
|
->setCrumbs($crumbs)
|
2017-06-06 19:20:45 +02:00
|
|
|
->appendChild($view)
|
|
|
|
->addClass('diffusion-history-view');
|
2011-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
private function buildHeader(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getViewer();
|
2017-08-16 21:07:14 +02:00
|
|
|
$repository = $drequest->getRepository();
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2017-07-05 23:09:12 +02:00
|
|
|
$no_path = !strlen($drequest->getPath());
|
|
|
|
if ($no_path) {
|
|
|
|
$header_text = pht('History');
|
|
|
|
} else {
|
|
|
|
$header_text = $this->renderPathLinks($drequest, $mode = 'history');
|
|
|
|
}
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$header = id(new PHUIHeaderView())
|
2017-05-28 02:55:44 +02:00
|
|
|
->setUser($viewer)
|
2017-07-05 23:09:12 +02:00
|
|
|
->setHeader($header_text)
|
2017-06-18 09:53:43 +02:00
|
|
|
->setHeaderIcon('fa-clock-o');
|
|
|
|
|
2017-08-16 21:07:14 +02:00
|
|
|
if (!$repository->isSVN()) {
|
|
|
|
$branch_tag = $this->renderBranchTag($drequest);
|
|
|
|
$header->addTag($branch_tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($drequest->getSymbolicCommit()) {
|
|
|
|
$symbolic_tag = $this->renderSymbolicCommit($drequest);
|
|
|
|
$header->addTag($symbolic_tag);
|
|
|
|
}
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
return $header;
|
2017-05-28 02:55:44 +02:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
}
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
}
|