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 @@ -55,7 +55,6 @@ } private function browseSearch() { - $drequest = $this->getDiffusionRequest(); $header = $this->buildHeaderView($drequest); @@ -77,7 +76,8 @@ $view = id(new PHUITwoColumnView()) ->setHeader($header) - ->setFooter(array( + ->setFooter( + array( $search_form, $search_results, )); @@ -337,6 +337,7 @@ $empty_result = null; $browse_panel = null; + $branch_panel = null; if (!$results->isValidResults()) { $empty_result = new DiffusionEmptyResultView(); $empty_result->setDiffusionRequest($drequest); @@ -376,6 +377,12 @@ pht('Hide Search'), $search_form, '#'); + + $path = $drequest->getPath(); + $is_branch = (!strlen($path) && $repository->supportsBranchComparison()); + if ($is_branch) { + $branch_panel = $this->buildBranchTable(); + } } $open_revisions = $this->buildOpenRevisions(); @@ -394,15 +401,18 @@ $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) - ->setMainColumn(array( - $empty_result, - $browse_panel, - )) - ->setFooter(array( + ->setMainColumn( + array( + $branch_panel, + $empty_result, + $browse_panel, + )) + ->setFooter( + array( $open_revisions, $readme, $pager_box, - )); + )); if ($details) { $view->addPropertySection(pht('Details'), $details); @@ -1951,5 +1961,62 @@ return $file; } + private function buildBranchTable() { + $viewer = $this->getViewer(); + $drequest = $this->getDiffusionRequest(); + $repository = $drequest->getRepository(); + + $branch = $drequest->getBranch(); + $default_branch = $repository->getDefaultBranch(); + + if ($branch === $default_branch) { + return null; + } + + $pager = id(new PHUIPagerView()) + ->setPageSize(10); + + try { + $results = $this->callConduitWithDiffusionRequest( + 'diffusion.historyquery', + array( + 'commit' => $branch, + 'against' => $default_branch, + 'path' => $drequest->getPath(), + 'offset' => $pager->getOffset(), + 'limit' => $pager->getPageSize() + 1, + )); + } catch (Exception $ex) { + return null; + } + + $history = DiffusionPathChange::newFromConduit($results['pathChanges']); + $history = $pager->sliceResults($history); + + if (!$history) { + return null; + } + + $history_table = id(new DiffusionHistoryTableView()) + ->setViewer($viewer) + ->setDiffusionRequest($drequest) + ->setHistory($history); + + $history_table->loadRevisions(); + + $history_table + ->setParents($results['parents']) + ->setFilterParents(true) + ->setIsHead(true) + ->setIsTail(!$pager->getHasMorePages()); + + $header = id(new PHUIHeaderView()) + ->setHeader(pht('%s vs %s', $branch, $default_branch)); + + return id(new PHUIObjectBoxView()) + ->setHeader($header) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) + ->setTable($history_table); + } } diff --git a/src/applications/diffusion/controller/DiffusionCompareController.php b/src/applications/diffusion/controller/DiffusionCompareController.php --- a/src/applications/diffusion/controller/DiffusionCompareController.php +++ b/src/applications/diffusion/controller/DiffusionCompareController.php @@ -301,11 +301,11 @@ $history_table->loadRevisions(); - if ($history) { - $history_table->setParents($results['parents']); - $history_table->setIsHead(!$pager->getOffset()); - $history_table->setIsTail(!$pager->getHasMorePages()); - } + $history_table + ->setParents($results['parents']) + ->setFilterParents(true) + ->setIsHead(!$pager->getOffset()) + ->setIsTail(!$pager->getHasMorePages()); $header = id(new PHUIHeaderView()) ->setHeader(pht('Commits')); diff --git a/src/applications/diffusion/view/DiffusionHistoryTableView.php b/src/applications/diffusion/view/DiffusionHistoryTableView.php --- a/src/applications/diffusion/view/DiffusionHistoryTableView.php +++ b/src/applications/diffusion/view/DiffusionHistoryTableView.php @@ -8,6 +8,7 @@ private $isHead; private $isTail; private $parents; + private $filterParents; public function setHistory(array $history) { assert_instances_of($history, 'DiffusionPathChange'); @@ -66,6 +67,15 @@ return $this; } + public function setFilterParents($filter_parents) { + $this->filterParents = $filter_parents; + return $this; + } + + public function getFilterParents() { + return $this->filterParents; + } + public function render() { $drequest = $this->getDiffusionRequest(); @@ -82,10 +92,26 @@ $graph = null; if ($this->parents) { + $parents = $this->parents; + + // If we're filtering parents, remove relationships which point to + // commits that are not part of the visible graph. Otherwise, we get + // a big tree of nonsense when viewing release branches like "stable" + // versus "master". + if ($this->filterParents) { + foreach ($parents as $key => $nodes) { + foreach ($nodes as $nkey => $node) { + if (empty($parents[$node])) { + unset($parents[$key][$nkey]); + } + } + } + } + $graph = id(new PHUIDiffGraphView()) ->setIsHead($this->isHead) ->setIsTail($this->isTail) - ->renderGraph($this->parents); + ->renderGraph($parents); } $show_builds = PhabricatorApplication::isClassInstalledForViewer(