mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Ignore closed branch heads by default in Mercurial
Summary: Fixes T6160. Ref T7100. - When resolving ambiguous branch references, ignore closed heads unless there are no other options. - Hide closed heads by default on the main page. - Show branch open/closed state in Mercurial. Test Plan: Browsed a previously-ambiguous Mercurial repository because of multiple branch heads, no longer ambiguous. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6160, T7100 Differential Revision: https://secure.phabricator.com/D12552
This commit is contained in:
parent
2c9b194d16
commit
d3436c256c
4 changed files with 55 additions and 3 deletions
|
@ -17,6 +17,7 @@ final class DiffusionBranchQueryConduitAPIMethod
|
||||||
|
|
||||||
protected function defineCustomParamTypes() {
|
protected function defineCustomParamTypes() {
|
||||||
return array(
|
return array(
|
||||||
|
'closed' => 'optional bool',
|
||||||
'limit' => 'optional int',
|
'limit' => 'optional int',
|
||||||
'offset' => 'optional int',
|
'offset' => 'optional int',
|
||||||
'contains' => 'optional string',
|
'contains' => 'optional string',
|
||||||
|
@ -97,6 +98,16 @@ final class DiffusionBranchQueryConduitAPIMethod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$with_closed = $request->getValue('closed');
|
||||||
|
if ($with_closed !== null) {
|
||||||
|
foreach ($refs as $key => $ref) {
|
||||||
|
$fields = $ref->getRawFields();
|
||||||
|
if (idx($fields, 'closed') != $with_closed) {
|
||||||
|
unset($refs[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: We can't apply the offset or limit until here, because we may have
|
// NOTE: We can't apply the offset or limit until here, because we may have
|
||||||
// filtered untrackable branches out of the result set.
|
// filtered untrackable branches out of the result set.
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
$branches = $this->callConduitWithDiffusionRequest(
|
$branches = $this->callConduitWithDiffusionRequest(
|
||||||
'diffusion.branchquery',
|
'diffusion.branchquery',
|
||||||
array(
|
array(
|
||||||
|
'closed' => false,
|
||||||
'limit' => $limit + 1,
|
'limit' => $limit + 1,
|
||||||
));
|
));
|
||||||
if (!$branches) {
|
if (!$branches) {
|
||||||
|
|
|
@ -756,12 +756,32 @@ abstract class DiffusionRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function chooseBestRefMatch($ref, array $results) {
|
private function chooseBestRefMatch($ref, array $results) {
|
||||||
// TODO: Do a better job of selecting the best match.
|
// First, filter out less-desirable matches.
|
||||||
$match = head($results);
|
$candidates = array();
|
||||||
|
foreach ($results as $result) {
|
||||||
|
// Exclude closed heads.
|
||||||
|
if ($result['type'] == 'branch') {
|
||||||
|
if (idx($result, 'closed')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$candidates[] = $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we filtered everything, undo the filtering.
|
||||||
|
if (!$candidates) {
|
||||||
|
$candidates = $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Do a better job of selecting the best match?
|
||||||
|
$match = head($candidates);
|
||||||
|
|
||||||
// After choosing the best alternative, save all the alternatives so the
|
// After choosing the best alternative, save all the alternatives so the
|
||||||
// UI can show them to the user.
|
// UI can show them to the user.
|
||||||
$this->refAlternatives = $results;
|
if (count($candidates) > 1) {
|
||||||
|
$this->refAlternatives = $candidates;
|
||||||
|
}
|
||||||
|
|
||||||
return $match;
|
return $match;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
$current_branch = $drequest->getBranch();
|
$current_branch = $drequest->getBranch();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
|
$can_close_branches = ($repository->isHg());
|
||||||
|
|
||||||
Javelin::initBehavior('phabricator-tooltips');
|
Javelin::initBehavior('phabricator-tooltips');
|
||||||
|
|
||||||
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
|
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
|
||||||
|
@ -75,6 +77,14 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
'size' => 200,
|
'size' => 200,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$fields = $branch->getRawFields();
|
||||||
|
$closed = idx($fields, 'closed');
|
||||||
|
if ($closed) {
|
||||||
|
$status = pht('Closed');
|
||||||
|
} else {
|
||||||
|
$status = pht('Open');
|
||||||
|
}
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
phutil_tag(
|
phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
|
@ -99,6 +109,7 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
self::linkCommit(
|
self::linkCommit(
|
||||||
$drequest->getRepository(),
|
$drequest->getRepository(),
|
||||||
$branch->getCommitIdentifier()),
|
$branch->getCommitIdentifier()),
|
||||||
|
$status,
|
||||||
$status_icon,
|
$status_icon,
|
||||||
$datetime,
|
$datetime,
|
||||||
AphrontTableView::renderSingleDisplayLine($details),
|
AphrontTableView::renderSingleDisplayLine($details),
|
||||||
|
@ -116,6 +127,7 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
pht('History'),
|
pht('History'),
|
||||||
pht('Branch'),
|
pht('Branch'),
|
||||||
pht('Head'),
|
pht('Head'),
|
||||||
|
pht('State'),
|
||||||
pht(''),
|
pht(''),
|
||||||
pht('Modified'),
|
pht('Modified'),
|
||||||
pht('Details'),
|
pht('Details'),
|
||||||
|
@ -127,8 +139,16 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
'',
|
||||||
'wide',
|
'wide',
|
||||||
));
|
));
|
||||||
|
$view->setColumnVisibility(
|
||||||
|
array(
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
$can_close_branches,
|
||||||
|
));
|
||||||
$view->setRowClasses($rowc);
|
$view->setRowClasses($rowc);
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue