mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
726a4912bd
Test Plan: /diffusion/ARC/lint/master/src/, clicked on count link. /diffusion/ARC/browse/master/src/difference/?lint=XHP9, clicked on file name. /diffusion/ARC/browse/master/src/difference/ArcanistDiffUtils.php?lint=, verified that all messages are displayed. /diffusion/ARC/browse/master/src/difference/ArcanistDiffUtils.php?lint=XHP9. /diffusion/ARC/browse/master/src/difference/ArcanistDiffUtils.php?lint=TXT3, verified that 0 messages are displayed. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3929
107 lines
2.9 KiB
PHP
107 lines
2.9 KiB
PHP
<?php
|
|
|
|
final class DiffusionDiffController extends DiffusionController {
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$data = $data + array(
|
|
'dblob' => $this->getRequest()->getStr('ref'),
|
|
);
|
|
$drequest = DiffusionRequest::newFromAphrontRequestDictionary(
|
|
$data,
|
|
$this->getRequest());
|
|
|
|
$this->diffusionRequest = $drequest;
|
|
}
|
|
|
|
public function processRequest() {
|
|
$drequest = $this->getDiffusionRequest();
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
if (!$request->isAjax()) {
|
|
|
|
// This request came out of the dropdown menu, either "View Standalone"
|
|
// or "View Raw File".
|
|
|
|
$view = $request->getStr('view');
|
|
if ($view == 'r') {
|
|
$uri = $drequest->generateURI(
|
|
array(
|
|
'action' => 'browse',
|
|
'params' => array(
|
|
'view' => 'raw',
|
|
),
|
|
));
|
|
} else {
|
|
$uri = $drequest->generateURI(
|
|
array(
|
|
'action' => 'change',
|
|
));
|
|
}
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($uri);
|
|
}
|
|
|
|
|
|
$diff_query = DiffusionDiffQuery::newFromDiffusionRequest($drequest);
|
|
$changeset = $diff_query->loadChangeset();
|
|
|
|
if (!$changeset) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
|
|
$parser = new DifferentialChangesetParser();
|
|
$parser->setUser($user);
|
|
$parser->setChangeset($changeset);
|
|
$parser->setRenderingReference($diff_query->getRenderingReference());
|
|
|
|
$pquery = new DiffusionPathIDQuery(array($changeset->getFilename()));
|
|
$ids = $pquery->loadPathIDs();
|
|
$path_id = $ids[$changeset->getFilename()];
|
|
|
|
$parser->setLeftSideCommentMapping($path_id, false);
|
|
$parser->setRightSideCommentMapping($path_id, true);
|
|
|
|
$parser->setWhitespaceMode(
|
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
|
|
|
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
|
'commitPHID = %s AND pathID = %d AND
|
|
(authorPHID = %s OR auditCommentID IS NOT NULL)',
|
|
$drequest->loadCommit()->getPHID(),
|
|
$path_id,
|
|
$user->getPHID());
|
|
|
|
if ($inlines) {
|
|
foreach ($inlines as $inline) {
|
|
$parser->parseInlineComment($inline);
|
|
}
|
|
|
|
$phids = mpull($inlines, 'getAuthorPHID');
|
|
$handles = $this->loadViewerHandles($phids);
|
|
$parser->setHandles($handles);
|
|
}
|
|
|
|
$engine = new PhabricatorMarkupEngine();
|
|
$engine->setViewer($user);
|
|
|
|
foreach ($inlines as $inline) {
|
|
$engine->addObject(
|
|
$inline,
|
|
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
|
|
}
|
|
|
|
$engine->process();
|
|
|
|
$parser->setMarkupEngine($engine);
|
|
|
|
$spec = $request->getStr('range');
|
|
list($range_s, $range_e, $mask) =
|
|
DifferentialChangesetParser::parseRangeSpecification($spec);
|
|
$output = $parser->render($range_s, $range_e, $mask);
|
|
|
|
return id(new PhabricatorChangesetResponse())
|
|
->setRenderedChangeset($output);
|
|
}
|
|
}
|