mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +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() {
|
||||
return array(
|
||||
'closed' => 'optional bool',
|
||||
'limit' => 'optional int',
|
||||
'offset' => 'optional int',
|
||||
'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
|
||||
// filtered untrackable branches out of the result set.
|
||||
|
||||
|
|
|
@ -351,6 +351,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$branches = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.branchquery',
|
||||
array(
|
||||
'closed' => false,
|
||||
'limit' => $limit + 1,
|
||||
));
|
||||
if (!$branches) {
|
||||
|
|
|
@ -756,12 +756,32 @@ abstract class DiffusionRequest {
|
|||
}
|
||||
|
||||
private function chooseBestRefMatch($ref, array $results) {
|
||||
// TODO: Do a better job of selecting the best match.
|
||||
$match = head($results);
|
||||
// First, filter out less-desirable matches.
|
||||
$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
|
||||
// UI can show them to the user.
|
||||
$this->refAlternatives = $results;
|
||||
if (count($candidates) > 1) {
|
||||
$this->refAlternatives = $candidates;
|
||||
}
|
||||
|
||||
return $match;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ final class DiffusionBranchTableView extends DiffusionView {
|
|||
$current_branch = $drequest->getBranch();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$can_close_branches = ($repository->isHg());
|
||||
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
|
||||
|
@ -75,6 +77,14 @@ final class DiffusionBranchTableView extends DiffusionView {
|
|||
'size' => 200,
|
||||
));
|
||||
|
||||
$fields = $branch->getRawFields();
|
||||
$closed = idx($fields, 'closed');
|
||||
if ($closed) {
|
||||
$status = pht('Closed');
|
||||
} else {
|
||||
$status = pht('Open');
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
phutil_tag(
|
||||
'a',
|
||||
|
@ -99,6 +109,7 @@ final class DiffusionBranchTableView extends DiffusionView {
|
|||
self::linkCommit(
|
||||
$drequest->getRepository(),
|
||||
$branch->getCommitIdentifier()),
|
||||
$status,
|
||||
$status_icon,
|
||||
$datetime,
|
||||
AphrontTableView::renderSingleDisplayLine($details),
|
||||
|
@ -116,6 +127,7 @@ final class DiffusionBranchTableView extends DiffusionView {
|
|||
pht('History'),
|
||||
pht('Branch'),
|
||||
pht('Head'),
|
||||
pht('State'),
|
||||
pht(''),
|
||||
pht('Modified'),
|
||||
pht('Details'),
|
||||
|
@ -127,8 +139,16 @@ final class DiffusionBranchTableView extends DiffusionView {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'wide',
|
||||
));
|
||||
$view->setColumnVisibility(
|
||||
array(
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
$can_close_branches,
|
||||
));
|
||||
$view->setRowClasses($rowc);
|
||||
return $view->render();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue