2015-04-27 12:49:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionRefTableController extends DiffusionController {
|
|
|
|
|
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function processDiffusionRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
if (!$drequest->supportsBranches()) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('No Ref Support'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'The version control system this repository uses does not '.
|
|
|
|
'support named references, so you can not resolve or list '.
|
|
|
|
'repository refs in this repository.'))
|
|
|
|
->addCancelButton($repository->getURI());
|
|
|
|
}
|
|
|
|
|
|
|
|
$ref_name = $drequest->getBranch();
|
|
|
|
|
|
|
|
$cache_query = id(new DiffusionCachedResolveRefsQuery())
|
|
|
|
->setRepository($repository);
|
|
|
|
if ($ref_name !== null) {
|
|
|
|
$cache_query->withRefs(array($ref_name));
|
|
|
|
}
|
|
|
|
$cache_refs = $cache_query->execute();
|
|
|
|
|
|
|
|
$vcs_refs = DiffusionQuery::callConduitWithDiffusionRequest(
|
|
|
|
$viewer,
|
|
|
|
$drequest,
|
|
|
|
'diffusion.resolverefs',
|
|
|
|
array(
|
|
|
|
'refs' => array($ref_name),
|
|
|
|
));
|
|
|
|
|
|
|
|
$all = array();
|
|
|
|
foreach ($cache_refs as $ref => $results) {
|
|
|
|
foreach ($results as $result) {
|
|
|
|
$id = $result['type'].'/'.$result['identifier'];
|
|
|
|
$all[$ref][$id]['cache'] = $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($vcs_refs as $ref => $results) {
|
|
|
|
foreach ($results as $result) {
|
|
|
|
$id = $result['type'].'/'.$result['identifier'];
|
|
|
|
$all[$ref][$id]['vcs'] = $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($all as $ref => $results) {
|
|
|
|
foreach ($results as $info) {
|
|
|
|
$cache = idx($info, 'cache', array());
|
|
|
|
$vcs = idx($info, 'vcs', array());
|
|
|
|
|
|
|
|
$type = idx($vcs, 'type');
|
|
|
|
if (!$type) {
|
|
|
|
$type = idx($cache, 'type');
|
|
|
|
}
|
|
|
|
|
Improve low-level branch resolution in Mercurial
Summary:
Ref T7100. Ref T7108. Ref T6160. Several issues:
- High load for mercurial repositories with huge numbers of branches (T7108).
- In Mercurial, we resolve refs individually (one `hg` call per ref).
- Each repository update also updates all refs, which requires resolving all of them.
- For repositories with a huge number of branches,
- We don't distinguish between closed branches (a Mercurial-only concept) and open branches (T6160).
- In Git, when a branch is merged, it ceases to exist.
- In Mercurial, when a branch is merged, it still exists, it's just "closed". Normally, no one cares about these branches.
- In the low-level query, correctly identify which refs we resolve as branches.
- In the low-level query, correctly mark closed branches as closed.
- This marginally improves ref handling in general (see T7100).
Test Plan:
{F384366}
{F384367}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6160, T7108, T7100
Differential Revision: https://secure.phabricator.com/D12548
2015-04-27 12:50:20 +02:00
|
|
|
$hash = idx($vcs, 'identifier');
|
|
|
|
if ($hash !== null) {
|
|
|
|
$hash = DiffusionView::linkCommit(
|
2015-04-27 12:49:57 +02:00
|
|
|
$repository,
|
Improve low-level branch resolution in Mercurial
Summary:
Ref T7100. Ref T7108. Ref T6160. Several issues:
- High load for mercurial repositories with huge numbers of branches (T7108).
- In Mercurial, we resolve refs individually (one `hg` call per ref).
- Each repository update also updates all refs, which requires resolving all of them.
- For repositories with a huge number of branches,
- We don't distinguish between closed branches (a Mercurial-only concept) and open branches (T6160).
- In Git, when a branch is merged, it ceases to exist.
- In Mercurial, when a branch is merged, it still exists, it's just "closed". Normally, no one cares about these branches.
- In the low-level query, correctly identify which refs we resolve as branches.
- In the low-level query, correctly mark closed branches as closed.
- This marginally improves ref handling in general (see T7100).
Test Plan:
{F384366}
{F384367}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6160, T7108, T7100
Differential Revision: https://secure.phabricator.com/D12548
2015-04-27 12:50:20 +02:00
|
|
|
$hash);
|
2015-04-27 12:49:57 +02:00
|
|
|
}
|
|
|
|
|
Improve low-level branch resolution in Mercurial
Summary:
Ref T7100. Ref T7108. Ref T6160. Several issues:
- High load for mercurial repositories with huge numbers of branches (T7108).
- In Mercurial, we resolve refs individually (one `hg` call per ref).
- Each repository update also updates all refs, which requires resolving all of them.
- For repositories with a huge number of branches,
- We don't distinguish between closed branches (a Mercurial-only concept) and open branches (T6160).
- In Git, when a branch is merged, it ceases to exist.
- In Mercurial, when a branch is merged, it still exists, it's just "closed". Normally, no one cares about these branches.
- In the low-level query, correctly identify which refs we resolve as branches.
- In the low-level query, correctly mark closed branches as closed.
- This marginally improves ref handling in general (see T7100).
Test Plan:
{F384366}
{F384367}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6160, T7108, T7100
Differential Revision: https://secure.phabricator.com/D12548
2015-04-27 12:50:20 +02:00
|
|
|
$cached_hash = idx($cache, 'identifier');
|
|
|
|
if ($cached_hash !== null) {
|
|
|
|
$cache_hash = DiffusionView::linkCommit(
|
2015-04-27 12:49:57 +02:00
|
|
|
$repository,
|
Improve low-level branch resolution in Mercurial
Summary:
Ref T7100. Ref T7108. Ref T6160. Several issues:
- High load for mercurial repositories with huge numbers of branches (T7108).
- In Mercurial, we resolve refs individually (one `hg` call per ref).
- Each repository update also updates all refs, which requires resolving all of them.
- For repositories with a huge number of branches,
- We don't distinguish between closed branches (a Mercurial-only concept) and open branches (T6160).
- In Git, when a branch is merged, it ceases to exist.
- In Mercurial, when a branch is merged, it still exists, it's just "closed". Normally, no one cares about these branches.
- In the low-level query, correctly identify which refs we resolve as branches.
- In the low-level query, correctly mark closed branches as closed.
- This marginally improves ref handling in general (see T7100).
Test Plan:
{F384366}
{F384367}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6160, T7108, T7100
Differential Revision: https://secure.phabricator.com/D12548
2015-04-27 12:50:20 +02:00
|
|
|
$cached_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
$closed = idx($vcs, 'closed', false);
|
|
|
|
if (!$vcs) {
|
|
|
|
$state = null;
|
|
|
|
} else {
|
|
|
|
$state = $closed ? pht('Closed') : pht('Open');
|
|
|
|
}
|
|
|
|
|
|
|
|
$cached_closed = idx($cache, 'closed', false);
|
|
|
|
if (!$cache) {
|
|
|
|
$cached_state = null;
|
|
|
|
} else {
|
|
|
|
$cached_state = $cached_closed ? pht('Closed') : pht('Open');
|
2015-04-27 12:49:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$alternate = idx($vcs, 'alternate');
|
|
|
|
if ($alternate !== null) {
|
|
|
|
$alternate = DiffusionView::linkCommit(
|
|
|
|
$repository,
|
|
|
|
$alternate);
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
$ref,
|
|
|
|
$type,
|
Improve low-level branch resolution in Mercurial
Summary:
Ref T7100. Ref T7108. Ref T6160. Several issues:
- High load for mercurial repositories with huge numbers of branches (T7108).
- In Mercurial, we resolve refs individually (one `hg` call per ref).
- Each repository update also updates all refs, which requires resolving all of them.
- For repositories with a huge number of branches,
- We don't distinguish between closed branches (a Mercurial-only concept) and open branches (T6160).
- In Git, when a branch is merged, it ceases to exist.
- In Mercurial, when a branch is merged, it still exists, it's just "closed". Normally, no one cares about these branches.
- In the low-level query, correctly identify which refs we resolve as branches.
- In the low-level query, correctly mark closed branches as closed.
- This marginally improves ref handling in general (see T7100).
Test Plan:
{F384366}
{F384367}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6160, T7108, T7100
Differential Revision: https://secure.phabricator.com/D12548
2015-04-27 12:50:20 +02:00
|
|
|
$hash,
|
|
|
|
$cached_hash,
|
|
|
|
$state,
|
|
|
|
$cached_state,
|
2015-04-27 12:49:57 +02:00
|
|
|
$alternate,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
|
|
|
pht('Ref'),
|
|
|
|
pht('Type'),
|
Improve low-level branch resolution in Mercurial
Summary:
Ref T7100. Ref T7108. Ref T6160. Several issues:
- High load for mercurial repositories with huge numbers of branches (T7108).
- In Mercurial, we resolve refs individually (one `hg` call per ref).
- Each repository update also updates all refs, which requires resolving all of them.
- For repositories with a huge number of branches,
- We don't distinguish between closed branches (a Mercurial-only concept) and open branches (T6160).
- In Git, when a branch is merged, it ceases to exist.
- In Mercurial, when a branch is merged, it still exists, it's just "closed". Normally, no one cares about these branches.
- In the low-level query, correctly identify which refs we resolve as branches.
- In the low-level query, correctly mark closed branches as closed.
- This marginally improves ref handling in general (see T7100).
Test Plan:
{F384366}
{F384367}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6160, T7108, T7100
Differential Revision: https://secure.phabricator.com/D12548
2015-04-27 12:50:20 +02:00
|
|
|
pht('Hash'),
|
|
|
|
pht('Cached Hash'),
|
|
|
|
pht('State'),
|
|
|
|
pht('Cached State'),
|
2015-04-27 12:49:57 +02:00
|
|
|
pht('Alternate'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$content = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Ref "%s"', $ref_name))
|
|
|
|
->appendChild($table);
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(array());
|
|
|
|
$crumbs->addTextCrumb(pht('Refs'));
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$content,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => array(
|
|
|
|
pht('Refs'),
|
|
|
|
$repository->getMonogram(),
|
|
|
|
$ref_name,
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|