diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -868,8 +868,11 @@ ->setHighlightingDisabled($this->highlightingDisabled) ->setDepthOnlyLines($this->getDepthOnlyLines()); + $engine_blocks = $this->newDocumentEngineBlocks(); + $has_document_engine = ($engine_blocks !== null); + $shield = null; - if ($this->isTopLevel && !$this->comments) { + if ($this->isTopLevel && !$this->comments && !$has_document_engine) { if ($this->isGenerated()) { $shield = $renderer->renderShield( pht( @@ -1024,7 +1027,6 @@ ->setOldComments($old_comments) ->setNewComments($new_comments); - $engine_blocks = $this->newDocumentEngineChangesetView(); if ($engine_blocks !== null) { $reference = $this->getRenderingReference(); $parts = explode('/', $reference); @@ -1041,6 +1043,8 @@ $vs = $id; } + $renderer->setDocumentEngineBlocks($engine_blocks); + return $renderer->renderDocumentEngineBlocks( $engine_blocks, (string)$id, @@ -1653,7 +1657,7 @@ return $prefix.$line; } - private function newDocumentEngineChangesetView() { + private function newDocumentEngineBlocks() { $changeset = $this->changeset; $viewer = $this->getViewer(); @@ -1724,7 +1728,7 @@ } if ($document_engine) { - return $document_engine->newDiffView( + return $document_engine->newEngineBlocks( $old_ref, $new_ref); } diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php --- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php @@ -270,11 +270,20 @@ } } - if ($this->getHighlightingDisabled()) { - $messages[] = pht( - 'This file is larger than %s, so syntax highlighting is '. - 'disabled by default.', - phutil_format_bytes(DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT)); + $blocks = $this->getDocumentEngineBlocks(); + if ($blocks) { + foreach ($blocks->getMessages() as $message) { + $messages[] = $message; + } + } else { + if ($this->getHighlightingDisabled()) { + $byte_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT; + $byte_limit = phutil_format_bytes($byte_limit); + $messages[] = pht( + 'This file is larger than %s, so syntax highlighting is '. + 'disabled by default.', + $byte_limit); + } } return $this->formatHeaderMessages($messages); diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php --- a/src/applications/differential/render/DifferentialChangesetRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetRenderer.php @@ -35,6 +35,7 @@ private $highlightingDisabled; private $scopeEngine = false; private $depthOnlyLines; + private $documentEngineBlocks; private $oldFile = false; private $newFile = false; @@ -239,6 +240,16 @@ return $this->oldChangesetID; } + public function setDocumentEngineBlocks( + PhabricatorDocumentEngineBlocks $blocks) { + $this->documentEngineBlocks = $blocks; + return $this; + } + + public function getDocumentEngineBlocks() { + return $this->documentEngineBlocks; + } + public function setNewComments(array $new_comments) { foreach ($new_comments as $line_number => $comments) { assert_instances_of($comments, 'PhabricatorInlineCommentInterface'); @@ -355,6 +366,16 @@ $notice = null; if ($this->getIsTopLevel()) { $force = (!$content && !$props); + + // If we have DocumentEngine messages about the blocks, assume they + // explain why there's no content. + $blocks = $this->getDocumentEngineBlocks(); + if ($blocks) { + if ($blocks->getMessages()) { + $force = false; + } + } + $notice = $this->renderChangeTypeHeader($force); } diff --git a/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php b/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php --- a/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php +++ b/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php @@ -4,6 +4,16 @@ extends Phobject { private $lists = array(); + private $messages = array(); + + public function addMessage($message) { + $this->messages[] = $message; + return $this; + } + + public function getMessages() { + return $this->messages; + } public function addBlockList(PhabricatorDocumentRef $ref, array $blocks) { assert_instances_of($blocks, 'PhabricatorDocumentEngineBlock'); @@ -20,6 +30,10 @@ $rows = array(); $lists = $this->lists; + if (count($lists) != 2) { + return array(); + } + $specs = array(); foreach ($this->lists as $list) { $specs[] = $this->newDiffSpec($list['blocks']); diff --git a/src/applications/files/document/PhabricatorDocumentEngine.php b/src/applications/files/document/PhabricatorDocumentEngine.php --- a/src/applications/files/document/PhabricatorDocumentEngine.php +++ b/src/applications/files/document/PhabricatorDocumentEngine.php @@ -37,7 +37,7 @@ return false; } - public function newDiffView( + public function newEngineBlocks( PhabricatorDocumentRef $uref, PhabricatorDocumentRef $vref) { throw new PhutilMethodNotImplementedException(); diff --git a/src/applications/files/document/PhabricatorImageDocumentEngine.php b/src/applications/files/document/PhabricatorImageDocumentEngine.php --- a/src/applications/files/document/PhabricatorImageDocumentEngine.php +++ b/src/applications/files/document/PhabricatorImageDocumentEngine.php @@ -27,7 +27,7 @@ return ($uref->getFile() && $vref->getFile()); } - public function newDiffView( + public function newEngineBlocks( PhabricatorDocumentRef $uref, PhabricatorDocumentRef $vref) { diff --git a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php --- a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php +++ b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php @@ -41,16 +41,23 @@ return true; } - public function newDiffView( + public function newEngineBlocks( PhabricatorDocumentRef $uref, PhabricatorDocumentRef $vref) { - $u_blocks = $this->newDiffBlocks($uref); - $v_blocks = $this->newDiffBlocks($vref); + $blocks = new PhabricatorDocumentEngineBlocks(); - return id(new PhabricatorDocumentEngineBlocks()) - ->addBlockList($uref, $u_blocks) - ->addBlockList($vref, $v_blocks); + try { + $u_blocks = $this->newDiffBlocks($uref); + $v_blocks = $this->newDiffBlocks($vref); + + $blocks->addBlockList($uref, $u_blocks); + $blocks->addBlockList($vref, $v_blocks); + } catch (Exception $ex) { + $blocks->addMessage($ex->getMessage()); + } + + return $blocks; } private function newDiffBlocks(PhabricatorDocumentRef $ref) {