mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
4310c4ed53
Summary: Ref T1460. This just barely works, but throwing it up in case any of it sounds mechanically crazy before we build integrations/UI/etc. Specifically, these are the behaviors: - You can mark your own draft comments as "done" before you submit them. The intent is to let reviewers mark their stuff advisory/minor/not-important before they submit it, to hint to authors that they don't expect the feedback to necessarily be addressed (maybe it's a joke, maybe it's just discussion, maybe it's "consider.."). - You can mark others' published comments as "done" if you're the revision/commit author. The intent is to keep this lightweight by not requiring an audit trail of who marked what done when. If anyone could mark anything done, we'd have to have some way to show who marked stuff. - When you mark stuff done (or unmark it), it goes into a "draft" state, where you see the change but others don't see it yet. The intent is twofold: - Be consistent with how inlines work. - Allow us to publish a "epriestley updated this revision + epriestley marked 15 inlines as done" story later if we want. This seems more useful than publishing 15 "epriestley marked one thing as done" stories. - The actual bit where done-ness publishes isn't implemented. - UI is bare bones. - No integration with the rest of the UI yet. Test Plan: Clicked some checkboxes. Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: paulshen, chasemp, epriestley Maniphest Tasks: T1460 Differential Revision: https://secure.phabricator.com/D12033
141 lines
3.8 KiB
PHP
141 lines
3.8 KiB
PHP
<?php
|
|
|
|
final class DiffusionDiffController extends DiffusionController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
protected function shouldLoadDiffusionRequest() {
|
|
return false;
|
|
}
|
|
|
|
protected function processDiffusionRequest(AphrontRequest $request) {
|
|
$data = $request->getURIMap();
|
|
$data = $data + array(
|
|
'dblob' => $this->getRequest()->getStr('ref'),
|
|
);
|
|
try {
|
|
$drequest = DiffusionRequest::newFromAphrontRequestDictionary(
|
|
$data,
|
|
$request);
|
|
} catch (Exception $ex) {
|
|
return id(new Aphront404Response())
|
|
->setRequest($request);
|
|
}
|
|
$this->setDiffusionRequest($drequest);
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
$viewer = $this->getViewer();
|
|
|
|
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->updateSymbolicCommit($data['effectiveCommit']);
|
|
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
|
|
$diff = DifferentialDiff::newEphemeralFromRawChanges(
|
|
$raw_changes);
|
|
$changesets = $diff->getChangesets();
|
|
$changeset = reset($changesets);
|
|
|
|
if (!$changeset) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$parser = new DifferentialChangesetParser();
|
|
$parser->setUser($viewer);
|
|
$parser->setChangeset($changeset);
|
|
$parser->setRenderingReference($drequest->generateURI(
|
|
array(
|
|
'action' => 'rendering-ref',
|
|
)));
|
|
|
|
$parser->readParametersFromRequest($request);
|
|
|
|
$coverage = $drequest->loadCoverage();
|
|
if ($coverage) {
|
|
$parser->setCoverage($coverage);
|
|
}
|
|
|
|
$commit = $drequest->loadCommit();
|
|
|
|
$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->setCanMarkDone(
|
|
($commit->getAuthorPHID()) &&
|
|
($viewer->getPHID() == $commit->getAuthorPHID()));
|
|
|
|
$parser->setWhitespaceMode(
|
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
|
|
|
$inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
|
|
$viewer,
|
|
$commit->getPHID(),
|
|
$path_id);
|
|
|
|
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($viewer);
|
|
|
|
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);
|
|
|
|
$parser->setRange($range_s, $range_e);
|
|
$parser->setMask($mask);
|
|
|
|
return id(new PhabricatorChangesetResponse())
|
|
->setRenderedChangeset($parser->renderChangeset())
|
|
->setUndoTemplates($parser->getRenderer()->renderUndoTemplates());
|
|
}
|
|
}
|