2011-03-08 17:31:44 -08:00
|
|
|
<?php
|
|
|
|
|
2017-05-27 17:55:44 -07:00
|
|
|
final class DiffusionHistoryTableView extends DiffusionHistoryView {
|
2016-12-05 18:09:51 -08:00
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
public function render() {
|
2011-03-12 16:17:34 -08:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
2015-09-10 19:28:49 -07:00
|
|
|
$viewer = $this->getUser();
|
2015-09-29 07:09:12 -07:00
|
|
|
|
2017-05-27 17:55:44 -07:00
|
|
|
$buildables = $this->loadBuildables(
|
|
|
|
mpull($this->getHistory(), 'getCommit'));
|
2015-10-06 07:38:15 -07:00
|
|
|
$has_any_build = false;
|
|
|
|
|
2015-09-29 07:09:12 -07:00
|
|
|
$show_revisions = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorDifferentialApplication',
|
|
|
|
$viewer);
|
|
|
|
|
2015-09-10 19:28:49 -07:00
|
|
|
$handles = $viewer->loadHandles($this->getRequiredHandlePHIDs());
|
2011-04-02 16:39:23 -07:00
|
|
|
|
2012-03-23 17:11:15 -07:00
|
|
|
$graph = null;
|
2017-05-27 17:55:44 -07:00
|
|
|
if ($this->getParents()) {
|
|
|
|
$parents = $this->getParents();
|
2016-12-05 18:09:51 -08:00
|
|
|
|
|
|
|
// If we're filtering parents, remove relationships which point to
|
|
|
|
// commits that are not part of the visible graph. Otherwise, we get
|
|
|
|
// a big tree of nonsense when viewing release branches like "stable"
|
|
|
|
// versus "master".
|
2017-05-27 17:55:44 -07:00
|
|
|
if ($this->getFilterParents()) {
|
2016-12-05 18:09:51 -08:00
|
|
|
foreach ($parents as $key => $nodes) {
|
|
|
|
foreach ($nodes as $nkey => $node) {
|
|
|
|
if (empty($parents[$node])) {
|
|
|
|
unset($parents[$key][$nkey]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 17:20:29 -07:00
|
|
|
$graph = id(new PHUIDiffGraphView())
|
2017-05-27 17:55:44 -07:00
|
|
|
->setIsHead($this->getIsHead())
|
|
|
|
->setIsTail($this->getIsTail())
|
2016-12-05 18:09:51 -08:00
|
|
|
->renderGraph($parents);
|
2012-03-23 17:11:15 -07:00
|
|
|
}
|
|
|
|
|
2014-06-14 02:28:00 +10:00
|
|
|
$show_builds = PhabricatorApplication::isClassInstalledForViewer(
|
2014-07-23 10:03:09 +10:00
|
|
|
'PhabricatorHarbormasterApplication',
|
2014-06-14 02:28:00 +10:00
|
|
|
$this->getUser());
|
2014-06-24 03:08:47 +10:00
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$rows = array();
|
2012-03-23 17:11:15 -07:00
|
|
|
$ii = 0;
|
2017-05-27 17:55:44 -07:00
|
|
|
foreach ($this->getHistory() as $history) {
|
2011-03-12 22:51:40 -08:00
|
|
|
$epoch = $history->getEpoch();
|
|
|
|
|
|
|
|
if ($epoch) {
|
2016-03-18 08:59:21 -07:00
|
|
|
$committed = $viewer->formatShortDateTime($epoch);
|
2011-03-12 22:51:40 -08:00
|
|
|
} else {
|
2015-10-06 07:38:15 -07:00
|
|
|
$committed = null;
|
2011-03-12 22:51:40 -08:00
|
|
|
}
|
|
|
|
|
2011-04-02 16:39:23 -07:00
|
|
|
$data = $history->getCommitData();
|
2012-05-23 08:34:36 -07:00
|
|
|
$author_phid = $committer = $committer_phid = null;
|
2011-04-02 16:39:23 -07:00
|
|
|
if ($data) {
|
|
|
|
$author_phid = $data->getCommitDetail('authorPHID');
|
2012-05-23 08:34:36 -07:00
|
|
|
$committer_phid = $data->getCommitDetail('committerPHID');
|
|
|
|
$committer = $data->getCommitDetail('committer');
|
2011-04-02 16:39:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($author_phid && isset($handles[$author_phid])) {
|
|
|
|
$author = $handles[$author_phid]->renderLink();
|
|
|
|
} else {
|
2012-08-08 18:26:23 -07:00
|
|
|
$author = self::renderName($history->getAuthorName());
|
2011-04-02 16:39:23 -07:00
|
|
|
}
|
|
|
|
|
2012-06-07 12:26:19 -07:00
|
|
|
$different_committer = false;
|
|
|
|
if ($committer_phid) {
|
|
|
|
$different_committer = ($committer_phid != $author_phid);
|
|
|
|
} else if ($committer != '') {
|
|
|
|
$different_committer = ($committer != $history->getAuthorName());
|
|
|
|
}
|
|
|
|
if ($different_committer) {
|
2012-05-23 08:34:36 -07:00
|
|
|
if ($committer_phid && isset($handles[$committer_phid])) {
|
|
|
|
$committer = $handles[$committer_phid]->renderLink();
|
|
|
|
} else {
|
2012-08-08 18:26:23 -07:00
|
|
|
$committer = self::renderName($committer);
|
2012-05-23 08:34:36 -07:00
|
|
|
}
|
2013-02-13 14:50:15 -08:00
|
|
|
$author = hsprintf('%s/%s', $author, $committer);
|
2012-05-23 08:34:36 -07:00
|
|
|
}
|
|
|
|
|
2013-10-30 13:15:14 -07:00
|
|
|
// We can show details once the message and change have been imported.
|
|
|
|
$partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE |
|
|
|
|
PhabricatorRepositoryCommit::IMPORTED_CHANGE;
|
|
|
|
|
2012-05-09 17:28:57 -07:00
|
|
|
$commit = $history->getCommit();
|
2013-10-30 13:15:14 -07:00
|
|
|
if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
|
2014-05-12 19:57:12 -07:00
|
|
|
$summary = AphrontTableView::renderSingleDisplayLine(
|
|
|
|
$history->getSummary());
|
2012-05-09 17:28:57 -07:00
|
|
|
} else {
|
2015-06-09 23:06:52 +10:00
|
|
|
$summary = phutil_tag('em', array(), pht("Importing\xE2\x80\xA6"));
|
2012-05-09 17:28:57 -07:00
|
|
|
}
|
|
|
|
|
2014-06-14 02:28:00 +10:00
|
|
|
$build = null;
|
|
|
|
if ($show_builds) {
|
2015-10-06 07:38:15 -07:00
|
|
|
$buildable = idx($buildables, $commit->getPHID());
|
2014-06-14 02:28:00 +10:00
|
|
|
if ($buildable !== null) {
|
2015-10-06 07:38:15 -07:00
|
|
|
$build = $this->renderBuildable($buildable);
|
2014-06-14 02:28:00 +10:00
|
|
|
$has_any_build = true;
|
|
|
|
}
|
|
|
|
}
|
2014-06-24 03:08:47 +10:00
|
|
|
|
2015-09-10 19:28:49 -07:00
|
|
|
$browse = $this->linkBrowse(
|
|
|
|
$history->getPath(),
|
|
|
|
array(
|
|
|
|
'commit' => $history->getCommitIdentifier(),
|
|
|
|
'branch' => $drequest->getBranch(),
|
|
|
|
'type' => $history->getFileType(),
|
|
|
|
));
|
|
|
|
|
2017-01-19 10:39:05 -08:00
|
|
|
$status = $commit->getAuditStatus();
|
|
|
|
$icon = PhabricatorAuditCommitStatusConstants::getStatusIcon($status);
|
|
|
|
$color = PhabricatorAuditCommitStatusConstants::getStatusColor($status);
|
|
|
|
$name = PhabricatorAuditCommitStatusConstants::getStatusName($status);
|
|
|
|
|
|
|
|
$audit_view = id(new PHUIIconView())
|
|
|
|
->setIcon($icon, $color)
|
|
|
|
->addSigil('has-tooltip')
|
|
|
|
->setMetadata(
|
|
|
|
array(
|
|
|
|
'tip' => $name,
|
|
|
|
));
|
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$rows[] = array(
|
2012-03-23 17:11:15 -07:00
|
|
|
$graph ? $graph[$ii++] : null,
|
2015-09-10 19:28:49 -07:00
|
|
|
$browse,
|
2011-03-12 16:17:34 -08:00
|
|
|
self::linkCommit(
|
|
|
|
$drequest->getRepository(),
|
|
|
|
$history->getCommitIdentifier()),
|
2014-06-14 02:28:00 +10:00
|
|
|
$build,
|
2017-01-19 10:39:05 -08:00
|
|
|
$audit_view,
|
2012-06-22 16:52:08 -07:00
|
|
|
($commit ?
|
2017-05-27 17:55:44 -07:00
|
|
|
self::linkRevision(idx($this->getRevisions(), $commit->getPHID())) :
|
2012-06-22 16:52:08 -07:00
|
|
|
null),
|
2014-05-12 19:57:12 -07:00
|
|
|
$author,
|
|
|
|
$summary,
|
2015-10-06 07:38:15 -07:00
|
|
|
$committed,
|
2011-03-08 17:31:44 -08:00
|
|
|
);
|
|
|
|
}
|
2014-06-24 03:08:47 +10:00
|
|
|
|
2011-03-08 17:31:44 -08:00
|
|
|
$view = new AphrontTableView($rows);
|
|
|
|
$view->setHeaders(
|
|
|
|
array(
|
2015-09-10 19:28:49 -07:00
|
|
|
null,
|
|
|
|
null,
|
2013-05-11 08:23:19 -07:00
|
|
|
pht('Commit'),
|
2015-09-10 19:28:49 -07:00
|
|
|
null,
|
2015-10-06 07:38:15 -07:00
|
|
|
null,
|
2017-01-19 10:39:05 -08:00
|
|
|
null,
|
|
|
|
pht('Author'),
|
2013-05-11 08:23:19 -07:00
|
|
|
pht('Details'),
|
2015-10-06 07:38:15 -07:00
|
|
|
pht('Committed'),
|
2011-03-12 16:17:34 -08:00
|
|
|
));
|
|
|
|
$view->setColumnClasses(
|
|
|
|
array(
|
2012-03-23 17:11:15 -07:00
|
|
|
'threads',
|
2015-09-10 19:28:49 -07:00
|
|
|
'nudgeright',
|
2015-10-06 07:38:15 -07:00
|
|
|
'',
|
2014-06-14 02:28:00 +10:00
|
|
|
'icon',
|
2017-01-19 10:39:05 -08:00
|
|
|
'icon',
|
2015-10-06 07:38:15 -07:00
|
|
|
'',
|
2011-03-12 16:17:34 -08:00
|
|
|
'',
|
2014-05-12 19:57:12 -07:00
|
|
|
'wide',
|
2016-03-18 08:59:21 -07:00
|
|
|
'right',
|
2011-03-08 17:31:44 -08:00
|
|
|
));
|
2012-03-23 17:11:15 -07:00
|
|
|
$view->setColumnVisibility(
|
|
|
|
array(
|
|
|
|
$graph ? true : false,
|
2015-09-29 07:09:12 -07:00
|
|
|
true,
|
|
|
|
true,
|
2015-10-06 07:38:15 -07:00
|
|
|
$has_any_build,
|
2017-01-19 10:39:05 -08:00
|
|
|
true,
|
2015-09-29 07:09:12 -07:00
|
|
|
$show_revisions,
|
2012-03-23 17:11:15 -07:00
|
|
|
));
|
2014-05-12 19:57:12 -07:00
|
|
|
$view->setDeviceVisibility(
|
|
|
|
array(
|
|
|
|
$graph ? true : false,
|
|
|
|
true,
|
|
|
|
true,
|
2014-06-14 02:28:00 +10:00
|
|
|
true,
|
2015-09-10 19:28:49 -07:00
|
|
|
true,
|
2017-01-19 10:39:05 -08:00
|
|
|
true,
|
2014-05-12 19:57:12 -07:00
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
));
|
2011-03-08 17:31:44 -08:00
|
|
|
return $view->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|