2011-03-14 06:03:30 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionChangeController extends DiffusionController {
|
2011-03-14 06:03:30 +01:00
|
|
|
|
2013-09-23 21:54:12 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2011-03-14 06:03:30 +01:00
|
|
|
|
2013-05-14 22:53:32 +02:00
|
|
|
$data = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.diffquery',
|
|
|
|
array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
2013-09-23 21:54:12 +02:00
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
));
|
2014-05-13 22:53:06 +02:00
|
|
|
|
|
|
|
$drequest->updateSymbolicCommit($data['effectiveCommit']);
|
|
|
|
|
2013-05-14 22:53:32 +02:00
|
|
|
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
|
2014-12-19 23:54:15 +01:00
|
|
|
$diff = DifferentialDiff::newEphemeralFromRawChanges(
|
2014-11-19 21:16:07 +01:00
|
|
|
$raw_changes);
|
2013-05-14 22:53:32 +02:00
|
|
|
$changesets = $diff->getChangesets();
|
|
|
|
$changeset = reset($changesets);
|
2011-03-14 06:03:30 +01:00
|
|
|
|
2011-04-06 21:27:56 +02:00
|
|
|
if (!$changeset) {
|
|
|
|
// TODO: Refine this.
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2013-02-19 22:33:10 +01:00
|
|
|
|
2012-12-13 06:21:56 +01:00
|
|
|
$repository = $drequest->getRepository();
|
2012-05-01 21:09:50 +02:00
|
|
|
$changesets = array(
|
|
|
|
0 => $changeset,
|
|
|
|
);
|
2012-05-02 22:13:03 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$changeset_header = $this->buildChangesetHeader($drequest);
|
|
|
|
|
2011-03-31 02:36:16 +02:00
|
|
|
$changeset_view = new DifferentialChangesetListView();
|
2012-05-01 21:09:50 +02:00
|
|
|
$changeset_view->setChangesets($changesets);
|
2016-03-17 20:01:22 +01:00
|
|
|
$changeset_view->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
2012-05-01 21:09:50 +02:00
|
|
|
$changeset_view->setVisibleChangesets($changesets);
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-12 06:46:29 +02:00
|
|
|
$changeset_view->setRenderingReferences(
|
|
|
|
array(
|
2014-10-07 15:01:04 +02:00
|
|
|
0 => $drequest->generateURI(array('action' => 'rendering-ref')),
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-12 06:46:29 +02:00
|
|
|
));
|
2012-05-02 22:13:03 +02:00
|
|
|
|
|
|
|
$raw_params = array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'params' => array(
|
|
|
|
'view' => 'raw',
|
|
|
|
),
|
|
|
|
);
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2012-05-02 22:13:03 +02:00
|
|
|
$right_uri = $drequest->generateURI($raw_params);
|
2014-05-13 22:52:48 +02:00
|
|
|
$raw_params['params']['before'] = $drequest->getStableCommit();
|
2012-05-02 22:13:03 +02:00
|
|
|
$left_uri = $drequest->generateURI($raw_params);
|
|
|
|
$changeset_view->setRawFileURIs($left_uri, $right_uri);
|
|
|
|
|
2016-01-02 21:21:13 +01:00
|
|
|
$changeset_view->setRenderURI($repository->getPathURI('diff/'));
|
|
|
|
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-12 06:46:29 +02:00
|
|
|
$changeset_view->setWhitespace(
|
|
|
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
2015-01-09 22:29:08 +01:00
|
|
|
$changeset_view->setUser($viewer);
|
2016-03-17 20:01:22 +01:00
|
|
|
$changeset_view->setHeader($changeset_header);
|
2011-03-14 06:03:30 +01:00
|
|
|
|
2011-03-31 02:36:16 +02:00
|
|
|
// TODO: This is pretty awkward, unify the CSS between Diffusion and
|
|
|
|
// Differential better.
|
|
|
|
require_celerity_resource('differential-core-view-css');
|
2011-03-14 06:03:30 +01: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' => 'change',
|
|
|
|
));
|
2016-03-17 20:01:22 +01:00
|
|
|
$crumbs->setBorder(true);
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$links = $this->renderPathLinks($drequest, $mode = 'browse');
|
2016-03-17 20:01:22 +01:00
|
|
|
$header = $this->buildHeader($drequest, $links);
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$view = id(new PHUITwoColumnView())
|
2013-09-29 00:55:38 +02:00
|
|
|
->setHeader($header)
|
2016-03-17 20:01:22 +01:00
|
|
|
->setMainColumn(array(
|
|
|
|
))
|
|
|
|
->setFooter(array(
|
|
|
|
$changeset_view,
|
|
|
|
));
|
2013-09-29 00:55:38 +02:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(
|
|
|
|
array(
|
|
|
|
basename($drequest->getPath()),
|
|
|
|
$repository->getDisplayName(),
|
|
|
|
))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild(
|
|
|
|
array(
|
2016-03-17 20:01:22 +01:00
|
|
|
$view,
|
2016-01-05 17:13:05 +01:00
|
|
|
));
|
2011-03-14 06:03:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
private function buildHeader(
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
$links) {
|
|
|
|
$viewer = $this->getViewer();
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$tag = $this->renderCommitHashTag($drequest);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader($links)
|
|
|
|
->setUser($viewer)
|
|
|
|
->setPolicyObject($drequest->getRepository())
|
|
|
|
->addTag($tag);
|
|
|
|
|
|
|
|
return $header;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildChangesetHeader(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Changes'));
|
2013-09-23 21:54:12 +02:00
|
|
|
|
|
|
|
$history_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
|
|
|
));
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$header->addActionLink(
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('View History'))
|
2013-09-23 21:54:12 +02:00
|
|
|
->setHref($history_uri)
|
2014-05-13 16:45:39 +02:00
|
|
|
->setIcon('fa-clock-o'));
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$browse_uri = $drequest->generateURI(
|
2013-09-23 21:54:12 +02:00
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$header->addActionLink(
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('Browse Content'))
|
2013-09-23 21:54:12 +02:00
|
|
|
->setHref($browse_uri)
|
2014-05-13 16:45:39 +02:00
|
|
|
->setIcon('fa-files-o'));
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
return $header;
|
2013-09-23 21:54:12 +02:00
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
protected function buildPropertyView(
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2013-09-23 21:54:12 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions);
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2014-05-13 22:51:45 +02:00
|
|
|
$stable_commit = $drequest->getStableCommit();
|
2013-09-23 21:54:12 +02:00
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Commit'),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'commit',
|
|
|
|
'commit' => $stable_commit,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
$drequest->getRepository()->formatCommitName($stable_commit)));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2011-03-14 06:03:30 +01:00
|
|
|
}
|