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 @@ +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 @@ +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 @@ + 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; + } + +}