2011-03-13 01:17:34 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionRepositoryController extends DiffusionController {
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$drequest = $this->diffusionRequest;
|
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs();
|
|
|
|
$content[] = $crumbs;
|
|
|
|
|
2012-03-08 21:46:19 +01:00
|
|
|
$content[] = $this->buildPropertiesTable($drequest->getRepository());
|
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$history_results = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.historyquery',
|
|
|
|
array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'offset' => 0,
|
|
|
|
'limit' => 15));
|
|
|
|
$history = DiffusionPathChange::newFromConduit(
|
|
|
|
$history_results['pathChanges']);
|
2011-04-03 01:39:23 +02:00
|
|
|
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.browsequery',
|
|
|
|
array(
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
)));
|
|
|
|
$browse_paths = $browse_results->getPaths();
|
2011-04-03 01:39:23 +02:00
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
foreach ($history as $item) {
|
|
|
|
$data = $item->getCommitData();
|
|
|
|
if ($data) {
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
}
|
2012-05-23 17:34:36 +02:00
|
|
|
if ($data->getCommitDetail('committerPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('committerPHID')] = true;
|
|
|
|
}
|
2011-04-03 01:39:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
foreach ($browse_paths as $item) {
|
2011-04-03 01:39:23 +02:00
|
|
|
$data = $item->getLastCommitData();
|
|
|
|
if ($data) {
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
}
|
2012-05-23 17:34:36 +02:00
|
|
|
if ($data->getCommitDetail('committerPHID')) {
|
|
|
|
$phids[$data->getCommitDetail('committerPHID')] = true;
|
|
|
|
}
|
2011-04-03 01:39:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$phids = array_keys($phids);
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-04-03 01:39:23 +02:00
|
|
|
|
2013-05-21 22:47:06 +02:00
|
|
|
$readme = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.readmequery',
|
|
|
|
array(
|
|
|
|
'paths' => $browse_results->getPathDicts()
|
|
|
|
));
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_table = new DiffusionHistoryTableView();
|
2012-12-21 00:04:20 +01:00
|
|
|
$history_table->setUser($this->getRequest()->getUser());
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_table->setDiffusionRequest($drequest);
|
2011-04-03 01:39:23 +02:00
|
|
|
$history_table->setHandles($handles);
|
2011-03-13 01:17:34 +01:00
|
|
|
$history_table->setHistory($history);
|
2012-06-23 01:52:08 +02:00
|
|
|
$history_table->loadRevisions();
|
2013-05-20 21:45:34 +02:00
|
|
|
$history_table->setParents($history_results['parents']);
|
2012-03-24 01:11:15 +01:00
|
|
|
$history_table->setIsHead(true);
|
2011-03-13 01:17:34 +01:00
|
|
|
|
2011-03-13 07:51:40 +01:00
|
|
|
$callsign = $drequest->getRepository()->getCallsign();
|
2013-01-18 03:57:09 +01:00
|
|
|
$all = phutil_tag(
|
2011-03-13 07:51:40 +01:00
|
|
|
'a',
|
|
|
|
array(
|
2012-12-04 03:23:33 +01:00
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
|
|
|
)),
|
2011-03-13 07:51:40 +01:00
|
|
|
),
|
2013-05-11 17:23:19 +02:00
|
|
|
pht('View Full Commit History'));
|
2011-03-13 07:51:40 +01:00
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
$panel = new AphrontPanelView();
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setHeader(pht("Recent Commits · %s", $all));
|
2011-03-13 01:17:34 +01:00
|
|
|
$panel->appendChild($history_table);
|
2013-01-15 01:40:04 +01:00
|
|
|
$panel->setNoBackground();
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
$content[] = $panel;
|
|
|
|
|
|
|
|
|
|
|
|
$browse_table = new DiffusionBrowseTableView();
|
|
|
|
$browse_table->setDiffusionRequest($drequest);
|
2011-04-03 01:39:23 +02:00
|
|
|
$browse_table->setHandles($handles);
|
Diffusion - move DiffusionBrowseQuery => Conduit
Summary: see title. Ref T2784.
Test Plan:
In diffusion, for each of SVN, Mercurial, and Git, I loaded up /diffusion/CALLSIGN/. I verified the README was displayed and things looked good. Next I clicked on "browse" on the top-most commit and verified things looked correct. Also clicked through to a file for a good measure and things looked good.
In owners, for each of SVN, Mercurial, and Git, I played around with the path typeahead / validator. It worked correctly!
Reviewers: epriestley
Reviewed By: epriestley
CC: chad, aran, Korvin
Maniphest Tasks: T2784
Differential Revision: https://secure.phabricator.com/D5883
2013-05-10 20:02:58 +02:00
|
|
|
$browse_table->setPaths($browse_paths);
|
2012-08-02 21:22:50 +02:00
|
|
|
$browse_table->setUser($this->getRequest()->getUser());
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
$browse_panel = new AphrontPanelView();
|
2013-02-21 21:58:40 +01:00
|
|
|
$browse_panel->setHeader(phutil_tag(
|
|
|
|
'a',
|
|
|
|
array('href' => $drequest->generateURI(array('action' => 'browse'))),
|
2013-05-11 17:23:19 +02:00
|
|
|
pht('Browse Repository')));
|
2011-03-13 01:17:34 +01:00
|
|
|
$browse_panel->appendChild($browse_table);
|
2013-01-15 01:40:04 +01:00
|
|
|
$browse_panel->setNoBackground();
|
2011-03-13 01:17:34 +01:00
|
|
|
|
|
|
|
$content[] = $browse_panel;
|
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
$content[] = $this->buildTagListTable($drequest);
|
|
|
|
|
2012-05-10 09:28:19 +02:00
|
|
|
$content[] = $this->buildBranchListTable($drequest);
|
2011-03-13 01:17:34 +01:00
|
|
|
|
2012-04-30 16:47:41 +02:00
|
|
|
if ($readme) {
|
2013-05-11 17:23:19 +02:00
|
|
|
$box = new PHUIBoxView();
|
|
|
|
$box->setShadow(true);
|
|
|
|
$box->appendChild($readme);
|
|
|
|
$box->addPadding(PHUI::PADDING_LARGE);
|
|
|
|
|
2012-04-30 16:47:41 +02:00
|
|
|
$panel = new AphrontPanelView();
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setHeader(pht('README'));
|
|
|
|
$panel->setNoBackground();
|
|
|
|
$panel->appendChild($box);
|
2012-04-30 16:47:41 +02:00
|
|
|
$content[] = $panel;
|
|
|
|
}
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
return $this->buildApplicationPage(
|
2011-03-13 01:17:34 +01:00
|
|
|
$content,
|
|
|
|
array(
|
2012-01-20 22:27:32 +01:00
|
|
|
'title' => $drequest->getRepository()->getName(),
|
2013-05-11 17:23:19 +02:00
|
|
|
'device' => true,
|
2011-03-13 01:17:34 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-03-08 21:46:19 +01:00
|
|
|
private function buildPropertiesTable(PhabricatorRepository $repository) {
|
2013-05-24 21:38:44 +02:00
|
|
|
$user = $this->getRequest()->getUser();
|
2012-03-08 21:46:19 +01:00
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-09-19 20:57:09 +02:00
|
|
|
->setHeader($repository->getName())
|
|
|
|
->setUser($user)
|
|
|
|
->setPolicyObject($repository);
|
|
|
|
|
|
|
|
$actions = $this->buildActionList($repository);
|
2013-05-24 19:48:10 +02:00
|
|
|
|
2013-05-24 21:38:44 +02:00
|
|
|
$view = id(new PhabricatorPropertyListView())
|
|
|
|
->setUser($user);
|
2013-05-24 19:48:10 +02:00
|
|
|
$view->addProperty(pht('Callsign'), $repository->getCallsign());
|
|
|
|
|
2012-03-08 21:46:19 +01:00
|
|
|
switch ($repository->getVersionControlSystem()) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
2013-05-24 19:48:10 +02:00
|
|
|
$view->addProperty(
|
|
|
|
pht('Clone URI'),
|
|
|
|
$repository->getPublicRemoteURI());
|
2012-03-08 21:46:19 +01:00
|
|
|
break;
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
2013-05-24 19:48:10 +02:00
|
|
|
$view->addProperty(
|
|
|
|
pht('Repository Root'),
|
|
|
|
$repository->getPublicRemoteURI());
|
2012-03-08 21:46:19 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-05-24 19:48:10 +02:00
|
|
|
$description = $repository->getDetail('description');
|
|
|
|
if (strlen($description)) {
|
2013-05-24 21:38:44 +02:00
|
|
|
$description = PhabricatorMarkupEngine::renderOneObject(
|
|
|
|
$repository,
|
|
|
|
'description',
|
|
|
|
$user);
|
2013-05-24 19:48:10 +02:00
|
|
|
$view->addTextContent($description);
|
2012-03-08 21:46:19 +01:00
|
|
|
}
|
|
|
|
|
2013-09-19 20:57:09 +02:00
|
|
|
return array($header, $actions, $view);
|
2012-03-08 21:46:19 +01:00
|
|
|
}
|
|
|
|
|
2012-05-10 09:28:19 +02:00
|
|
|
private function buildBranchListTable(DiffusionRequest $drequest) {
|
|
|
|
if ($drequest->getBranch() !== null) {
|
|
|
|
$limit = 15;
|
|
|
|
|
2013-05-01 23:56:36 +02:00
|
|
|
$branches = DiffusionBranchInformation::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.branchquery',
|
|
|
|
array(
|
|
|
|
'limit' => $limit
|
|
|
|
)));
|
2012-05-10 09:28:19 +02:00
|
|
|
if (!$branches) {
|
2013-05-01 23:56:36 +02:00
|
|
|
return null;
|
2012-05-10 09:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$more_branches = (count($branches) > $limit);
|
|
|
|
$branches = array_slice($branches, 0, $limit);
|
|
|
|
|
|
|
|
$commits = id(new PhabricatorAuditCommitQuery())
|
|
|
|
->withIdentifiers(
|
|
|
|
$drequest->getRepository()->getID(),
|
|
|
|
mpull($branches, 'getHeadCommitIdentifier'))
|
|
|
|
->needCommitData(true)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$table = new DiffusionBranchTableView();
|
|
|
|
$table->setDiffusionRequest($drequest);
|
|
|
|
$table->setBranches($branches);
|
|
|
|
$table->setCommits($commits);
|
|
|
|
$table->setUser($this->getRequest()->getUser());
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setHeader(pht('Branches'));
|
2013-01-15 01:40:04 +01:00
|
|
|
$panel->setNoBackground();
|
2012-05-10 09:28:19 +02:00
|
|
|
|
|
|
|
if ($more_branches) {
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setCaption(pht('Showing %d branches.', $limit));
|
2012-05-10 09:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$panel->addButton(
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2012-05-10 23:18:49 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
2012-05-10 09:28:19 +02:00
|
|
|
array(
|
2012-05-10 23:18:49 +02:00
|
|
|
'action' => 'branches',
|
|
|
|
)),
|
|
|
|
'class' => 'grey button',
|
|
|
|
),
|
2013-05-11 17:23:19 +02:00
|
|
|
pht("Show All Branches \xC2\xBB")));
|
2012-05-10 09:28:19 +02:00
|
|
|
|
|
|
|
$panel->appendChild($table);
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
private function buildTagListTable(DiffusionRequest $drequest) {
|
2012-05-10 09:28:19 +02:00
|
|
|
$tag_limit = 15;
|
2013-05-11 00:22:35 +02:00
|
|
|
$tags = array();
|
|
|
|
try {
|
|
|
|
$tags = DiffusionRepositoryTag::newFromConduit(
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.tagsquery',
|
2013-09-19 20:57:33 +02:00
|
|
|
array(
|
|
|
|
// On the home page, we want to find tags on any branch.
|
|
|
|
'commit' => null,
|
|
|
|
'limit' => $tag_limit + 1,
|
|
|
|
)));
|
2013-05-11 00:22:35 +02:00
|
|
|
} catch (ConduitException $e) {
|
|
|
|
if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') {
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
2012-04-18 17:02:08 +02:00
|
|
|
|
|
|
|
if (!$tags) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-19 18:39:19 +02:00
|
|
|
$more_tags = (count($tags) > $tag_limit);
|
|
|
|
$tags = array_slice($tags, 0, $tag_limit);
|
|
|
|
|
2012-04-18 17:02:08 +02:00
|
|
|
$commits = id(new PhabricatorAuditCommitQuery())
|
|
|
|
->withIdentifiers(
|
|
|
|
$drequest->getRepository()->getID(),
|
|
|
|
mpull($tags, 'getCommitIdentifier'))
|
|
|
|
->needCommitData(true)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$view = new DiffusionTagListView();
|
|
|
|
$view->setDiffusionRequest($drequest);
|
|
|
|
$view->setTags($tags);
|
|
|
|
$view->setUser($this->getRequest()->getUser());
|
|
|
|
$view->setCommits($commits);
|
|
|
|
|
|
|
|
$phids = $view->getRequiredHandlePHIDs();
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2012-04-18 17:02:08 +02:00
|
|
|
$view->setHandles($handles);
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setHeader(pht('Tags'));
|
2013-09-19 20:57:33 +02:00
|
|
|
$panel->setNoBackground(true);
|
2012-04-19 18:39:19 +02:00
|
|
|
|
|
|
|
if ($more_tags) {
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit));
|
2012-04-19 18:39:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$panel->addButton(
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2012-04-19 18:39:19 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'tags',
|
|
|
|
)),
|
|
|
|
'class' => 'grey button',
|
|
|
|
),
|
2013-05-11 17:23:19 +02:00
|
|
|
pht("Show All Tags \xC2\xBB")));
|
2012-04-18 17:02:08 +02:00
|
|
|
$panel->appendChild($view);
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:57:09 +02:00
|
|
|
private function buildActionList(PhabricatorRepository $repository) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view_uri = $this->getApplicationURI($repository->getCallsign().'/');
|
|
|
|
$edit_uri = $this->getApplicationURI($repository->getCallsign().'/edit/');
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setObject($repository)
|
|
|
|
->setObjectURI($view_uri);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Edit Repository'))
|
|
|
|
->setIcon('edit')
|
|
|
|
->setHref($edit_uri)
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
}
|