Provide "differential.diff.search"
Summary: See PHI90. For now, this only provides a limited amount of information, but should satisfy the use case in PHI90 and build toward a more complete version in the future. Test Plan: Used new Conduit method to retrieve information about diffs. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18744
This commit is contained in:
@@ -439,6 +439,8 @@ phutil_register_library_map(array(
|
|||||||
'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php',
|
'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php',
|
||||||
'DifferentialDiffRepositoryHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryHeraldField.php',
|
'DifferentialDiffRepositoryHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryHeraldField.php',
|
||||||
'DifferentialDiffRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php',
|
'DifferentialDiffRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php',
|
||||||
|
'DifferentialDiffSearchConduitAPIMethod' => 'applications/differential/conduit/DifferentialDiffSearchConduitAPIMethod.php',
|
||||||
|
'DifferentialDiffSearchEngine' => 'applications/differential/query/DifferentialDiffSearchEngine.php',
|
||||||
'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php',
|
'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php',
|
||||||
'DifferentialDiffTransaction' => 'applications/differential/storage/DifferentialDiffTransaction.php',
|
'DifferentialDiffTransaction' => 'applications/differential/storage/DifferentialDiffTransaction.php',
|
||||||
'DifferentialDiffTransactionQuery' => 'applications/differential/query/DifferentialDiffTransactionQuery.php',
|
'DifferentialDiffTransactionQuery' => 'applications/differential/query/DifferentialDiffTransactionQuery.php',
|
||||||
@@ -5435,6 +5437,7 @@ phutil_register_library_map(array(
|
|||||||
'HarbormasterBuildkiteBuildableInterface',
|
'HarbormasterBuildkiteBuildableInterface',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
|
'PhabricatorConduitResultInterface',
|
||||||
),
|
),
|
||||||
'DifferentialDiffAffectedFilesHeraldField' => 'DifferentialDiffHeraldField',
|
'DifferentialDiffAffectedFilesHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
'DifferentialDiffAuthorHeraldField' => 'DifferentialDiffHeraldField',
|
'DifferentialDiffAuthorHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
@@ -5453,6 +5456,8 @@ phutil_register_library_map(array(
|
|||||||
'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'DifferentialDiffRepositoryHeraldField' => 'DifferentialDiffHeraldField',
|
'DifferentialDiffRepositoryHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField',
|
'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
|
'DifferentialDiffSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'DifferentialDiffTestCase' => 'PhutilTestCase',
|
'DifferentialDiffTestCase' => 'PhutilTestCase',
|
||||||
'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction',
|
'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
'DifferentialDiffTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'DifferentialDiffTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffSearchConduitAPIMethod
|
||||||
|
extends PhabricatorSearchEngineAPIMethod {
|
||||||
|
|
||||||
|
public function getAPIMethodName() {
|
||||||
|
return 'differential.diff.search';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newSearchEngine() {
|
||||||
|
return new DifferentialDiffSearchEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMethodSummary() {
|
||||||
|
return pht('Read information about diffs.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,6 +11,16 @@ final class DifferentialQueryDiffsConduitAPIMethod
|
|||||||
return pht('Query differential diffs which match certain criteria.');
|
return pht('Query differential diffs which match certain criteria.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMethodStatus() {
|
||||||
|
return self::METHOD_STATUS_FROZEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMethodStatusDescription() {
|
||||||
|
return pht(
|
||||||
|
'This method is frozen and will eventually be deprecated. New code '.
|
||||||
|
'should use "differential.diff.search" instead.');
|
||||||
|
}
|
||||||
|
|
||||||
protected function defineParamTypes() {
|
protected function defineParamTypes() {
|
||||||
return array(
|
return array(
|
||||||
'ids' => 'optional list<uint>',
|
'ids' => 'optional list<uint>',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ final class DifferentialDiffQuery
|
|||||||
private $ids;
|
private $ids;
|
||||||
private $phids;
|
private $phids;
|
||||||
private $revisionIDs;
|
private $revisionIDs;
|
||||||
|
private $revisionPHIDs;
|
||||||
private $commitPHIDs;
|
private $commitPHIDs;
|
||||||
private $hasRevision;
|
private $hasRevision;
|
||||||
|
|
||||||
@@ -27,6 +28,11 @@ final class DifferentialDiffQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withRevisionPHIDs(array $revision_phids) {
|
||||||
|
$this->revisionPHIDs = $revision_phids;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function withCommitPHIDs(array $phids) {
|
public function withCommitPHIDs(array $phids) {
|
||||||
$this->commitPHIDs = $phids;
|
$this->commitPHIDs = $phids;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -160,6 +166,25 @@ final class DifferentialDiffQuery
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->revisionPHIDs !== null) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$revisions = id(new DifferentialRevisionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->setParentQuery($this)
|
||||||
|
->withPHIDs($this->revisionPHIDs)
|
||||||
|
->execute();
|
||||||
|
$revision_ids = mpull($revisions, 'getID');
|
||||||
|
if (!$revision_ids) {
|
||||||
|
throw new PhabricatorEmptyQueryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn,
|
||||||
|
'revisionID IN (%Ls)',
|
||||||
|
$revision_ids);
|
||||||
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffSearchEngine
|
||||||
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getResultTypeDescription() {
|
||||||
|
return pht('Differential Diffs');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorDifferentialApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newQuery() {
|
||||||
|
return new DifferentialDiffQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildQueryFromParameters(array $map) {
|
||||||
|
$query = $this->newQuery();
|
||||||
|
|
||||||
|
if ($map['revisionPHIDs']) {
|
||||||
|
$query->withRevisionPHIDs($map['revisionPHIDs']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildCustomSearchFields() {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorPHIDsSearchField())
|
||||||
|
->setLabel(pht('Revisions'))
|
||||||
|
->setKey('revisionPHIDs')
|
||||||
|
->setAliases(array('revision', 'revisions', 'revisionPHID'))
|
||||||
|
->setDescription(
|
||||||
|
pht('Find diffs attached to a particular revision.')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getURI($path) {
|
||||||
|
return '/differential/diff/'.$path;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBuiltinQueryNames() {
|
||||||
|
$names = array();
|
||||||
|
|
||||||
|
$names['all'] = pht('All Diffs');
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildSavedQueryFromBuiltin($query_key) {
|
||||||
|
$query = $this->newSavedQuery();
|
||||||
|
$query->setQueryKey($query_key);
|
||||||
|
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
|
switch ($query_key) {
|
||||||
|
case 'all':
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $revisions,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
assert_instances_of($revisions, 'DifferentialDiff');
|
||||||
|
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
|
// NOTE: This is only exposed to Conduit, so we don't currently render
|
||||||
|
// results.
|
||||||
|
|
||||||
|
return id(new PhabricatorApplicationSearchResultView());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,7 +9,8 @@ final class DifferentialDiff
|
|||||||
HarbormasterCircleCIBuildableInterface,
|
HarbormasterCircleCIBuildableInterface,
|
||||||
HarbormasterBuildkiteBuildableInterface,
|
HarbormasterBuildkiteBuildableInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorDestructibleInterface {
|
PhabricatorDestructibleInterface,
|
||||||
|
PhabricatorConduitResultInterface {
|
||||||
|
|
||||||
protected $revisionID;
|
protected $revisionID;
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
@@ -740,4 +741,82 @@ final class DifferentialDiff
|
|||||||
$this->saveTransaction();
|
$this->saveTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorConduitResultInterface )---------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getFieldSpecificationsForConduit() {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('revisionPHID')
|
||||||
|
->setType('phid')
|
||||||
|
->setDescription(pht('Associated revision PHID.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('authorPHID')
|
||||||
|
->setType('phid')
|
||||||
|
->setDescription(pht('Revision author PHID.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('repositoryPHID')
|
||||||
|
->setType('phid')
|
||||||
|
->setDescription(pht('Associated repository PHID.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('refs')
|
||||||
|
->setType('map<string, wild>')
|
||||||
|
->setDescription(pht('List of related VCS references.')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldValuesForConduit() {
|
||||||
|
$refs = array();
|
||||||
|
|
||||||
|
$branch = $this->getBranch();
|
||||||
|
if (strlen($branch)) {
|
||||||
|
$refs[] = array(
|
||||||
|
'type' => 'branch',
|
||||||
|
'name' => $branch,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$onto = $this->loadTargetBranch();
|
||||||
|
if (strlen($onto)) {
|
||||||
|
$refs[] = array(
|
||||||
|
'type' => 'onto',
|
||||||
|
'name' => $onto,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = $this->getSourceControlBaseRevision();
|
||||||
|
if (strlen($base)) {
|
||||||
|
$refs[] = array(
|
||||||
|
'type' => 'base',
|
||||||
|
'identifier' => $base,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$bookmark = $this->getBookmark();
|
||||||
|
if (strlen($bookmark)) {
|
||||||
|
$refs[] = array(
|
||||||
|
'type' => 'bookmark',
|
||||||
|
'name' => $bookmark,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$revision_phid = null;
|
||||||
|
if ($this->getRevisionID()) {
|
||||||
|
$revision_phid = $this->getRevision()->getPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'revisionPHID' => $revision_phid,
|
||||||
|
'authorPHID' => $this->getAuthorPHID(),
|
||||||
|
'repositoryPHID' => $this->getRepositoryPHID(),
|
||||||
|
'refs' => $refs,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConduitSearchAttachments() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user