1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

Allow revisions to be queried by repository

Summary: This isn't too useful most of the time since we don't automatically populate this data yet, but works fine.

Test Plan: See screenshot.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7144
This commit is contained in:
epriestley 2013-09-26 14:17:26 -07:00
parent 3d354d205f
commit b435c0297e
2 changed files with 34 additions and 6 deletions

View file

@ -39,6 +39,7 @@ final class DifferentialRevisionQuery
private $branches = array();
private $arcanistProjectPHIDs = array();
private $draftRevisions = array();
private $repositoryPHIDs;
private $order = 'order-modified';
const ORDER_MODIFIED = 'order-modified';
@ -246,6 +247,11 @@ final class DifferentialRevisionQuery
return $this;
}
public function withRepositoryPHIDs(array $repository_phids) {
$this->repositoryPHIDs = $repository_phids;
return $this;
}
/**
* Set result ordering. Provide a class constant, such as
@ -658,6 +664,13 @@ final class DifferentialRevisionQuery
$this->revIDs);
}
if ($this->repositoryPHIDs) {
$where[] = qsprintf(
$conn_r,
'r.repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
if ($this->commitHashes) {
$hash_clauses = array();
foreach ($this->commitHashes as $info) {

View file

@ -29,6 +29,10 @@ final class DifferentialRevisionSearchEngine
'subscriberPHIDs',
$this->readUsersFromRequest($request, 'subscribers'));
$saved->setParameter(
'repositoryPHIDs',
$request->getArr('repositories'));
$saved->setParameter(
'draft',
$request->getBool('draft'));
@ -68,6 +72,11 @@ final class DifferentialRevisionSearchEngine
$query->withCCs($subscriber_phids);
}
$repository_phids = $saved->getParameter('repositoryPHIDs', array());
if ($repository_phids) {
$query->withRepositoryPHIDs($repository_phids);
}
$draft = $saved->getParameter('draft', false);
if ($draft && $this->requireViewer()->isLoggedIn()) {
$query->withDraftRepliesByAuthors(
@ -97,6 +106,7 @@ final class DifferentialRevisionSearchEngine
$author_phids = $saved->getParameter('authorPHIDs', array());
$reviewer_phids = $saved->getParameter('reviewerPHIDs', array());
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
$repository_phids = $saved->getParameter('repositoryPHIDs', array());
$only_draft = $saved->getParameter('draft', false);
$all_phids = array_mergev(
@ -105,6 +115,7 @@ final class DifferentialRevisionSearchEngine
$author_phids,
$reviewer_phids,
$subscriber_phids,
$repository_phids,
));
$handles = id(new PhabricatorHandleQuery())
@ -112,33 +123,37 @@ final class DifferentialRevisionSearchEngine
->withPHIDs($all_phids)
->execute();
$tokens = mpull($handles, 'getFullName', 'getPHID');
$form
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Responsible Users'))
->setName('responsibles')
->setDatasource('/typeahead/common/accounts/')
->setValue(array_select_keys($tokens, $responsible_phids)))
->setValue(array_select_keys($handles, $responsible_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Authors'))
->setName('authors')
->setDatasource('/typeahead/common/accounts/')
->setValue(array_select_keys($tokens, $author_phids)))
->setValue(array_select_keys($handles, $author_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Reviewers'))
->setName('reviewers')
->setDatasource('/typeahead/common/accounts/')
->setValue(array_select_keys($tokens, $reviewer_phids)))
->setValue(array_select_keys($handles, $reviewer_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Subscribers'))
->setName('subscribers')
->setDatasource('/typeahead/common/allmailable/')
->setValue(array_select_keys($tokens, $subscriber_phids)))
->setValue(array_select_keys($handles, $subscriber_phids)))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Repositories'))
->setName('repositories')
->setDatasource('/typeahead/common/repositories/')
->setValue(array_select_keys($handles, $repository_phids)))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Status'))