Support branch offset/limit in Mercurial

Summary:
  - Support offset/limit as added by D2442, for Mercurial.
  - We just list everything and slice, no clear way to do better and this isn't a major perf issue.
  - No clear way to easily get by-update sorting, we can implement this by looking up revs if someone asks.
  - Bury some of the Git implementation details inside the Git query.

Test Plan:
  - Looked at a Git repo, clicked "View All Branches".
  - Looked at a Hg repo, clicked "View All Branches".
  - Limited page size to 1, made sure it limited properly.

Reviewers: aurelijus, btrahan, vrana

Reviewed By: aurelijus

CC: aran

Differential Revision: https://secure.phabricator.com/D2453
This commit is contained in:
epriestley
2012-05-10 14:18:49 -07:00
parent 70e5ef92cf
commit d24c81c5e2
4 changed files with 33 additions and 17 deletions

View File

@@ -32,8 +32,7 @@ final class DiffusionBranchTableController extends DiffusionController {
// TODO: Add support for branches that contain commit
$query = DiffusionBranchQuery::newFromDiffusionRequest($drequest);
$query->setOffset($pager->getOffset());
// we add 2 here, because of removed HEAD branch
$query->setLimit($pager->getPageSize() + 2);
$query->setLimit($pager->getPageSize() + 1);
$branches = $query->loadBranches();
$branches = $pager->sliceResults($branches);

View File

@@ -154,8 +154,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$limit = 15;
$branch_query = DiffusionBranchQuery::newFromDiffusionRequest($drequest);
// we add 2 here, because of removed HEAD branch
$branch_query->setLimit($limit + 2);
$branch_query->setLimit($limit + 1);
$branches = $branch_query->loadBranches();
if (!$branches) {
@@ -182,20 +181,20 @@ final class DiffusionRepositoryController extends DiffusionController {
$panel->setHeader('Branches');
if ($more_branches) {
$panel->setCaption('Showing the ' . $limit . ' most recent branches.');
$panel->setCaption('Showing ' . $limit . ' branches.');
}
$panel->addButton(
phutil_render_tag(
'a',
phutil_render_tag(
'a',
array(
'href' => $drequest->generateURI(
array(
'href' => $drequest->generateURI(
array(
'action' => 'branches',
)),
'class' => 'grey button',
),
"Show All Branches \xC2\xBB"));
'action' => 'branches',
)),
'class' => 'grey button',
),
"Show All Branches \xC2\xBB"));
$panel->appendChild($table);