2011-03-08 17:31:44 -08:00
|
|
|
<?php
|
|
|
|
|
|
2011-03-12 16:17:34 -08:00
|
|
|
final class DiffusionHistoryTableView extends DiffusionView {
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
private $history;
|
2012-06-22 16:52:08 -07:00
|
|
|
private $revisions = array();
|
2011-04-02 16:39:23 -07:00
|
|
|
private $handles = array();
|
2012-03-23 17:11:15 -07:00
|
|
|
private $isHead;
|
2016-01-08 11:41:49 -08:00
|
|
|
private $isTail;
|
2012-03-23 17:11:15 -07:00
|
|
|
private $parents;
|
2016-12-05 18:09:51 -08:00
|
|
|
private $filterParents;
|
2011-03-08 17:31:44 -08:00
|
|
|
|
|
|
|
|
public function setHistory(array $history) {
|
2012-04-03 16:22:31 -07:00
|
|
|
assert_instances_of($history, 'DiffusionPathChange');
|
2011-03-08 17:31:44 -08:00
|
|
|
$this->history = $history;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-22 16:52:08 -07:00
|
|
|
public function loadRevisions() {
|
|
|
|
|
$commit_phids = array();
|
|
|
|
|
foreach ($this->history as $item) {
|
|
|
|
|
if ($item->getCommit()) {
|
|
|
|
|
$commit_phids[] = $item->getCommit()->getPHID();
|
|
|
|
|
}
|
|
|
|
|
}
|
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
2013-10-26 19:59:57 -07:00
|
|
|
|
|
|
|
|
// TODO: Get rid of this.
|
2012-06-22 16:52:08 -07:00
|
|
|
$this->revisions = id(new DifferentialRevision())
|
|
|
|
|
->loadIDsByCommitPHIDs($commit_phids);
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-02 16:39:23 -07:00
|
|
|
public function setHandles(array $handles) {
|
2012-04-03 16:22:31 -07:00
|
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
2011-04-02 16:39:23 -07:00
|
|
|
$this->handles = $handles;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-10 19:28:49 -07:00
|
|
|
private function getRequiredHandlePHIDs() {
|
2012-03-23 15:32:26 -07:00
|
|
|
$phids = array();
|
|
|
|
|
foreach ($this->history as $item) {
|
|
|
|
|
$data = $item->getCommitData();
|
|
|
|
|
if ($data) {
|
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
|
}
|
2012-05-23 08:34:36 -07:00
|
|
|
if ($data->getCommitDetail('committerPHID')) {
|
|
|
|
|
$phids[$data->getCommitDetail('committerPHID')] = true;
|
|
|
|
|
}
|
2012-03-23 15:32:26 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return array_keys($phids);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-23 17:11:15 -07:00
|
|
|
public function setParents(array $parents) {
|
|
|
|
|
$this->parents = $parents;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setIsHead($is_head) {
|
|
|
|
|
$this->isHead = $is_head;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-08 11:41:49 -08:00
|
|
|
public function setIsTail($is_tail) {
|
|
|
|
|
$this->isTail = $is_tail;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-05 18:09:51 -08:00
|
|
|
public function setFilterParents($filter_parents) {
|
|
|
|
|
$this->filterParents = $filter_parents;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFilterParents() {
|
|
|
|
|
return $this->filterParents;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2015-10-06 07:38:15 -07:00
|
|
|
$buildables = $this->loadBuildables(mpull($this->history, 'getCommit'));
|
|
|
|
|
$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;
|
|
|
|
|
if ($this->parents) {
|
2016-12-05 18:09:51 -08:00
|
|
|
$parents = $this->parents;
|
|
|
|
|
|
|
|
|
|
// 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".
|
|
|
|
|
if ($this->filterParents) {
|
|
|
|
|
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())
|
|
|
|
|
->setIsHead($this->isHead)
|
|
|
|
|
->setIsTail($this->isTail)
|
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;
|
2011-03-08 17:31:44 -08:00
|
|
|
foreach ($this->history 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 ?
|
|
|
|
|
self::linkRevision(idx($this->revisions, $commit->getPHID())) :
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|