diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 8dc9bc5a5d..b4a2233d2a 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -472,15 +472,16 @@ celerity_register_resource_map(array( ), 'javelin-behavior-differential-dropdown-menus' => array( - 'uri' => '/res/08e751ee/rsrc/js/application/differential/behavior-dropdown-menus.js', + 'uri' => '/res/c5abbb83/rsrc/js/application/differential/behavior-dropdown-menus.js', 'type' => 'js', 'requires' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', - 2 => 'javelin-stratcom', - 3 => 'phabricator-dropdown-menu', - 4 => 'phabricator-menu-item', + 2 => 'javelin-util', + 3 => 'javelin-stratcom', + 4 => 'phabricator-dropdown-menu', + 5 => 'phabricator-menu-item', ), 'disk' => '/rsrc/js/application/differential/behavior-dropdown-menus.js', ), @@ -1418,7 +1419,7 @@ celerity_register_resource_map(array( ), 'phabricator-menu-item' => array( - 'uri' => '/res/8a9be282/rsrc/js/application/core/DropdownMenuItem.js', + 'uri' => '/res/cfd0a620/rsrc/js/application/core/DropdownMenuItem.js', 'type' => 'js', 'requires' => array( diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index 6fb4f33d24..bf64868591 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -1,7 +1,7 @@ buildSymbolIndexes($target, $visible_changesets); + $arc_project = $target->loadArcanistProject(); + + if ($arc_project) { + $symbol_indexes = $this->buildSymbolIndexes( + $target, + $arc_project, + $visible_changesets); + $repository = $arc_project->loadRepository(); + } else { + $symbol_indexes = array(); + $repository = null; + } $revision_detail->setActions($actions); $revision_detail->setUser($user); @@ -205,8 +216,12 @@ class DifferentialRevisionViewController extends DifferentialController { $changeset_view->setEditable(!$viewer_is_anonymous); $changeset_view->setStandaloneViews(true); $changeset_view->setRevision($revision); + $changeset_view->setDiff($target); $changeset_view->setRenderingReferences($rendering_references); $changeset_view->setWhitespace($whitespace); + if ($repository) { + $changeset_view->setRepository($repository, $target); + } $changeset_view->setSymbolIndexes($symbol_indexes); $diff_history = new DifferentialRevisionUpdateHistoryView(); @@ -597,21 +612,18 @@ class DifferentialRevisionViewController extends DifferentialController { private function buildSymbolIndexes( DifferentialDiff $target, + PhabricatorRepositoryArcanistProject $arc_project, array $visible_changesets) { $engine = PhabricatorSyntaxHighlighter::newEngine(); - $symbol_indexes = array(); - $arc_project = $target->loadArcanistProject(); - if (!$arc_project) { - return array(); - } - $langs = $arc_project->getSymbolIndexLanguages(); if (!$langs) { return array(); } + $symbol_indexes = array(); + $project_phids = array_merge( array($arc_project->getPHID()), nonempty($arc_project->getSymbolIndexProjects(), array())); diff --git a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php index 7498703ee2..3dd0c07f60 100644 --- a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php +++ b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php @@ -25,6 +25,8 @@ class DifferentialChangesetListView extends AphrontView { private $whitespace; private $standaloneViews; private $symbolIndexes = array(); + private $repository; + private $diff; public function setChangesets($changesets) { $this->changesets = $changesets; @@ -46,6 +48,16 @@ class DifferentialChangesetListView extends AphrontView { return $this; } + public function setRepository(PhabricatorRepository $repository) { + $this->repository = $repository; + return $this; + } + + public function setDiff(DifferentialDiff $diff) { + $this->diff = $diff; + return $this; + } + public function setRenderingReferences(array $references) { $this->references = $references; return $this; @@ -79,6 +91,7 @@ class DifferentialChangesetListView extends AphrontView { $output = array(); $mapping = array(); + $repository = $this->repository; foreach ($changesets as $key => $changeset) { $file = $changeset->getFilename(); $class = 'differential-changeset'; @@ -97,14 +110,21 @@ class DifferentialChangesetListView extends AphrontView { 'whitespace' => $this->whitespace, )); + $diffusion_uri = null; + if ($repository) { + $diffusion_uri = $repository->getDiffusionBrowseURIForPath( + $changeset->getAbsoluteRepositoryPath($this->diff, $repository)); + } + $detail_button = javelin_render_tag( 'a', array( 'class' => 'button small grey', 'meta' => array( - 'detailURI' => (string)$detail_uri, - 'leftURI' => (string)$detail_uri->alter('view', 'old'), - 'rightURI' => (string)$detail_uri->alter('view', 'new'), + 'detailURI' => (string)$detail_uri, + 'leftURI' => (string)$detail_uri->alter('view', 'old'), + 'rightURI' => (string)$detail_uri->alter('view', 'new'), + 'diffusionURI' => $diffusion_uri, ), 'href' => $detail_uri, 'target' => '_blank', diff --git a/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php b/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php index 2393e86fef..55e3afd636 100644 --- a/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php +++ b/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php @@ -1,7 +1,7 @@ getID(), $loadable_commits); $commits = mpull($commits, null, 'getCommitIdentifier'); - $commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere( - 'commitID in (%Ld)', - mpull($commits, 'getID')); - $commit_data = mpull($commit_data, null, 'getCommitID'); + if ($commits) { + $commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere( + 'commitID in (%Ld)', + mpull($commits, 'getID')); + $commit_data = mpull($commit_data, null, 'getCommitID'); + } else { + $commit_data = array(); + } } $path_normal = DiffusionPathIDQuery::normalizePath($path); diff --git a/src/applications/repository/storage/repository/PhabricatorRepository.php b/src/applications/repository/storage/repository/PhabricatorRepository.php index 1bcf27e3d2..adf2fb1ade 100644 --- a/src/applications/repository/storage/repository/PhabricatorRepository.php +++ b/src/applications/repository/storage/repository/PhabricatorRepository.php @@ -57,6 +57,22 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO { return $this; } + public function getDiffusionBrowseURIForPath($path) { + switch ($this->getVersionControlSystem()) { + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: + $branch = '/'.$this->getDetail('default-branch'); + break; + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: + $branch = null; + break; + default: + throw new Exception("Unknown VCS."); + } + + return '/diffusion/'.$this->getCallsign().'/browse'.$branch.$path; + } + public static function newPhutilURIFromGitURI($raw_uri) { // If there's no protocol (git implicit SSH) reformat the URI to be a // normal URI. These git URIs look like "user@domain.com:path" instead of diff --git a/webroot/rsrc/js/application/core/DropdownMenuItem.js b/webroot/rsrc/js/application/core/DropdownMenuItem.js index b15eb435d9..b3535aee30 100644 --- a/webroot/rsrc/js/application/core/DropdownMenuItem.js +++ b/webroot/rsrc/js/application/core/DropdownMenuItem.js @@ -17,12 +17,20 @@ JX.install('PhabricatorMenuItem', { _action : null, render : function() { - return JX.$N('a', { href : '#', meta : { item : this } }, this._name); + if (this.getDisabled()) { + return JX.$N('span', this._name); + } else { + return JX.$N('a', { href : '#', meta : { item : this } }, this._name); + } }, select : function() { this._action(); } + }, + + properties : { + disabled : false } }); diff --git a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js index 497b353713..f0e3b6f0c0 100644 --- a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js +++ b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js @@ -2,6 +2,7 @@ * @provides javelin-behavior-differential-dropdown-menus * @requires javelin-behavior * javelin-dom + * javelin-util * javelin-stratcom * phabricator-dropdown-menu * phabricator-menu-item @@ -9,40 +10,33 @@ JX.behavior('differential-dropdown-menus', function(config) { - function standalone(button) { - return function() { - window.open(JX.Stratcom.getData(button).detailURI); - } - } - - function left_file(button) { - return function() { - window.open(JX.Stratcom.getData(button).leftURI); - } - } - - function right_file(button) { - return function() { - window.open(JX.Stratcom.getData(button).rightURI); - } - } - var buttons = JX.DOM.scry(window.document, 'a', 'differential-view-options'); + for (var ii = 0; ii < buttons.length; ii++) { - var button = buttons[ii]; + var data = JX.Stratcom.getData(buttons[ii]); + + var diffusion_item = new JX.PhabricatorMenuItem( + 'Browse in Diffusion', + JX.bind(null, window.open, data.diffusionURI)) + + if (!data.diffusionURI) { + diffusion_item.setDisabled(true); + } + new JX.PhabricatorDropdownMenu(buttons[ii]) + .addItem(diffusion_item) .addItem( new JX.PhabricatorMenuItem( 'View Standalone', - standalone(button))) + JX.bind(null, window.open, data.detailURI))) .addItem( new JX.PhabricatorMenuItem( 'Show Raw File (Left)', - left_file(button))) + JX.bind(null, window.open, data.leftURI))) .addItem( new JX.PhabricatorMenuItem( 'Show Raw File (Right)', - right_file(button))); + JX.bind(null, window.open, data.rightURI))); } });