1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Remove direct calls to LowLevelCommitQuery

Summary: Ref T2783. This cleans up some more of the direct VCS access calls. If the repository is local, this boils down to an in-process call. If not, it uses Conduit to make an intracluster request.

Test Plan: Used `reparse.php --message <commit> --trace` to observe cluster request.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2783

Differential Revision: https://secure.phabricator.com/D11253
This commit is contained in:
epriestley 2015-02-10 15:58:51 -08:00
parent a7814b071c
commit bdd7a35b30
4 changed files with 44 additions and 21 deletions

View file

@ -3,6 +3,41 @@
abstract class PhabricatorRepositoryCommitMessageParserWorker
extends PhabricatorRepositoryCommitParserWorker {
abstract protected function parseCommitWithRef(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit,
DiffusionCommitRef $ref);
final protected function parseCommit(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$viewer = PhabricatorUser::getOmnipotentUser();
$refs_raw = DiffusionQuery::callConduitWithDiffusionRequest(
$viewer,
DiffusionRequest::newFromDictionary(
array(
'repository' => $repository,
'user' => $viewer,
)),
'diffusion.querycommits',
array(
'phids' => array($commit->getPHID()),
'bypassCache' => true,
'needMessages' => true,
));
if (empty($refs_raw['data'])) {
throw new Exception(
pht('Unable to retrieve details for commit "%s"!'));
}
$ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data']));
$this->parseCommitWithRef($repository, $commit, $ref);
}
final protected function updateCommitData(DiffusionCommitRef $ref) {
$commit = $this->commit;
$author = $ref->getAuthor();

View file

@ -3,14 +3,10 @@
final class PhabricatorRepositoryGitCommitMessageParserWorker
extends PhabricatorRepositoryCommitMessageParserWorker {
protected function parseCommit(
protected function parseCommitWithRef(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$ref = id(new DiffusionLowLevelCommitQuery())
->setRepository($repository)
->withIdentifier($commit->getCommitIdentifier())
->execute();
PhabricatorRepositoryCommit $commit,
DiffusionCommitRef $ref) {
$this->updateCommitData($ref);

View file

@ -3,14 +3,10 @@
final class PhabricatorRepositoryMercurialCommitMessageParserWorker
extends PhabricatorRepositoryCommitMessageParserWorker {
protected function parseCommit(
protected function parseCommitWithRef(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$ref = id(new DiffusionLowLevelCommitQuery())
->setRepository($repository)
->withIdentifier($commit->getCommitIdentifier())
->execute();
PhabricatorRepositoryCommit $commit,
DiffusionCommitRef $ref) {
$this->updateCommitData($ref);

View file

@ -3,14 +3,10 @@
final class PhabricatorRepositorySvnCommitMessageParserWorker
extends PhabricatorRepositoryCommitMessageParserWorker {
protected function parseCommit(
protected function parseCommitWithRef(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$ref = id(new DiffusionLowLevelCommitQuery())
->setRepository($repository)
->withIdentifier($commit->getCommitIdentifier())
->execute();
PhabricatorRepositoryCommit $commit,
DiffusionCommitRef $ref) {
$this->updateCommitData($ref);