diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2486,7 +2486,6 @@ 'PhabricatorDifferentialRevisionTestDataGenerator' => 'applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php', 'PhabricatorDiffusionApplication' => 'applications/diffusion/application/PhabricatorDiffusionApplication.php', 'PhabricatorDiffusionBlameSetting' => 'applications/settings/setting/PhabricatorDiffusionBlameSetting.php', - 'PhabricatorDiffusionColorSetting' => 'applications/settings/setting/PhabricatorDiffusionColorSetting.php', 'PhabricatorDiffusionConfigOptions' => 'applications/diffusion/config/PhabricatorDiffusionConfigOptions.php', 'PhabricatorDisabledUserController' => 'applications/auth/controller/PhabricatorDisabledUserController.php', 'PhabricatorDisplayPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php', @@ -7406,7 +7405,6 @@ 'PhabricatorDifferentialRevisionTestDataGenerator' => 'PhabricatorTestDataGenerator', 'PhabricatorDiffusionApplication' => 'PhabricatorApplication', 'PhabricatorDiffusionBlameSetting' => 'PhabricatorInternalSetting', - 'PhabricatorDiffusionColorSetting' => 'PhabricatorInternalSetting', 'PhabricatorDiffusionConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorDisabledUserController' => 'PhabricatorAuthController', 'PhabricatorDisplayPreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 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 @@ -106,16 +106,11 @@ $path = $drequest->getPath(); $blame_key = PhabricatorDiffusionBlameSetting::SETTINGKEY; - $color_key = PhabricatorDiffusionColorSetting::SETTINGKEY; $show_blame = $request->getBool( 'blame', $viewer->getUserSetting($blame_key)); - $show_color = $request->getBool( - 'color', - $viewer->getUserSetting($color_key)); - $view = $request->getStr('view'); if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) { $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer); @@ -128,22 +123,18 @@ $xactions = array(); $xactions[] = $preferences->newTransaction($blame_key, $show_blame); - $xactions[] = $preferences->newTransaction($color_key, $show_color); $editor->applyTransactions($preferences, $xactions); $uri = $request->getRequestURI() - ->alter('blame', null) - ->alter('color', null); + ->alter('blame', null); return id(new AphrontRedirectResponse())->setURI($uri); } - // We need the blame information if blame is on and we're building plain - // text, or blame is on and this is an Ajax request. If blame is on and - // this is a colorized request, we don't show blame at first (we ajax it - // in afterward) so we don't need to query for it. - $needs_blame = ($show_blame && !$show_color) || - ($show_blame && $request->isAjax()); + // We need the blame information if blame is on and this is an Ajax request. + // If blame is on and this is a colorized request, we don't show blame at + // first (we ajax it in afterward) so we don't need to query for it. + $needs_blame = ($show_blame && $request->isAjax()); $params = array( 'commit' => $drequest->getCommit(), @@ -196,10 +187,10 @@ $data = $file->loadFileData(); - $ref = $this->getGitLFSRef($repository, $data); - if ($ref) { + $lfs_ref = $this->getGitLFSRef($repository, $data); + if ($lfs_ref) { if ($view == 'git-lfs') { - $file = $this->loadGitLFSFile($ref); + $file = $this->loadGitLFSFile($lfs_ref); // Rename the file locally so we generate a better vanity URI for // it. In storage, it just has a name like "lfs-13f9a94c0923...", @@ -211,7 +202,7 @@ return $file->getRedirectResponse(); } else { - $corpus = $this->buildGitLFSCorpus($ref); + $corpus = $this->buildGitLFSCorpus($lfs_ref); } } else if (ArcanistDiffUtils::isHeuristicBinaryFile($data)) { $file_uri = $file->getBestURI(); @@ -228,7 +219,6 @@ // Build the content of the file. $corpus = $this->buildCorpus( $show_blame, - $show_color, $data, $needs_blame, $drequest, @@ -248,8 +238,7 @@ $curtain = $this->enrichCurtain( $view, $drequest, - $show_blame, - $show_color); + $show_blame); $properties = $this->buildPropertyView($drequest); $header = $this->buildHeaderView($drequest); @@ -647,7 +636,6 @@ private function buildCorpus( $show_blame, - $show_color, $file_corpus, $needs_blame, DiffusionRequest $drequest, @@ -675,91 +663,82 @@ $blame_commits = array(); } - if (!$show_color) { - $corpus = $this->renderPlaintextCorpus( - $file_corpus, - $blame_list, - $blame_commits, - $show_blame); + require_celerity_resource('syntax-highlighting-css'); + if ($can_highlight) { + $highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename( + $path, + $file_corpus); } else { - require_celerity_resource('syntax-highlighting-css'); - - if ($can_highlight) { - $highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename( - $path, - $file_corpus); - } else { - // Highlight as plain text to escape the content properly. - $highlighted = PhabricatorSyntaxHighlighter::highlightWithLanguage( - 'txt', - $file_corpus); - } + // Highlight as plain text to escape the content properly. + $highlighted = PhabricatorSyntaxHighlighter::highlightWithLanguage( + 'txt', + $file_corpus); + } - $lines = phutil_split_lines($highlighted); + $lines = phutil_split_lines($highlighted); - $rows = $this->buildDisplayRows( - $lines, - $blame_list, - $blame_commits, - $show_blame, - $show_color); - - $corpus_table = javelin_tag( - 'table', - array( - 'class' => 'diffusion-source remarkup-code PhabricatorMonospaced', - 'sigil' => 'phabricator-source', - ), - $rows); + $rows = $this->buildDisplayRows( + $lines, + $blame_list, + $blame_commits, + $show_blame); - if ($this->getRequest()->isAjax()) { - return $corpus_table; - } + $corpus_table = javelin_tag( + 'table', + array( + 'class' => 'diffusion-source remarkup-code PhabricatorMonospaced', + 'sigil' => 'phabricator-source', + ), + $rows); - $id = celerity_generate_unique_node_id(); + if ($this->getRequest()->isAjax()) { + return $corpus_table; + } - $repo = $drequest->getRepository(); - $symbol_repos = nonempty($repo->getSymbolSources(), array()); - $symbol_repos[] = $repo->getPHID(); + $id = celerity_generate_unique_node_id(); - $lang = last(explode('.', $drequest->getPath())); - $repo_languages = $repo->getSymbolLanguages(); - $repo_languages = nonempty($repo_languages, array()); - $repo_languages = array_fill_keys($repo_languages, true); + $repo = $drequest->getRepository(); + $symbol_repos = nonempty($repo->getSymbolSources(), array()); + $symbol_repos[] = $repo->getPHID(); - $needs_symbols = true; - if ($repo_languages && $symbol_repos) { - $have_symbols = id(new DiffusionSymbolQuery()) - ->existsSymbolsInRepository($repo->getPHID()); - if (!$have_symbols) { - $needs_symbols = false; - } - } + $lang = last(explode('.', $drequest->getPath())); + $repo_languages = $repo->getSymbolLanguages(); + $repo_languages = nonempty($repo_languages, array()); + $repo_languages = array_fill_keys($repo_languages, true); - if ($needs_symbols && $repo_languages) { - $needs_symbols = isset($repo_languages[$lang]); + $needs_symbols = true; + if ($repo_languages && $symbol_repos) { + $have_symbols = id(new DiffusionSymbolQuery()) + ->existsSymbolsInRepository($repo->getPHID()); + if (!$have_symbols) { + $needs_symbols = false; } + } - if ($needs_symbols) { - Javelin::initBehavior( - 'repository-crossreference', - array( - 'container' => $id, - 'lang' => $lang, - 'repositories' => $symbol_repos, - )); - } + if ($needs_symbols && $repo_languages) { + $needs_symbols = isset($repo_languages[$lang]); + } - $corpus = phutil_tag( - 'div', + if ($needs_symbols) { + Javelin::initBehavior( + 'repository-crossreference', array( - 'id' => $id, - ), - $corpus_table); - - Javelin::initBehavior('load-blame', array('id' => $id)); + 'container' => $id, + 'lang' => $lang, + 'repositories' => $symbol_repos, + )); } + $corpus = phutil_tag( + 'div', + array( + 'id' => $id, + ), + $corpus_table); + + Javelin::initBehavior('load-blame', array('id' => $id)); + + $edit = $this->renderEditButton(); $file = $this->renderFileButton(); $header = id(new PHUIHeaderView()) @@ -808,8 +787,7 @@ private function enrichCurtain( PHUICurtainView $curtain, DiffusionRequest $drequest, - $show_blame, - $show_color) { + $show_blame) { $viewer = $this->getViewer(); $base_uri = $this->getRequest()->getRequestURI(); @@ -842,24 +820,6 @@ ->setUser($viewer) ->setRenderAsForm($viewer->isLoggedIn())); - if ($show_color) { - $highlight_text = pht('Disable Highlighting'); - $highlight_icon = 'fa-star-o grey'; - $highlight_value = 0; - } else { - $highlight_text = pht('Enable Highlighting'); - $highlight_icon = 'fa-star'; - $highlight_value = 1; - } - - $curtain->addAction( - id(new PhabricatorActionView()) - ->setName($highlight_text) - ->setHref($base_uri->alter('color', $highlight_value)) - ->setIcon($highlight_icon) - ->setUser($viewer) - ->setRenderAsForm($viewer->isLoggedIn())); - $href = null; if ($this->getRequest()->getStr('lint') !== null) { $lint_text = pht('Hide %d Lint Message(s)', count($this->lintMessages)); @@ -1002,8 +962,7 @@ array $lines, array $blame_list, array $blame_commits, - $show_blame, - $show_color) { + $show_blame) { $request = $this->getRequest(); $viewer = $this->getViewer(); @@ -1891,79 +1850,6 @@ return $links; } - private function renderPlaintextCorpus( - $file_corpus, - array $blame_list, - array $blame_commits, - $show_blame) { - - $viewer = $this->getViewer(); - - if (!$show_blame) { - $corpus = $file_corpus; - } else { - $author_phids = array(); - foreach ($blame_commits as $commit) { - $author_phid = $commit->getAuthorPHID(); - if ($author_phid === null) { - continue; - } - $author_phids[$author_phid] = $author_phid; - } - - if ($author_phids) { - $handles = $viewer->loadHandles($author_phids); - } else { - $handles = array(); - } - - $authors = array(); - $names = array(); - foreach ($blame_commits as $identifier => $commit) { - $author = $commit->renderAuthorShortName($handles); - $name = $commit->getLocalName(); - - $authors[$identifier] = $author; - $names[$identifier] = $name; - } - - $lines = phutil_split_lines($file_corpus); - - $rows = array(); - foreach ($lines as $line_number => $line) { - $commit_name = null; - $author = null; - - if (isset($blame_list[$line_number])) { - $identifier = $blame_list[$line_number]; - - if (isset($names[$identifier])) { - $commit_name = $names[$identifier]; - } - - if (isset($authors[$identifier])) { - $author = $authors[$identifier]; - } - } - - $rows[] = sprintf( - '%-10s %-20s %s', - $commit_name, - $author, - $line); - } - $corpus = implode('', $rows); - } - - return phutil_tag( - 'textarea', - array( - 'style' => 'border: none; width: 100%; height: 80em; '. - 'font-family: monospace', - ), - $corpus); - } - private function getGitLFSRef(PhabricatorRepository $repository, $data) { if (!$repository->canUseGitLFS()) { return null; diff --git a/src/applications/settings/setting/PhabricatorDiffusionColorSetting.php b/src/applications/settings/setting/PhabricatorDiffusionColorSetting.php deleted file mode 100644 --- a/src/applications/settings/setting/PhabricatorDiffusionColorSetting.php +++ /dev/null @@ -1,16 +0,0 @@ -