3 final class DiffusionDiffController
extends DiffusionController
{
5 public function shouldAllowPublic() {
9 protected function getDiffusionBlobFromRequest(AphrontRequest
$request) {
10 return $request->getStr('ref');
13 public function handleRequest(AphrontRequest
$request) {
14 $response = $this->loadDiffusionContext();
19 $viewer = $this->getViewer();
20 $drequest = $this->getDiffusionRequest();
22 if (!$request->isAjax()) {
24 // This request came out of the dropdown menu, either "View Standalone"
25 // or "View Raw File".
27 $view = $request->getStr('view');
29 $uri = $drequest->generateURI(
37 $uri = $drequest->generateURI(
43 return id(new AphrontRedirectResponse())->setURI($uri);
46 $data = $this->callConduitWithDiffusionRequest(
47 'diffusion.diffquery',
49 'commit' => $drequest->getCommit(),
50 'path' => $drequest->getPath(),
52 $drequest->updateSymbolicCommit($data['effectiveCommit']);
53 $raw_changes = ArcanistDiffChange
::newFromConduit($data['changes']);
54 $diff = DifferentialDiff
::newEphemeralFromRawChanges(
56 $changesets = $diff->getChangesets();
57 $changeset = reset($changesets);
60 return new Aphront404Response();
63 $commit = $drequest->loadCommit();
65 $viewstate_engine = id(new PhabricatorChangesetViewStateEngine())
67 ->setObjectPHID($commit->getPHID())
68 ->setChangeset($changeset);
70 $viewstate = $viewstate_engine->newViewStateFromRequest($request);
72 if ($viewstate->getDiscardResponse()) {
73 return new AphrontAjaxResponse();
76 $parser = id(new DifferentialChangesetParser())
78 ->setChangeset($changeset)
79 ->setViewState($viewstate);
81 $parser->setRenderingReference($drequest->generateURI(
83 'action' => 'rendering-ref',
86 $coverage = $drequest->loadCoverage();
88 $parser->setCoverage($coverage);
91 $pquery = new DiffusionPathIDQuery(array($changeset->getFilename()));
92 $ids = $pquery->loadPathIDs();
93 $path_id = $ids[$changeset->getFilename()];
95 $parser->setLeftSideCommentMapping($path_id, false);
96 $parser->setRightSideCommentMapping($path_id, true);
97 $parser->setCanMarkDone(
98 ($commit->getAuthorPHID()) &&
99 ($viewer->getPHID() == $commit->getAuthorPHID()));
100 $parser->setObjectOwnerPHID($commit->getAuthorPHID());
102 $inlines = id(new DiffusionDiffInlineCommentQuery())
104 ->withCommitPHIDs(array($commit->getPHID()))
105 ->withPathIDs(array($path_id))
106 ->withPublishedComments(true)
107 ->withPublishableComments(true)
109 $inlines = mpull($inlines, 'newInlineCommentObject');
112 foreach ($inlines as $inline) {
113 $parser->parseInlineComment($inline);
116 $phids = mpull($inlines, 'getAuthorPHID');
117 $handles = $this->loadViewerHandles($phids);
118 $parser->setHandles($handles);
121 $engine = new PhabricatorMarkupEngine();
122 $engine->setViewer($viewer);
124 foreach ($inlines as $inline) {
127 PhabricatorInlineComment
::MARKUP_FIELD_BODY
);
132 $parser->setMarkupEngine($engine);
134 $spec = $request->getStr('range');
135 list($range_s, $range_e, $mask) =
136 DifferentialChangesetParser
::parseRangeSpecification($spec);
138 $parser->setRange($range_s, $range_e);
139 $parser->setMask($mask);
141 return $parser->newChangesetResponse();