Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
3.4 kB · 119 lines
PHP
at commit dcd7a316
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120<?php
final class DiffusionDiffController extends DiffusionController {
public function shouldAllowPublic() { return true; }
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); }
$data = $this->callConduitWithDiffusionRequest( 'diffusion.diffquery', array( 'commit' => $drequest->getCommit(), 'path' => $drequest->getPath())); $drequest->setCommit($data['effectiveCommit']); $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']); $diff = DifferentialDiff::newFromRawChanges($raw_changes); $changesets = $diff->getChangesets(); $changeset = reset($changesets);
if (!$changeset) { return new Aphront404Response(); }
$parser = new DifferentialChangesetParser(); $parser->setUser($user); $parser->setChangeset($changeset); $parser->setRenderingReference($drequest->generateURI( array( 'action' => 'rendering-ref')));
$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); }}