1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-17 10:11:10 +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 $branches = array();
private $arcanistProjectPHIDs = array(); private $arcanistProjectPHIDs = array();
private $draftRevisions = array(); private $draftRevisions = array();
private $repositoryPHIDs;
private $order = 'order-modified'; private $order = 'order-modified';
const ORDER_MODIFIED = 'order-modified'; const ORDER_MODIFIED = 'order-modified';
@ -246,6 +247,11 @@ final class DifferentialRevisionQuery
return $this; return $this;
} }
public function withRepositoryPHIDs(array $repository_phids) {
$this->repositoryPHIDs = $repository_phids;
return $this;
}
/** /**
* Set result ordering. Provide a class constant, such as * Set result ordering. Provide a class constant, such as
@ -658,6 +664,13 @@ final class DifferentialRevisionQuery
$this->revIDs); $this->revIDs);
} }
if ($this->repositoryPHIDs) {
$where[] = qsprintf(
$conn_r,
'r.repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
if ($this->commitHashes) { if ($this->commitHashes) {
$hash_clauses = array(); $hash_clauses = array();
foreach ($this->commitHashes as $info) { foreach ($this->commitHashes as $info) {

View file

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