Page MenuHomePhabricator

D19423.id.diff
No OneTemporary

D19423.id.diff

diff --git a/resources/sql/autopatches/20180430.repo_identity.sql b/resources/sql/autopatches/20180430.repo_identity.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180430.repo_identity.sql
@@ -0,0 +1,14 @@
+CREATE TABLE {$NAMESPACE}_repository.repository_identity (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ phid VARBINARY(64) NOT NULL,
+ dateCreated INT UNSIGNED NOT NULL,
+ dateModified INT UNSIGNED NOT NULL,
+ automaticGuessedUserPHID VARBINARY(64) DEFAULT NULL,
+ manuallySetUserPHID VARBINARY(64) DEFAULT NULL,
+ currentEffectiveUserPHID VARBINARY(64) DEFAULT NULL,
+ identityNameHash BINARY(12) NOT NULL,
+ identityNameRaw LONGBLOB NOT NULL,
+ identityNameEncoding VARCHAR(16) DEFAULT NULL COLLATE {$COLLATE_TEXT},
+ UNIQUE KEY `key_phid` (phid),
+ UNIQUE KEY `key_identity` (identityNameHash)
+) ENGINE=InnoDB DEFAULT CHARSET={$CHARSET} COLLATE={$COLLATE_TEXT};
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
@@ -4085,6 +4085,9 @@
'PhabricatorRepositoryGitLFSRefQuery' => 'applications/repository/query/PhabricatorRepositoryGitLFSRefQuery.php',
'PhabricatorRepositoryGraphCache' => 'applications/repository/graphcache/PhabricatorRepositoryGraphCache.php',
'PhabricatorRepositoryGraphStream' => 'applications/repository/daemon/PhabricatorRepositoryGraphStream.php',
+ 'PhabricatorRepositoryIdentity' => 'applications/repository/storage/PhabricatorRepositoryIdentity.php',
+ 'PhabricatorRepositoryIdentityPHIDType' => 'applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php',
+ 'PhabricatorRepositoryIdentityQuery' => 'applications/repository/query/PhabricatorRepositoryIdentityQuery.php',
'PhabricatorRepositoryManagementCacheWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementCacheWorkflow.php',
'PhabricatorRepositoryManagementClusterizeWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementClusterizeWorkflow.php',
'PhabricatorRepositoryManagementDiscoverWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementDiscoverWorkflow.php',
@@ -9975,6 +9978,9 @@
'PhabricatorRepositoryGitLFSRefQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorRepositoryGraphCache' => 'Phobject',
'PhabricatorRepositoryGraphStream' => 'Phobject',
+ 'PhabricatorRepositoryIdentity' => 'PhabricatorRepositoryDAO',
+ 'PhabricatorRepositoryIdentityPHIDType' => 'PhabricatorPHIDType',
+ 'PhabricatorRepositoryIdentityQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorRepositoryManagementCacheWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
'PhabricatorRepositoryManagementClusterizeWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
'PhabricatorRepositoryManagementDiscoverWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
diff --git a/src/applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php b/src/applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php
@@ -0,0 +1,33 @@
+<?php
+
+final class PhabricatorRepositoryIdentityPHIDType
+ extends PhabricatorPHIDType {
+
+ const TYPECONST = 'RIDT';
+
+ public function getTypeName() {
+ return pht('Repository Identity');
+ }
+
+ public function newObject() {
+ return new PhabricatorRepositoryIdentity();
+ }
+
+ public function getPHIDTypeApplicationClass() {
+ return 'PhabricatorDiffusionApplication';
+ }
+
+ protected function buildQueryForObjects(
+ PhabricatorObjectQuery $query,
+ array $phids) {
+
+ return id(new PhabricatorRepositoryIdentityQuery())
+ ->withPHIDs($phids);
+ }
+
+ public function loadHandles(
+ PhabricatorHandleQuery $query,
+ array $handles,
+ array $objects) {}
+
+}
diff --git a/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php b/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
@@ -0,0 +1,69 @@
+<?php
+
+final class PhabricatorRepositoryIdentityQuery
+ extends PhabricatorCursorPagedPolicyAwareQuery {
+
+ private $ids;
+ private $phids;
+ private $identityNames;
+
+ public function withIDs(array $ids) {
+ $this->ids = $ids;
+ return $this;
+ }
+
+ public function withPHIDs(array $phids) {
+ $this->phids = $phids;
+ return $this;
+ }
+
+ public function withIdentityNames(array $names) {
+ $this->identityNames = $names;
+ return $this;
+ }
+
+ public function newResultObject() {
+ return new PhabricatorRepositoryIdentity();
+ }
+
+ protected function loadPage() {
+ return $this->loadStandardPage($this->newResultObject());
+ }
+
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
+
+ if ($this->ids !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'id IN (%Ld)',
+ $this->ids);
+ }
+
+ if ($this->phids !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'phid IN (%Ls)',
+ $this->phids);
+ }
+
+ if ($this->identityNames !== null) {
+ $name_hashes = array();
+ foreach ($this->identityNames as $name) {
+ $name_hashes[] = PhabricatorHash::digestForIndex($name);
+ }
+
+ $where[] = qsprintf(
+ $conn,
+ 'identityNameHash IN (%Ls)',
+ $name_hashes);
+ }
+
+ return $where;
+ }
+
+ public function getQueryApplicationClass() {
+ return 'PhabricatorDiffusionApplication';
+ }
+
+}
diff --git a/src/applications/repository/storage/PhabricatorRepositoryIdentity.php b/src/applications/repository/storage/PhabricatorRepositoryIdentity.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/storage/PhabricatorRepositoryIdentity.php
@@ -0,0 +1,40 @@
+<?php
+
+final class PhabricatorRepositoryIdentity
+ extends PhabricatorRepositoryDAO {
+
+ protected $identityNameHash;
+ protected $identityNameRaw;
+ protected $identityNameEncoding;
+
+ protected $automaticGuessedUserPHID;
+ protected $manuallySetUserPHID;
+ protected $currentEffectiveUserPHID;
+
+ protected function getConfiguration() {
+ return array(
+ self::CONFIG_AUX_PHID => true,
+ self::CONFIG_BINARY => array(
+ 'identityNameRaw' => true,
+ ),
+ self::CONFIG_COLUMN_SCHEMA => array(
+ 'identityNameHash' => 'bytes12',
+ 'identityNameEncoding' => 'text16?',
+ 'automaticGuessedUserPHID' => 'phid?',
+ 'manuallySetUserPHID' => 'phid?',
+ 'currentEffectiveUserPHID' => 'phid?',
+ ),
+ self::CONFIG_KEY_SCHEMA => array(
+ 'key_identity' => array(
+ 'columns' => array('identityNameHash'),
+ 'unique' => true,
+ ),
+ ),
+ ) + parent::getConfiguration();
+ }
+
+ public function getPHIDType() {
+ return PhabricatorRepositoryIdentityPHIDType::TYPECONST;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Thu, May 16, 10:18 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6284382
Default Alt Text
D19423.id.diff (7 KB)

Event Timeline