Page MenuHomePhabricator

D14964.diff
No OneTemporary

D14964.diff

diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php
--- a/src/applications/diffusion/controller/DiffusionBrowseController.php
+++ b/src/applications/diffusion/controller/DiffusionBrowseController.php
@@ -591,19 +591,27 @@
$data) {
$viewer = $this->getViewer();
+ $blame_timeout = 15;
+ $blame_failed = false;
- if ($needs_blame) {
- $blame = $this->loadBlame($path, $drequest->getCommit());
+ $file_corpus = $file_content->getCorpus();
+ $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
+ $blame_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
+ $can_highlight = (strlen($file_corpus) <= $highlight_limit);
+ $can_blame = (strlen($file_corpus) <= $blame_limit);
+
+ if ($needs_blame && $can_blame) {
+ $blame = $this->loadBlame($path, $drequest->getCommit(), $blame_timeout);
list($blame_list, $blame_commits) = $blame;
+ if ($blame_list === null) {
+ $blame_failed = true;
+ $blame_list = array();
+ }
} else {
$blame_list = array();
$blame_commits = array();
}
- $file_corpus = $file_content->getCorpus();
- $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
- $can_highlight = (strlen($file_corpus) <= $highlight_limit);
-
if (!$show_color) {
$corpus = $this->renderPlaintextCorpus(
$file_corpus,
@@ -697,16 +705,32 @@
->appendChild($corpus)
->setCollapsed(true);
+ $messages = array();
+
if (!$can_highlight) {
- $message = pht(
+ $messages[] = pht(
'This file is larger than %s, so syntax highlighting is disabled '.
'by default.',
phutil_format_bytes($highlight_limit));
+ }
+
+ if ($show_blame && !$can_blame) {
+ $messages[] = pht(
+ 'This file is larger than %s, so blame is disabled.',
+ phutil_format_bytes($blame_limit));
+ }
+
+ if ($blame_failed) {
+ $messages[] = pht(
+ 'Failed to load blame information for this file in %s second(s).',
+ new PhutilNumber($blame_timeout));
+ }
+ if ($messages) {
$corpus->setInfoView(
id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
- ->setErrors(array($message)));
+ ->setErrors($messages));
}
return $corpus;
@@ -1709,15 +1733,16 @@
return $view;
}
- private function loadBlame($path, $commit) {
+ private function loadBlame($path, $commit, $timeout) {
$blame = $this->callConduitWithDiffusionRequest(
'diffusion.blame',
array(
'commit' => $commit,
'paths' => array($path),
+ 'timeout' => $timeout,
));
- $identifiers = idx($blame, $path, array());
+ $identifiers = idx($blame, $path, null);
if ($identifiers) {
$viewer = $this->getViewer();

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 4, 6:36 PM (2 w, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711407
Default Alt Text
D14964.diff (2 KB)

Event Timeline