@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When viewing a branch, preview differences from master

Summary: Ref T929. When viewing a branch, show a few recent differences from the default branch (usually, "master").

Test Plan: {F2079220}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T929

Differential Revision: https://secure.phabricator.com/D16991

+107 -14
+75 -8
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 55 55 } 56 56 57 57 private function browseSearch() { 58 - 59 58 $drequest = $this->getDiffusionRequest(); 60 59 $header = $this->buildHeaderView($drequest); 61 60 ··· 77 76 78 77 $view = id(new PHUITwoColumnView()) 79 78 ->setHeader($header) 80 - ->setFooter(array( 79 + ->setFooter( 80 + array( 81 81 $search_form, 82 82 $search_results, 83 83 )); ··· 337 337 338 338 $empty_result = null; 339 339 $browse_panel = null; 340 + $branch_panel = null; 340 341 if (!$results->isValidResults()) { 341 342 $empty_result = new DiffusionEmptyResultView(); 342 343 $empty_result->setDiffusionRequest($drequest); ··· 376 377 pht('Hide Search'), 377 378 $search_form, 378 379 '#'); 380 + 381 + $path = $drequest->getPath(); 382 + $is_branch = (!strlen($path) && $repository->supportsBranchComparison()); 383 + if ($is_branch) { 384 + $branch_panel = $this->buildBranchTable(); 385 + } 379 386 } 380 387 381 388 $open_revisions = $this->buildOpenRevisions(); ··· 394 401 $view = id(new PHUITwoColumnView()) 395 402 ->setHeader($header) 396 403 ->setCurtain($curtain) 397 - ->setMainColumn(array( 398 - $empty_result, 399 - $browse_panel, 400 - )) 401 - ->setFooter(array( 404 + ->setMainColumn( 405 + array( 406 + $branch_panel, 407 + $empty_result, 408 + $browse_panel, 409 + )) 410 + ->setFooter( 411 + array( 402 412 $open_revisions, 403 413 $readme, 404 414 $pager_box, 405 - )); 415 + )); 406 416 407 417 if ($details) { 408 418 $view->addPropertySection(pht('Details'), $details); ··· 1951 1961 return $file; 1952 1962 } 1953 1963 1964 + private function buildBranchTable() { 1965 + $viewer = $this->getViewer(); 1966 + $drequest = $this->getDiffusionRequest(); 1967 + $repository = $drequest->getRepository(); 1968 + 1969 + $branch = $drequest->getBranch(); 1970 + $default_branch = $repository->getDefaultBranch(); 1971 + 1972 + if ($branch === $default_branch) { 1973 + return null; 1974 + } 1975 + 1976 + $pager = id(new PHUIPagerView()) 1977 + ->setPageSize(10); 1978 + 1979 + try { 1980 + $results = $this->callConduitWithDiffusionRequest( 1981 + 'diffusion.historyquery', 1982 + array( 1983 + 'commit' => $branch, 1984 + 'against' => $default_branch, 1985 + 'path' => $drequest->getPath(), 1986 + 'offset' => $pager->getOffset(), 1987 + 'limit' => $pager->getPageSize() + 1, 1988 + )); 1989 + } catch (Exception $ex) { 1990 + return null; 1991 + } 1992 + 1993 + $history = DiffusionPathChange::newFromConduit($results['pathChanges']); 1994 + $history = $pager->sliceResults($history); 1995 + 1996 + if (!$history) { 1997 + return null; 1998 + } 1999 + 2000 + $history_table = id(new DiffusionHistoryTableView()) 2001 + ->setViewer($viewer) 2002 + ->setDiffusionRequest($drequest) 2003 + ->setHistory($history); 2004 + 2005 + $history_table->loadRevisions(); 2006 + 2007 + $history_table 2008 + ->setParents($results['parents']) 2009 + ->setFilterParents(true) 2010 + ->setIsHead(true) 2011 + ->setIsTail(!$pager->getHasMorePages()); 2012 + 2013 + $header = id(new PHUIHeaderView()) 2014 + ->setHeader(pht('%s vs %s', $branch, $default_branch)); 2015 + 2016 + return id(new PHUIObjectBoxView()) 2017 + ->setHeader($header) 2018 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 2019 + ->setTable($history_table); 2020 + } 1954 2021 1955 2022 }
+5 -5
src/applications/diffusion/controller/DiffusionCompareController.php
··· 301 301 302 302 $history_table->loadRevisions(); 303 303 304 - if ($history) { 305 - $history_table->setParents($results['parents']); 306 - $history_table->setIsHead(!$pager->getOffset()); 307 - $history_table->setIsTail(!$pager->getHasMorePages()); 308 - } 304 + $history_table 305 + ->setParents($results['parents']) 306 + ->setFilterParents(true) 307 + ->setIsHead(!$pager->getOffset()) 308 + ->setIsTail(!$pager->getHasMorePages()); 309 309 310 310 $header = id(new PHUIHeaderView()) 311 311 ->setHeader(pht('Commits'));
+27 -1
src/applications/diffusion/view/DiffusionHistoryTableView.php
··· 8 8 private $isHead; 9 9 private $isTail; 10 10 private $parents; 11 + private $filterParents; 11 12 12 13 public function setHistory(array $history) { 13 14 assert_instances_of($history, 'DiffusionPathChange'); ··· 66 67 return $this; 67 68 } 68 69 70 + public function setFilterParents($filter_parents) { 71 + $this->filterParents = $filter_parents; 72 + return $this; 73 + } 74 + 75 + public function getFilterParents() { 76 + return $this->filterParents; 77 + } 78 + 69 79 public function render() { 70 80 $drequest = $this->getDiffusionRequest(); 71 81 ··· 82 92 83 93 $graph = null; 84 94 if ($this->parents) { 95 + $parents = $this->parents; 96 + 97 + // If we're filtering parents, remove relationships which point to 98 + // commits that are not part of the visible graph. Otherwise, we get 99 + // a big tree of nonsense when viewing release branches like "stable" 100 + // versus "master". 101 + if ($this->filterParents) { 102 + foreach ($parents as $key => $nodes) { 103 + foreach ($nodes as $nkey => $node) { 104 + if (empty($parents[$node])) { 105 + unset($parents[$key][$nkey]); 106 + } 107 + } 108 + } 109 + } 110 + 85 111 $graph = id(new PHUIDiffGraphView()) 86 112 ->setIsHead($this->isHead) 87 113 ->setIsTail($this->isTail) 88 - ->renderGraph($this->parents); 114 + ->renderGraph($parents); 89 115 } 90 116 91 117 $show_builds = PhabricatorApplication::isClassInstalledForViewer(