Page MenuHomePhabricator

D21558.id51319.diff
No OneTemporary

D21558.id51319.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -477,6 +477,7 @@
'DifferentialChangesetParserTestCase' => 'applications/differential/parser/__tests__/DifferentialChangesetParserTestCase.php',
'DifferentialChangesetQuery' => 'applications/differential/query/DifferentialChangesetQuery.php',
'DifferentialChangesetRenderer' => 'applications/differential/render/DifferentialChangesetRenderer.php',
+ 'DifferentialChangesetSearchConduitAPIMethod' => 'applications/differential/conduit/DifferentialChangesetSearchConduitAPIMethod.php',
'DifferentialChangesetSearchEngine' => 'applications/differential/query/DifferentialChangesetSearchEngine.php',
'DifferentialChangesetTestRenderer' => 'applications/differential/render/DifferentialChangesetTestRenderer.php',
'DifferentialChangesetTwoUpRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpRenderer.php',
@@ -6533,6 +6534,7 @@
'DifferentialDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
+ 'PhabricatorConduitResultInterface',
),
'DifferentialChangesetDetailView' => 'AphrontView',
'DifferentialChangesetEngine' => 'Phobject',
@@ -6547,6 +6549,7 @@
'DifferentialChangesetParserTestCase' => 'PhabricatorTestCase',
'DifferentialChangesetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DifferentialChangesetRenderer' => 'Phobject',
+ 'DifferentialChangesetSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'DifferentialChangesetSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DifferentialChangesetTestRenderer' => 'DifferentialChangesetRenderer',
'DifferentialChangesetTwoUpRenderer' => 'DifferentialChangesetHTMLRenderer',
diff --git a/src/applications/differential/conduit/DifferentialChangesetSearchConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialChangesetSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/conduit/DifferentialChangesetSearchConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class DifferentialChangesetSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'differential.changeset.search';
+ }
+
+ public function newSearchEngine() {
+ return new DifferentialChangesetSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Read information about changesets.');
+ }
+
+}
diff --git a/src/applications/differential/query/DifferentialChangesetQuery.php b/src/applications/differential/query/DifferentialChangesetQuery.php
--- a/src/applications/differential/query/DifferentialChangesetQuery.php
+++ b/src/applications/differential/query/DifferentialChangesetQuery.php
@@ -4,6 +4,9 @@
extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids;
+ private $phids;
+ private $diffPHIDs;
+
private $diffs;
private $needAttachToDiffs;
@@ -14,12 +17,22 @@
return $this;
}
+ public function withPHIDs(array $phids) {
+ $this->phids = $phids;
+ return $this;
+ }
+
public function withDiffs(array $diffs) {
assert_instances_of($diffs, 'DifferentialDiff');
$this->diffs = $diffs;
return $this;
}
+ public function withDiffPHIDs(array $phids) {
+ $this->diffPHIDs = $phids;
+ return $this;
+ }
+
public function needAttachToDiffs($attach) {
$this->needAttachToDiffs = $attach;
return $this;
@@ -134,6 +147,31 @@
$this->ids);
}
+ if ($this->phids !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'phid IN (%Ls)',
+ $this->phids);
+ }
+
+ if ($this->diffPHIDs !== null) {
+ $diff_ids = queryfx_all(
+ $conn,
+ 'SELECT id FROM %R WHERE phid IN (%Ls)',
+ new DifferentialDiff(),
+ $this->diffPHIDs);
+ $diff_ids = ipull($diff_ids, 'id', null);
+
+ if (!$diff_ids) {
+ throw new PhabricatorEmptyQueryException();
+ }
+
+ $where[] = qsprintf(
+ $conn,
+ 'diffID IN (%Ld)',
+ $diff_ids);
+ }
+
return $where;
}
diff --git a/src/applications/differential/query/DifferentialChangesetSearchEngine.php b/src/applications/differential/query/DifferentialChangesetSearchEngine.php
--- a/src/applications/differential/query/DifferentialChangesetSearchEngine.php
+++ b/src/applications/differential/query/DifferentialChangesetSearchEngine.php
@@ -38,11 +38,23 @@
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
+
+ if ($map['diffPHIDs']) {
+ $query->withDiffPHIDs($map['diffPHIDs']);
+ }
+
return $query;
}
protected function buildCustomSearchFields() {
- return array();
+ return array(
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Diffs'))
+ ->setKey('diffPHIDs')
+ ->setAliases(array('diff', 'diffs', 'diffPHID'))
+ ->setDescription(
+ pht('Find changesets attached to a particular diff.')),
+ );
}
protected function getURI($path) {
diff --git a/src/applications/differential/storage/DifferentialChangeset.php b/src/applications/differential/storage/DifferentialChangeset.php
--- a/src/applications/differential/storage/DifferentialChangeset.php
+++ b/src/applications/differential/storage/DifferentialChangeset.php
@@ -4,7 +4,8 @@
extends DifferentialDAO
implements
PhabricatorPolicyInterface,
- PhabricatorDestructibleInterface {
+ PhabricatorDestructibleInterface,
+ PhabricatorConduitResultInterface {
protected $diffID;
protected $oldFile;
@@ -735,5 +736,49 @@
$this->saveTransaction();
}
+/* -( PhabricatorConduitResultInterface )---------------------------------- */
+
+ public function getFieldSpecificationsForConduit() {
+ return array(
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('diffPHID')
+ ->setType('phid')
+ ->setDescription(pht('The diff the changeset is attached to.')),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ $diff = $this->getDiff();
+
+ $repository = null;
+ if ($diff) {
+ $revision = $diff->getRevision();
+ if ($revision) {
+ $repository = $revision->getRepository();
+ }
+ }
+
+ $absolute_path = $this->getAbsoluteRepositoryPath($repository, $diff);
+ if (strlen($absolute_path)) {
+ $absolute_path = base64_encode($absolute_path);
+ } else {
+ $absolute_path = null;
+ }
+
+ $display_path = $this->getDisplayFilename();
+
+ return array(
+ 'diffPHID' => $diff->getPHID(),
+ 'path' => array(
+ 'displayPath' => $display_path,
+ 'absolutePath.base64' => $absolute_path,
+ ),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array();
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 2, 6:30 PM (2 w, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7382094
Default Alt Text
D21558.id51319.diff (6 KB)

Event Timeline