Differential D20853 Diff 49714 src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
Show First 20 Lines • Show All 492 Lines • ▼ Show 20 Lines | final class PhabricatorRepositoryRefEngine | ||||
/** | /** | ||||
* Mark a list of commits as closeable, and queue workers for those commits | * Mark a list of commits as closeable, and queue workers for those commits | ||||
* which don't already have the flag. | * which don't already have the flag. | ||||
*/ | */ | ||||
private function setCloseFlagOnCommits(array $identifiers) { | private function setCloseFlagOnCommits(array $identifiers) { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$commit_table = new PhabricatorRepositoryCommit(); | $commit_table = new PhabricatorRepositoryCommit(); | ||||
$conn_w = $commit_table->establishConnection('w'); | $conn = $commit_table->establishConnection('w'); | ||||
$vcs = $repository->getVersionControlSystem(); | $vcs = $repository->getVersionControlSystem(); | ||||
switch ($vcs) { | switch ($vcs) { | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | ||||
$class = 'PhabricatorRepositoryGitCommitMessageParserWorker'; | $class = 'PhabricatorRepositoryGitCommitMessageParserWorker'; | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
$class = 'PhabricatorRepositorySvnCommitMessageParserWorker'; | $class = 'PhabricatorRepositorySvnCommitMessageParserWorker'; | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | ||||
$class = 'PhabricatorRepositoryMercurialCommitMessageParserWorker'; | $class = 'PhabricatorRepositoryMercurialCommitMessageParserWorker'; | ||||
break; | break; | ||||
default: | default: | ||||
throw new Exception(pht("Unknown repository type '%s'!", $vcs)); | throw new Exception(pht("Unknown repository type '%s'!", $vcs)); | ||||
} | } | ||||
$all_commits = queryfx_all( | $identifier_tokens = array(); | ||||
$conn_w, | foreach ($identifiers as $identifier) { | ||||
$identifier_tokens[] = qsprintf( | |||||
$conn, | |||||
'%s', | |||||
$identifier); | |||||
} | |||||
$all_commits = array(); | |||||
foreach (PhabricatorLiskDAO::chunkSQL($identifier_tokens) as $chunk) { | |||||
$rows = queryfx_all( | |||||
$conn, | |||||
'SELECT id, phid, commitIdentifier, importStatus FROM %T | 'SELECT id, phid, commitIdentifier, importStatus FROM %T | ||||
WHERE repositoryID = %d AND commitIdentifier IN (%Ls)', | WHERE repositoryID = %d AND commitIdentifier IN (%LQ)', | ||||
$commit_table->getTableName(), | $commit_table->getTableName(), | ||||
$repository->getID(), | $repository->getID(), | ||||
$identifiers); | $chunk); | ||||
foreach ($rows as $row) { | |||||
$all_commits[] = $row; | |||||
} | |||||
} | |||||
$closeable_flag = PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE; | $closeable_flag = PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE; | ||||
$all_commits = ipull($all_commits, null, 'commitIdentifier'); | $all_commits = ipull($all_commits, null, 'commitIdentifier'); | ||||
foreach ($identifiers as $identifier) { | foreach ($identifiers as $identifier) { | ||||
$row = idx($all_commits, $identifier); | $row = idx($all_commits, $identifier); | ||||
if (!$row) { | if (!$row) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Commit "%s" has not been discovered yet! Run discovery before '. | 'Commit "%s" has not been discovered yet! Run discovery before '. | ||||
'updating refs.', | 'updating refs.', | ||||
$identifier)); | $identifier)); | ||||
} | } | ||||
if (!($row['importStatus'] & $closeable_flag)) { | if (!($row['importStatus'] & $closeable_flag)) { | ||||
queryfx( | queryfx( | ||||
$conn_w, | $conn, | ||||
'UPDATE %T SET importStatus = (importStatus | %d) WHERE id = %d', | 'UPDATE %T SET importStatus = (importStatus | %d) WHERE id = %d', | ||||
$commit_table->getTableName(), | $commit_table->getTableName(), | ||||
$closeable_flag, | $closeable_flag, | ||||
$row['id']); | $row['id']); | ||||
$data = array( | $data = array( | ||||
'commitID' => $row['id'], | 'commitID' => $row['id'], | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |