Page MenuHomePhabricator

D21443.id.diff
No OneTemporary

D21443.id.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
@@ -873,6 +873,8 @@
'DiffusionIdentityViewController' => 'applications/diffusion/controller/DiffusionIdentityViewController.php',
'DiffusionInlineCommentController' => 'applications/diffusion/controller/DiffusionInlineCommentController.php',
'DiffusionInternalAncestorsConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionInternalAncestorsConduitAPIMethod.php',
+ 'DiffusionInternalCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionInternalCommitSearchConduitAPIMethod.php',
+ 'DiffusionInternalCommitSearchEngine' => 'applications/audit/query/DiffusionInternalCommitSearchEngine.php',
'DiffusionInternalGitRawDiffQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php',
'DiffusionLastModifiedController' => 'applications/diffusion/controller/DiffusionLastModifiedController.php',
'DiffusionLastModifiedQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionLastModifiedQueryConduitAPIMethod.php',
@@ -6976,6 +6978,8 @@
'DiffusionIdentityViewController' => 'DiffusionController',
'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController',
'DiffusionInternalAncestorsConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
+ 'DiffusionInternalCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
+ 'DiffusionInternalCommitSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DiffusionInternalGitRawDiffQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionLastModifiedController' => 'DiffusionController',
'DiffusionLastModifiedQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
diff --git a/src/applications/audit/query/DiffusionInternalCommitSearchEngine.php b/src/applications/audit/query/DiffusionInternalCommitSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/audit/query/DiffusionInternalCommitSearchEngine.php
@@ -0,0 +1,75 @@
+<?php
+
+final class DiffusionInternalCommitSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function getResultTypeDescription() {
+ return pht('Diffusion Raw Commits');
+ }
+
+ public function getApplicationClassName() {
+ return 'PhabricatorDiffusionApplication';
+ }
+
+ public function newQuery() {
+ return new DiffusionCommitQuery();
+ }
+
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
+
+ if ($map['repositoryPHIDs']) {
+ $query->withRepositoryPHIDs($map['repositoryPHIDs']);
+ }
+
+ return $query;
+ }
+
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Repositories'))
+ ->setKey('repositoryPHIDs')
+ ->setDatasource(new DiffusionRepositoryFunctionDatasource())
+ ->setDescription(pht('Find commits in particular repositories.')),
+ );
+ }
+
+ protected function getURI($path) {
+ return null;
+ }
+
+ protected function renderResultList(
+ array $commits,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+ return null;
+ }
+
+ protected function getObjectWireFieldsForConduit(
+ $object,
+ array $field_extensions,
+ array $extension_data) {
+
+ $commit = $object;
+ $viewer = $this->requireViewer();
+
+ $repository = $commit->getRepository();
+ $identifier = $commit->getCommitIdentifier();
+
+ id(new DiffusionRepositoryClusterEngine())
+ ->setViewer($viewer)
+ ->setRepository($repository)
+ ->synchronizeWorkingCopyBeforeRead();
+
+ $ref = id(new DiffusionLowLevelCommitQuery())
+ ->setRepository($repository)
+ ->withIdentifier($identifier)
+ ->execute();
+
+ return array(
+ 'ref' => $ref->newDictionary(),
+ );
+ }
+
+}
diff --git a/src/applications/diffusion/conduit/DiffusionInternalCommitSearchConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionInternalCommitSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/conduit/DiffusionInternalCommitSearchConduitAPIMethod.php
@@ -0,0 +1,58 @@
+<?php
+
+final class DiffusionInternalCommitSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'internal.commit.search';
+ }
+
+ public function newSearchEngine() {
+ return new DiffusionInternalCommitSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Read raw information about commits.');
+ }
+
+ protected function newConduitCallProxyClient(ConduitAPIRequest $request) {
+ $viewer = $request->getViewer();
+
+ $constraints = $request->getValue('constraints');
+ if (is_array($constraints)) {
+ $repository_phids = idx($constraints, 'repositoryPHIDs');
+ } else {
+ $repository_phids = array();
+ }
+
+ $repository_phid = null;
+ if (is_array($repository_phids)) {
+ if (phutil_is_natural_list($repository_phids)) {
+ if (count($repository_phids) === 1) {
+ $value = head($repository_phids);
+ if (is_string($value)) {
+ $repository_phid = $value;
+ }
+ }
+ }
+ }
+
+ if ($repository_phid === null) {
+ throw new Exception(
+ pht(
+ 'This internal method must be invoked with a "repositoryPHIDs" '.
+ 'constraint with exactly one value.'));
+ }
+
+ $repository = id(new PhabricatorRepositoryQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($repository_phid))
+ ->executeOne();
+ if (!$repository) {
+ return array();
+ }
+
+ return $repository->newConduitClientForRequest($request);
+ }
+
+}
diff --git a/src/applications/diffusion/data/DiffusionCommitHash.php b/src/applications/diffusion/data/DiffusionCommitHash.php
--- a/src/applications/diffusion/data/DiffusionCommitHash.php
+++ b/src/applications/diffusion/data/DiffusionCommitHash.php
@@ -34,4 +34,21 @@
}
return $hash_objects;
}
+
+ public static function newFromDictionary(array $map) {
+ $hash_type = idx($map, 'type');
+ $hash_value = idx($map, 'value');
+
+ return id(new self())
+ ->setHashType($hash_type)
+ ->setHashValue($hash_value);
+ }
+
+ public function newDictionary() {
+ return array(
+ 'type' => $this->hashType,
+ 'value' => $this->hashValue,
+ );
+ }
+
}
diff --git a/src/applications/diffusion/data/DiffusionCommitRef.php b/src/applications/diffusion/data/DiffusionCommitRef.php
--- a/src/applications/diffusion/data/DiffusionCommitRef.php
+++ b/src/applications/diffusion/data/DiffusionCommitRef.php
@@ -10,28 +10,52 @@
private $committerEmail;
private $hashes = array();
- public static function newFromConduitResult(array $result) {
- $ref = id(new DiffusionCommitRef())
- ->setAuthorEpoch(idx($result, 'authorEpoch'))
- ->setCommitterEmail(idx($result, 'committerEmail'))
- ->setCommitterName(idx($result, 'committerName'))
- ->setAuthorEmail(idx($result, 'authorEmail'))
- ->setAuthorName(idx($result, 'authorName'))
- ->setMessage(idx($result, 'message'));
-
- $hashes = array();
- foreach (idx($result, 'hashes', array()) as $hash_result) {
- $hashes[] = id(new DiffusionCommitHash())
- ->setHashType(idx($hash_result, 'type'))
- ->setHashValue(idx($hash_result, 'value'));
+ public function newDictionary() {
+ $hashes = $this->getHashes();
+ $hashes = mpull($hashes, 'newDictionary');
+ $hashes = array_values($hashes);
+
+ return array(
+ 'authorEpoch' => $this->authorEpoch,
+ 'authorName' => $this->authorName,
+ 'authorEmail' => $this->authorEmail,
+ 'committerName' => $this->committerName,
+ 'committerEmail' => $this->committerEmail,
+ 'message' => $this->message,
+ 'hashes' => $hashes,
+ );
+ }
+
+ public static function newFromDictionary(array $map) {
+ $hashes = idx($map, 'hashes', array());
+ foreach ($hashes as $key => $hash_map) {
+ $hashes[$key] = DiffusionCommitHash::newFromDictionary($hash_map);
}
+ $hashes = array_values($hashes);
+
+ $author_epoch = idx($map, 'authorEpoch');
+ $author_name = idx($map, 'authorName');
+ $author_email = idx($map, 'authorEmail');
+ $committer_name = idx($map, 'committerName');
+ $committer_email = idx($map, 'committerEmail');
+ $message = idx($map, 'message');
- $ref->setHashes($hashes);
+ return id(new self())
+ ->setAuthorEpoch($author_epoch)
+ ->setAuthorName($author_name)
+ ->setAuthorEmail($author_email)
+ ->setCommitterName($committer_name)
+ ->setCommitterEmail($committer_email)
+ ->setMessage($message)
+ ->setHashes($hashes);
+ }
- return $ref;
+ public static function newFromConduitResult(array $result) {
+ return self::newFromDictionary($result);
}
public function setHashes(array $hashes) {
+ assert_instances_of($hashes, 'DiffusionCommitHash');
$this->hashes = $hashes;
return $this;
}
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommitData.php b/src/applications/repository/storage/PhabricatorRepositoryCommitData.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommitData.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommitData.php
@@ -92,4 +92,13 @@
return array_values($holds);
}
+ public function setCommitRef(DiffusionCommitRef $ref) {
+ $this->setCommitDetail('commitRef', $ref->newDictionary());
+ }
+
+ public function newCommitRef() {
+ $map = $this->getCommitDetail('commitRef', array());
+ return DiffusionCommitRef::neWFromDictionary($map);
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 29, 4:58 PM (7 h, 13 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6806199
Default Alt Text
D21443.id.diff (9 KB)

Event Timeline