mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
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
This commit is contained in:
parent
fc1adf9875
commit
4faa4b451f
3 changed files with 107 additions and 14 deletions
|
@ -55,7 +55,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function browseSearch() {
|
private function browseSearch() {
|
||||||
|
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$header = $this->buildHeaderView($drequest);
|
$header = $this->buildHeaderView($drequest);
|
||||||
|
|
||||||
|
@ -77,7 +76,8 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->setFooter(array(
|
->setFooter(
|
||||||
|
array(
|
||||||
$search_form,
|
$search_form,
|
||||||
$search_results,
|
$search_results,
|
||||||
));
|
));
|
||||||
|
@ -337,6 +337,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$empty_result = null;
|
$empty_result = null;
|
||||||
$browse_panel = null;
|
$browse_panel = null;
|
||||||
|
$branch_panel = null;
|
||||||
if (!$results->isValidResults()) {
|
if (!$results->isValidResults()) {
|
||||||
$empty_result = new DiffusionEmptyResultView();
|
$empty_result = new DiffusionEmptyResultView();
|
||||||
$empty_result->setDiffusionRequest($drequest);
|
$empty_result->setDiffusionRequest($drequest);
|
||||||
|
@ -376,6 +377,12 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
pht('Hide Search'),
|
pht('Hide Search'),
|
||||||
$search_form,
|
$search_form,
|
||||||
'#');
|
'#');
|
||||||
|
|
||||||
|
$path = $drequest->getPath();
|
||||||
|
$is_branch = (!strlen($path) && $repository->supportsBranchComparison());
|
||||||
|
if ($is_branch) {
|
||||||
|
$branch_panel = $this->buildBranchTable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$open_revisions = $this->buildOpenRevisions();
|
$open_revisions = $this->buildOpenRevisions();
|
||||||
|
@ -394,11 +401,14 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->setCurtain($curtain)
|
->setCurtain($curtain)
|
||||||
->setMainColumn(array(
|
->setMainColumn(
|
||||||
|
array(
|
||||||
|
$branch_panel,
|
||||||
$empty_result,
|
$empty_result,
|
||||||
$browse_panel,
|
$browse_panel,
|
||||||
))
|
))
|
||||||
->setFooter(array(
|
->setFooter(
|
||||||
|
array(
|
||||||
$open_revisions,
|
$open_revisions,
|
||||||
$readme,
|
$readme,
|
||||||
$pager_box,
|
$pager_box,
|
||||||
|
@ -1951,5 +1961,62 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
return $file;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,11 +301,11 @@ final class DiffusionCompareController extends DiffusionController {
|
||||||
|
|
||||||
$history_table->loadRevisions();
|
$history_table->loadRevisions();
|
||||||
|
|
||||||
if ($history) {
|
$history_table
|
||||||
$history_table->setParents($results['parents']);
|
->setParents($results['parents'])
|
||||||
$history_table->setIsHead(!$pager->getOffset());
|
->setFilterParents(true)
|
||||||
$history_table->setIsTail(!$pager->getHasMorePages());
|
->setIsHead(!$pager->getOffset())
|
||||||
}
|
->setIsTail(!$pager->getHasMorePages());
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Commits'));
|
->setHeader(pht('Commits'));
|
||||||
|
|
|
@ -8,6 +8,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
private $isHead;
|
private $isHead;
|
||||||
private $isTail;
|
private $isTail;
|
||||||
private $parents;
|
private $parents;
|
||||||
|
private $filterParents;
|
||||||
|
|
||||||
public function setHistory(array $history) {
|
public function setHistory(array $history) {
|
||||||
assert_instances_of($history, 'DiffusionPathChange');
|
assert_instances_of($history, 'DiffusionPathChange');
|
||||||
|
@ -66,6 +67,15 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFilterParents($filter_parents) {
|
||||||
|
$this->filterParents = $filter_parents;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilterParents() {
|
||||||
|
return $this->filterParents;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
|
||||||
|
@ -82,10 +92,26 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
|
|
||||||
$graph = null;
|
$graph = null;
|
||||||
if ($this->parents) {
|
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())
|
$graph = id(new PHUIDiffGraphView())
|
||||||
->setIsHead($this->isHead)
|
->setIsHead($this->isHead)
|
||||||
->setIsTail($this->isTail)
|
->setIsTail($this->isTail)
|
||||||
->renderGraph($this->parents);
|
->renderGraph($parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
$show_builds = PhabricatorApplication::isClassInstalledForViewer(
|
$show_builds = PhabricatorApplication::isClassInstalledForViewer(
|
||||||
|
|
Loading…
Reference in a new issue