mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
Modernize Diffusion commitparentsquery
Summary: Ref T4195. Ref T2783. We have an old-school implementation of this; move it into a LowLevel query and make callers all run through Conduit. I need the LowLevel query for hooks, to implement an "is merge commit" Herald rule. Test Plan: - Ran query via Conduit for SVN, Mercurial, Git. - Parsed a commit which closed a revision, attach/closed worked correctly. - Browsed Diffusion. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4195, T2783 Differential Revision: https://secure.phabricator.com/D7808
This commit is contained in:
parent
72c73d644b
commit
9c938701c3
11 changed files with 129 additions and 122 deletions
|
@ -481,7 +481,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php',
|
'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php',
|
||||||
'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php',
|
'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php',
|
||||||
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
|
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
|
||||||
'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionCommitParentsQuery.php',
|
|
||||||
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
|
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
|
||||||
'DiffusionCommitRef' => 'applications/diffusion/data/DiffusionCommitRef.php',
|
'DiffusionCommitRef' => 'applications/diffusion/data/DiffusionCommitRef.php',
|
||||||
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
|
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
|
||||||
|
@ -494,7 +493,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionFileContentQuery.php',
|
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionFileContentQuery.php',
|
||||||
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
|
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
|
||||||
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
|
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
|
||||||
'DiffusionGitCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionGitCommitParentsQuery.php',
|
|
||||||
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
||||||
'DiffusionGitRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionGitRawDiffQuery.php',
|
'DiffusionGitRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionGitRawDiffQuery.php',
|
||||||
'DiffusionGitRequest' => 'applications/diffusion/request/DiffusionGitRequest.php',
|
'DiffusionGitRequest' => 'applications/diffusion/request/DiffusionGitRequest.php',
|
||||||
|
@ -512,9 +510,9 @@ phutil_register_library_map(array(
|
||||||
'DiffusionLowLevelCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php',
|
'DiffusionLowLevelCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php',
|
||||||
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
|
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
|
||||||
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
|
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
|
||||||
|
'DiffusionLowLevelParentsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelParentsQuery.php',
|
||||||
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
|
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
|
||||||
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
|
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
|
||||||
'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php',
|
|
||||||
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php',
|
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php',
|
||||||
'DiffusionMercurialRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionMercurialRawDiffQuery.php',
|
'DiffusionMercurialRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionMercurialRawDiffQuery.php',
|
||||||
'DiffusionMercurialRequest' => 'applications/diffusion/request/DiffusionMercurialRequest.php',
|
'DiffusionMercurialRequest' => 'applications/diffusion/request/DiffusionMercurialRequest.php',
|
||||||
|
@ -572,7 +570,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
|
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
|
||||||
'DiffusionSubversionWireProtocol' => 'applications/diffusion/protocol/DiffusionSubversionWireProtocol.php',
|
'DiffusionSubversionWireProtocol' => 'applications/diffusion/protocol/DiffusionSubversionWireProtocol.php',
|
||||||
'DiffusionSubversionWireProtocolTestCase' => 'applications/diffusion/protocol/__tests__/DiffusionSubversionWireProtocolTestCase.php',
|
'DiffusionSubversionWireProtocolTestCase' => 'applications/diffusion/protocol/__tests__/DiffusionSubversionWireProtocolTestCase.php',
|
||||||
'DiffusionSvnCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionSvnCommitParentsQuery.php',
|
|
||||||
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php',
|
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php',
|
||||||
'DiffusionSvnRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionSvnRawDiffQuery.php',
|
'DiffusionSvnRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionSvnRawDiffQuery.php',
|
||||||
'DiffusionSvnRequest' => 'applications/diffusion/request/DiffusionSvnRequest.php',
|
'DiffusionSvnRequest' => 'applications/diffusion/request/DiffusionSvnRequest.php',
|
||||||
|
@ -2871,7 +2868,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitHash' => 'Phobject',
|
'DiffusionCommitHash' => 'Phobject',
|
||||||
'DiffusionCommitHookEngine' => 'Phobject',
|
'DiffusionCommitHookEngine' => 'Phobject',
|
||||||
'DiffusionCommitHookRejectException' => 'Exception',
|
'DiffusionCommitHookRejectException' => 'Exception',
|
||||||
'DiffusionCommitParentsQuery' => 'DiffusionQuery',
|
|
||||||
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'DiffusionCommitRef' => 'Phobject',
|
'DiffusionCommitRef' => 'Phobject',
|
||||||
'DiffusionCommitTagsController' => 'DiffusionController',
|
'DiffusionCommitTagsController' => 'DiffusionController',
|
||||||
|
@ -2882,7 +2878,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionExternalController' => 'DiffusionController',
|
'DiffusionExternalController' => 'DiffusionController',
|
||||||
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
||||||
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
|
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
|
||||||
'DiffusionGitCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
|
||||||
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionGitRawDiffQuery' => 'DiffusionRawDiffQuery',
|
'DiffusionGitRawDiffQuery' => 'DiffusionRawDiffQuery',
|
||||||
'DiffusionGitRequest' => 'DiffusionRequest',
|
'DiffusionGitRequest' => 'DiffusionRequest',
|
||||||
|
@ -2899,9 +2894,9 @@ phutil_register_library_map(array(
|
||||||
'DiffusionLowLevelCommitQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelCommitQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
|
||||||
|
'DiffusionLowLevelParentsQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelQuery' => 'Phobject',
|
'DiffusionLowLevelQuery' => 'Phobject',
|
||||||
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
|
||||||
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionMercurialRawDiffQuery' => 'DiffusionRawDiffQuery',
|
'DiffusionMercurialRawDiffQuery' => 'DiffusionRawDiffQuery',
|
||||||
'DiffusionMercurialRequest' => 'DiffusionRequest',
|
'DiffusionMercurialRequest' => 'DiffusionRequest',
|
||||||
|
@ -2957,7 +2952,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSetupException' => 'AphrontUsageException',
|
'DiffusionSetupException' => 'AphrontUsageException',
|
||||||
'DiffusionSubversionWireProtocol' => 'Phobject',
|
'DiffusionSubversionWireProtocol' => 'Phobject',
|
||||||
'DiffusionSubversionWireProtocolTestCase' => 'PhabricatorTestCase',
|
'DiffusionSubversionWireProtocolTestCase' => 'PhabricatorTestCase',
|
||||||
'DiffusionSvnCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
|
||||||
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionSvnRawDiffQuery' => 'DiffusionRawDiffQuery',
|
'DiffusionSvnRawDiffQuery' => 'DiffusionRawDiffQuery',
|
||||||
'DiffusionSvnRequest' => 'DiffusionRequest',
|
'DiffusionSvnRequest' => 'DiffusionRequest',
|
||||||
|
|
|
@ -7,12 +7,12 @@ final class ConduitAPI_diffusion_commitparentsquery_Method
|
||||||
extends ConduitAPI_diffusion_abstractquery_Method {
|
extends ConduitAPI_diffusion_abstractquery_Method {
|
||||||
|
|
||||||
public function getMethodDescription() {
|
public function getMethodDescription() {
|
||||||
return
|
return pht(
|
||||||
'Commit parent(s) information for a commit in a repository.';
|
"Get the commit identifiers for a commit's parent or parents.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function defineReturnType() {
|
public function defineReturnType() {
|
||||||
return 'array';
|
return 'list<string>';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function defineCustomParamTypes() {
|
protected function defineCustomParamTypes() {
|
||||||
|
@ -22,10 +22,12 @@ final class ConduitAPI_diffusion_commitparentsquery_Method
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getResult(ConduitAPIRequest $request) {
|
protected function getResult(ConduitAPIRequest $request) {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$repository = $this->getRepository($request);
|
||||||
|
|
||||||
$query = DiffusionCommitParentsQuery::newFromDiffusionRequest($drequest);
|
return id(new DiffusionLowLevelParentsQuery())
|
||||||
$parents = $query->loadParents();
|
->setRepository($repository)
|
||||||
return $parents;
|
->withIdentifier($request->getValue('commit'))
|
||||||
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,17 +857,16 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
|
||||||
// NOTE: We need to get the grandparent so we can capture filename changes
|
// NOTE: We need to get the grandparent so we can capture filename changes
|
||||||
// in the parent.
|
// in the parent.
|
||||||
|
|
||||||
$parent = $this->loadParentRevisionOf($before);
|
$parent = $this->loadParentCommitOf($before);
|
||||||
$old_filename = null;
|
$old_filename = null;
|
||||||
$was_created = false;
|
$was_created = false;
|
||||||
if ($parent) {
|
if ($parent) {
|
||||||
$grandparent = $this->loadParentRevisionOf(
|
$grandparent = $this->loadParentCommitOf($parent);
|
||||||
$parent->getCommitIdentifier());
|
|
||||||
|
|
||||||
if ($grandparent) {
|
if ($grandparent) {
|
||||||
$rename_query = new DiffusionRenameHistoryQuery();
|
$rename_query = new DiffusionRenameHistoryQuery();
|
||||||
$rename_query->setRequest($drequest);
|
$rename_query->setRequest($drequest);
|
||||||
$rename_query->setOldCommit($grandparent->getCommitIdentifier());
|
$rename_query->setOldCommit($grandparent);
|
||||||
$rename_query->setViewer($request->getUser());
|
$rename_query->setViewer($request->getUser());
|
||||||
$old_filename = $rename_query->loadOldFilename();
|
$old_filename = $rename_query->loadOldFilename();
|
||||||
$was_created = $rename_query->getWasCreated();
|
$was_created = $rename_query->getWasCreated();
|
||||||
|
@ -955,7 +954,7 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
|
||||||
return $line;
|
return $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadParentRevisionOf($commit) {
|
private function loadParentCommitOf($commit) {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
@ -963,7 +962,7 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
|
||||||
array(
|
array(
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'repository' => $drequest->getRepository(),
|
'repository' => $drequest->getRepository(),
|
||||||
'commit' => $commit,
|
'commit' => $commit,
|
||||||
));
|
));
|
||||||
|
|
||||||
$parents = DiffusionQuery::callConduitWithDiffusionRequest(
|
$parents = DiffusionQuery::callConduitWithDiffusionRequest(
|
||||||
|
@ -971,7 +970,8 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
|
||||||
$before_req,
|
$before_req,
|
||||||
'diffusion.commitparentsquery',
|
'diffusion.commitparentsquery',
|
||||||
array(
|
array(
|
||||||
'commit' => $commit));
|
'commit' => $commit,
|
||||||
|
));
|
||||||
|
|
||||||
return head($parents);
|
return head($parents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,14 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
'diffusion.commitparentsquery',
|
'diffusion.commitparentsquery',
|
||||||
array('commit' => $drequest->getCommit()));
|
array('commit' => $drequest->getCommit()));
|
||||||
|
|
||||||
|
if ($parents) {
|
||||||
|
$parents = id(new DiffusionCommitQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->withRepository($repository)
|
||||||
|
->withIdentifiers($parents)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
$headsup_view = id(new PHUIHeaderView())
|
$headsup_view = id(new PHUIHeaderView())
|
||||||
->setHeader(nonempty($commit->getSummary(), pht('Commit Detail')));
|
->setHeader(nonempty($commit->getSummary(), pht('Commit Detail')));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionLowLevelParentsQuery
|
||||||
|
extends DiffusionLowLevelQuery {
|
||||||
|
|
||||||
|
private $identifier;
|
||||||
|
|
||||||
|
public function withIdentifier($identifier) {
|
||||||
|
$this->identifier = $identifier;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function executeQuery() {
|
||||||
|
if (!strlen($this->identifier)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht('You must provide an identifier with withIdentifier()!'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $this->getRepository()->getVersionControlSystem();
|
||||||
|
switch ($type) {
|
||||||
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||||
|
$result = $this->loadGitParents();
|
||||||
|
break;
|
||||||
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||||
|
$result = $this->loadMercurialParents();
|
||||||
|
break;
|
||||||
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||||
|
$result = $this->loadSubversionParents();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception(pht('Unsupported repository type "%s"!', $type));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadGitParents() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
|
||||||
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
|
'log -n 1 --format=%s %s',
|
||||||
|
'%P',
|
||||||
|
$this->identifier);
|
||||||
|
|
||||||
|
return preg_split('/\s+/', trim($stdout));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadMercurialParents() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
|
||||||
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
|
'log --debug --limit 1 --template={parents} --rev %s',
|
||||||
|
$this->identifier);
|
||||||
|
$stdout = PhabricatorRepository::filterMercurialDebugOutput($stdout);
|
||||||
|
|
||||||
|
$hashes = preg_split('/\s+/', trim($stdout));
|
||||||
|
foreach ($hashes as $key => $value) {
|
||||||
|
// Mercurial parents look like "23:ad9f769d6f786fad9f76d9a" -- we want
|
||||||
|
// to strip out the local rev part.
|
||||||
|
list($local, $global) = explode(':', $value);
|
||||||
|
$hashes[$key] = $global;
|
||||||
|
|
||||||
|
// With --debug we get 40-character hashes but also get the "000000..."
|
||||||
|
// hash for missing parents; ignore it.
|
||||||
|
if (preg_match('/^0+$/', $global)) {
|
||||||
|
unset($hashes[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hashes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadSubversionParents() {
|
||||||
|
$n = (int)$this->identifier;
|
||||||
|
if ($n > 1) {
|
||||||
|
$ids = array($n - 1);
|
||||||
|
} else {
|
||||||
|
$ids = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class DiffusionCommitParentsQuery extends DiffusionQuery {
|
|
||||||
|
|
||||||
final public static function newFromDiffusionRequest(
|
|
||||||
DiffusionRequest $request) {
|
|
||||||
return self::newQueryObject(__CLASS__, $request);
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function loadParents() {
|
|
||||||
return $this->executeQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DiffusionGitCommitParentsQuery
|
|
||||||
extends DiffusionCommitParentsQuery {
|
|
||||||
|
|
||||||
protected function executeQuery() {
|
|
||||||
$drequest = $this->getRequest();
|
|
||||||
$repository = $drequest->getRepository();
|
|
||||||
|
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
|
||||||
'log -n 1 --format=%s %s',
|
|
||||||
'%P',
|
|
||||||
$drequest->getStableCommitName());
|
|
||||||
|
|
||||||
$hashes = preg_split('/\s+/', trim($stdout));
|
|
||||||
|
|
||||||
return self::loadCommitsByIdentifiers($hashes, $drequest);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DiffusionMercurialCommitParentsQuery
|
|
||||||
extends DiffusionCommitParentsQuery {
|
|
||||||
|
|
||||||
protected function executeQuery() {
|
|
||||||
$drequest = $this->getRequest();
|
|
||||||
$repository = $drequest->getRepository();
|
|
||||||
|
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
|
||||||
'log --debug --limit 1 --template={parents} --rev %s',
|
|
||||||
$drequest->getStableCommitName());
|
|
||||||
$stdout = PhabricatorRepository::filterMercurialDebugOutput($stdout);
|
|
||||||
|
|
||||||
$hashes = preg_split('/\s+/', trim($stdout));
|
|
||||||
foreach ($hashes as $key => $value) {
|
|
||||||
// Mercurial parents look like "23:ad9f769d6f786fad9f76d9a" -- we want
|
|
||||||
// to strip out the local rev part.
|
|
||||||
list($local, $global) = explode(':', $value);
|
|
||||||
$hashes[$key] = $global;
|
|
||||||
|
|
||||||
// With --debug we get 40-character hashes but also get the "000000..."
|
|
||||||
// hash for missing parents; ignore it.
|
|
||||||
if (preg_match('/^0+$/', $global)) {
|
|
||||||
unset($hashes[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::loadCommitsByIdentifiers($hashes, $drequest);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DiffusionSvnCommitParentsQuery
|
|
||||||
extends DiffusionCommitParentsQuery {
|
|
||||||
|
|
||||||
protected function executeQuery() {
|
|
||||||
$drequest = $this->getRequest();
|
|
||||||
$repository = $drequest->getRepository();
|
|
||||||
|
|
||||||
// TODO: With merge properties in recent versions of SVN, can we do
|
|
||||||
// a better job of this?
|
|
||||||
|
|
||||||
$n = $drequest->getStableCommitName();
|
|
||||||
if ($n > 1) {
|
|
||||||
$ids = array($n - 1);
|
|
||||||
} else {
|
|
||||||
$ids = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::loadCommitsByIdentifiers($ids, $drequest);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -82,15 +82,10 @@ final class WaitForPreviousBuildStepImplementation
|
||||||
$call->setUser(PhabricatorUser::getOmnipotentUser());
|
$call->setUser(PhabricatorUser::getOmnipotentUser());
|
||||||
$parents = $call->execute();
|
$parents = $call->execute();
|
||||||
|
|
||||||
$hashes = array();
|
|
||||||
foreach ($parents as $parent => $obj) {
|
|
||||||
$hashes[] = $parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
$parents = id(new DiffusionCommitQuery())
|
$parents = id(new DiffusionCommitQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||||
->withRepository($commit->getRepository())
|
->withRepository($commit->getRepository())
|
||||||
->withIdentifiers($hashes)
|
->withIdentifiers($parents)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$blockers = array();
|
$blockers = array();
|
||||||
|
|
|
@ -205,15 +205,20 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
DifferentialRevision $revision,
|
DifferentialRevision $revision,
|
||||||
$actor_phid) {
|
$actor_phid) {
|
||||||
|
|
||||||
|
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||||
|
|
||||||
$drequest = DiffusionRequest::newFromDictionary(array(
|
$drequest = DiffusionRequest::newFromDictionary(array(
|
||||||
'user' => PhabricatorUser::getOmnipotentUser(),
|
'user' => $viewer,
|
||||||
'initFromConduit' => false,
|
|
||||||
'repository' => $this->repository,
|
'repository' => $this->repository,
|
||||||
'commit' => $this->commit->getCommitIdentifier(),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$raw_diff = DiffusionRawDiffQuery::newFromDiffusionRequest($drequest)
|
$raw_diff = DiffusionQuery::callConduitWithDiffusionRequest(
|
||||||
->loadRawDiff();
|
$viewer,
|
||||||
|
$drequest,
|
||||||
|
'diffusion.rawdiffquery',
|
||||||
|
array(
|
||||||
|
'commit' => $this->commit->getCommitIdentifier(),
|
||||||
|
));
|
||||||
|
|
||||||
// TODO: Support adds, deletes and moves under SVN.
|
// TODO: Support adds, deletes and moves under SVN.
|
||||||
if (strlen($raw_diff)) {
|
if (strlen($raw_diff)) {
|
||||||
|
@ -248,10 +253,15 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
$diff->setArcanistProjectPHID($arcanist_project->getPHID());
|
$diff->setArcanistProjectPHID($arcanist_project->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
$parents = DiffusionCommitParentsQuery::newFromDiffusionRequest($drequest)
|
$parents = DiffusionQuery::callConduitWithDiffusionRequest(
|
||||||
->loadParents();
|
$viewer,
|
||||||
|
$drequest,
|
||||||
|
'diffusion.commitparentsquery',
|
||||||
|
array(
|
||||||
|
'commit' => $this->commit->getCommitIdentifier(),
|
||||||
|
));
|
||||||
if ($parents) {
|
if ($parents) {
|
||||||
$diff->setSourceControlBaseRevision(head_key($parents));
|
$diff->setSourceControlBaseRevision(head($parents));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Attach binary files.
|
// TODO: Attach binary files.
|
||||||
|
|
Loading…
Reference in a new issue