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;
|
|
|
|
}
|
|
|
|
|
2011-03-14 06:03:30 +01:00
|
|
|
public function processRequest() {
|
|
|
|
$drequest = $this->diffusionRequest;
|
2013-09-23 21:54:12 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
2011-03-14 06:03:30 +01:00
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
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(),
|
|
|
|
));
|
2013-05-14 22:53:32 +02:00
|
|
|
$drequest->setCommit($data['effectiveCommit']);
|
|
|
|
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
|
|
|
|
$diff = DifferentialDiff::newFromRawChanges($raw_changes);
|
|
|
|
$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();
|
|
|
|
$callsign = $repository->getCallsign();
|
2014-05-13 22:52:48 +02:00
|
|
|
$commit = $drequest->getSymbolicCommit();
|
2012-05-01 21:09:50 +02:00
|
|
|
$changesets = array(
|
|
|
|
0 => $changeset,
|
|
|
|
);
|
2012-05-02 22:13:03 +02:00
|
|
|
|
2011-03-31 02:36:16 +02:00
|
|
|
$changeset_view = new DifferentialChangesetListView();
|
2013-10-01 02:49:15 +02:00
|
|
|
$changeset_view->setTitle(pht('Change'));
|
2012-05-01 21:09:50 +02:00
|
|
|
$changeset_view->setChangesets($changesets);
|
|
|
|
$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(
|
2013-05-14 22:53:32 +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);
|
|
|
|
|
2013-09-23 21:54:12 +02:00
|
|
|
$changeset_view->setRenderURI('/diffusion/'.$callsign.'/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);
|
2012-01-16 20:08:54 +01:00
|
|
|
$changeset_view->setUser($this->getRequest()->getUser());
|
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');
|
2012-12-13 19:46:41 +01:00
|
|
|
$content[] = $changeset_view->render();
|
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',
|
|
|
|
));
|
2013-09-23 21:54:12 +02:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$links = $this->renderPathLinks($drequest, $mode = 'browse');
|
2013-09-23 21:54:12 +02:00
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader($links)
|
|
|
|
->setUser($viewer)
|
|
|
|
->setPolicyObject($drequest->getRepository());
|
|
|
|
$actions = $this->buildActionView($drequest);
|
2013-10-11 16:53:56 +02:00
|
|
|
$properties = $this->buildPropertyView($drequest, $actions);
|
2011-03-14 06:03:30 +01:00
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
2013-10-11 16:53:56 +02:00
|
|
|
->addPropertyList($properties);
|
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
|
|
|
return $this->buildApplicationPage(
|
2013-09-23 21:54:12 +02:00
|
|
|
array(
|
|
|
|
$crumbs,
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box,
|
2013-09-23 21:54:12 +02:00
|
|
|
$content,
|
|
|
|
),
|
2011-03-14 06:03:30 +01:00
|
|
|
array(
|
2013-05-11 17:23:19 +02:00
|
|
|
'title' => pht('Change'),
|
2011-03-14 06:03:30 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-09-23 21:54:12 +02:00
|
|
|
private function buildActionView(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$history_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
|
|
|
));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('View History'))
|
|
|
|
->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',
|
|
|
|
));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Browse Content'))
|
|
|
|
->setHref($browse_uri)
|
2014-05-13 16:45:39 +02:00
|
|
|
->setIcon('fa-files-o'));
|
2013-09-23 21:54:12 +02:00
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
$callsign = $drequest->getRepository()->getCallsign();
|
|
|
|
|
|
|
|
$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
|
|
|
}
|