mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
Remove "RefQuery" and all "HardpointLoader" code
Summary: Ref T11968. "RefQuery" is now "HardpointEngine". "HardpointLoader" is now "HardpointQuery". Test Plan: Grepped for affected symbols. Maniphest Tasks: T11968 Differential Revision: https://secure.phabricator.com/D21083
This commit is contained in:
parent
dc42f51cf7
commit
fff2fc8bc9
19 changed files with 2 additions and 1179 deletions
|
@ -55,19 +55,13 @@ phutil_register_library_map(array(
|
|||
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php',
|
||||
'ArcanistBranchRef' => 'ref/ArcanistBranchRef.php',
|
||||
'ArcanistBranchWorkflow' => 'workflow/ArcanistBranchWorkflow.php',
|
||||
'ArcanistBrowseCommitHardpointLoader' => 'browse/loader/ArcanistBrowseCommitHardpointLoader.php',
|
||||
'ArcanistBrowseCommitHardpointQuery' => 'browse/query/ArcanistBrowseCommitHardpointQuery.php',
|
||||
'ArcanistBrowseCommitURIHardpointLoader' => 'browse/loader/ArcanistBrowseCommitURIHardpointLoader.php',
|
||||
'ArcanistBrowseCommitURIHardpointQuery' => 'browse/query/ArcanistBrowseCommitURIHardpointQuery.php',
|
||||
'ArcanistBrowseObjectNameURIHardpointLoader' => 'browse/loader/ArcanistBrowseObjectNameURIHardpointLoader.php',
|
||||
'ArcanistBrowseObjectNameURIHardpointQuery' => 'browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php',
|
||||
'ArcanistBrowsePathURIHardpointLoader' => 'browse/loader/ArcanistBrowsePathURIHardpointLoader.php',
|
||||
'ArcanistBrowsePathURIHardpointQuery' => 'browse/query/ArcanistBrowsePathURIHardpointQuery.php',
|
||||
'ArcanistBrowseRef' => 'browse/ref/ArcanistBrowseRef.php',
|
||||
'ArcanistBrowseRefInspector' => 'inspector/ArcanistBrowseRefInspector.php',
|
||||
'ArcanistBrowseRevisionURIHardpointLoader' => 'browse/loader/ArcanistBrowseRevisionURIHardpointLoader.php',
|
||||
'ArcanistBrowseRevisionURIHardpointQuery' => 'browse/query/ArcanistBrowseRevisionURIHardpointQuery.php',
|
||||
'ArcanistBrowseURIHardpointLoader' => 'browse/loader/ArcanistBrowseURIHardpointLoader.php',
|
||||
'ArcanistBrowseURIHardpointQuery' => 'browse/query/ArcanistBrowseURIHardpointQuery.php',
|
||||
'ArcanistBrowseURIRef' => 'browse/ref/ArcanistBrowseURIRef.php',
|
||||
'ArcanistBrowseWorkflow' => 'browse/workflow/ArcanistBrowseWorkflow.php',
|
||||
|
@ -110,7 +104,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistCommentStyleXHPASTLinterRuleTestCase.php',
|
||||
'ArcanistCommitRef' => 'ref/ArcanistCommitRef.php',
|
||||
'ArcanistCommitRefInspector' => 'inspector/ArcanistCommitRefInspector.php',
|
||||
'ArcanistCommitUpstreamHardpointLoader' => 'loader/ArcanistCommitUpstreamHardpointLoader.php',
|
||||
'ArcanistCommitUpstreamHardpointQuery' => 'query/ArcanistCommitUpstreamHardpointQuery.php',
|
||||
'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php',
|
||||
'ArcanistCompilerLintRenderer' => 'lint/renderer/ArcanistCompilerLintRenderer.php',
|
||||
|
@ -211,11 +204,8 @@ phutil_register_library_map(array(
|
|||
'ArcanistGeneratedLinterTestCase' => 'lint/linter/__tests__/ArcanistGeneratedLinterTestCase.php',
|
||||
'ArcanistGetConfigWorkflow' => 'workflow/ArcanistGetConfigWorkflow.php',
|
||||
'ArcanistGitAPI' => 'repository/api/ArcanistGitAPI.php',
|
||||
'ArcanistGitCommitMessageHardpointLoader' => 'loader/ArcanistGitCommitMessageHardpointLoader.php',
|
||||
'ArcanistGitCommitMessageHardpointQuery' => 'query/ArcanistGitCommitMessageHardpointQuery.php',
|
||||
'ArcanistGitHardpointLoader' => 'loader/ArcanistGitHardpointLoader.php',
|
||||
'ArcanistGitLandEngine' => 'land/ArcanistGitLandEngine.php',
|
||||
'ArcanistGitRevisionHardpointLoader' => 'loader/ArcanistGitRevisionHardpointLoader.php',
|
||||
'ArcanistGitUpstreamPath' => 'repository/api/ArcanistGitUpstreamPath.php',
|
||||
'ArcanistGitWorkingCopy' => 'workingcopy/ArcanistGitWorkingCopy.php',
|
||||
'ArcanistGitWorkingCopyRevisionHardpointQuery' => 'query/ArcanistGitWorkingCopyRevisionHardpointQuery.php',
|
||||
|
@ -231,7 +221,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistHardpointEngine' => 'hardpoint/ArcanistHardpointEngine.php',
|
||||
'ArcanistHardpointFutureList' => 'hardpoint/ArcanistHardpointFutureList.php',
|
||||
'ArcanistHardpointList' => 'hardpoint/ArcanistHardpointList.php',
|
||||
'ArcanistHardpointLoader' => 'loader/ArcanistHardpointLoader.php',
|
||||
'ArcanistHardpointObject' => 'hardpoint/ArcanistHardpointObject.php',
|
||||
'ArcanistHardpointQuery' => 'hardpoint/ArcanistHardpointQuery.php',
|
||||
'ArcanistHardpointRequest' => 'hardpoint/ArcanistHardpointRequest.php',
|
||||
|
@ -317,15 +306,11 @@ phutil_register_library_map(array(
|
|||
'ArcanistLowercaseFunctionsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistLowercaseFunctionsXHPASTLinterRule.php',
|
||||
'ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase.php',
|
||||
'ArcanistMercurialAPI' => 'repository/api/ArcanistMercurialAPI.php',
|
||||
'ArcanistMercurialBranchCommitHardpointLoader' => 'loader/ArcanistMercurialBranchCommitHardpointLoader.php',
|
||||
'ArcanistMercurialHardpointLoader' => 'loader/ArcanistMercurialHardpointLoader.php',
|
||||
'ArcanistMercurialParser' => 'repository/parser/ArcanistMercurialParser.php',
|
||||
'ArcanistMercurialParserTestCase' => 'repository/parser/__tests__/ArcanistMercurialParserTestCase.php',
|
||||
'ArcanistMercurialWorkingCopy' => 'workingcopy/ArcanistMercurialWorkingCopy.php',
|
||||
'ArcanistMercurialWorkingCopyCommitHardpointLoader' => 'loader/ArcanistMercurialWorkingCopyCommitHardpointLoader.php',
|
||||
'ArcanistMergeConflictLinter' => 'lint/linter/ArcanistMergeConflictLinter.php',
|
||||
'ArcanistMergeConflictLinterTestCase' => 'lint/linter/__tests__/ArcanistMergeConflictLinterTestCase.php',
|
||||
'ArcanistMessageRevisionHardpointLoader' => 'loader/ArcanistMessageRevisionHardpointLoader.php',
|
||||
'ArcanistMessageRevisionHardpointQuery' => 'query/ArcanistMessageRevisionHardpointQuery.php',
|
||||
'ArcanistMissingArgumentTerminatorException' => 'exception/ArcanistMissingArgumentTerminatorException.php',
|
||||
'ArcanistMissingLinterException' => 'lint/linter/exception/ArcanistMissingLinterException.php',
|
||||
|
@ -397,7 +382,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase.php',
|
||||
'ArcanistRef' => 'ref/ArcanistRef.php',
|
||||
'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php',
|
||||
'ArcanistRefQuery' => 'ref/ArcanistRefQuery.php',
|
||||
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
|
||||
'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php',
|
||||
'ArcanistRepositoryAPIStateTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php',
|
||||
|
@ -1031,19 +1015,13 @@ phutil_register_library_map(array(
|
|||
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||
'ArcanistBranchRef' => 'ArcanistRef',
|
||||
'ArcanistBranchWorkflow' => 'ArcanistFeatureWorkflow',
|
||||
'ArcanistBrowseCommitHardpointLoader' => 'ArcanistHardpointLoader',
|
||||
'ArcanistBrowseCommitHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
|
||||
'ArcanistBrowseCommitURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
|
||||
'ArcanistBrowseCommitURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery',
|
||||
'ArcanistBrowseObjectNameURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
|
||||
'ArcanistBrowseObjectNameURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery',
|
||||
'ArcanistBrowsePathURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
|
||||
'ArcanistBrowsePathURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery',
|
||||
'ArcanistBrowseRef' => 'ArcanistRef',
|
||||
'ArcanistBrowseRefInspector' => 'ArcanistRefInspector',
|
||||
'ArcanistBrowseRevisionURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
|
||||
'ArcanistBrowseRevisionURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery',
|
||||
'ArcanistBrowseURIHardpointLoader' => 'ArcanistHardpointLoader',
|
||||
'ArcanistBrowseURIHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
|
||||
'ArcanistBrowseURIRef' => 'ArcanistRef',
|
||||
'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow',
|
||||
|
@ -1086,7 +1064,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||
'ArcanistCommitRef' => 'ArcanistRef',
|
||||
'ArcanistCommitRefInspector' => 'ArcanistRefInspector',
|
||||
'ArcanistCommitUpstreamHardpointLoader' => 'ArcanistHardpointLoader',
|
||||
'ArcanistCommitUpstreamHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
|
||||
'ArcanistCommitWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistCompilerLintRenderer' => 'ArcanistLintRenderer',
|
||||
|
@ -1187,11 +1164,8 @@ phutil_register_library_map(array(
|
|||
'ArcanistGeneratedLinterTestCase' => 'ArcanistLinterTestCase',
|
||||
'ArcanistGetConfigWorkflow' => 'ArcanistWorkflow',
|
||||
'ArcanistGitAPI' => 'ArcanistRepositoryAPI',
|
||||
'ArcanistGitCommitMessageHardpointLoader' => 'ArcanistGitHardpointLoader',
|
||||
'ArcanistGitCommitMessageHardpointQuery' => 'ArcanistWorkflowGitHardpointQuery',
|
||||
'ArcanistGitHardpointLoader' => 'ArcanistHardpointLoader',
|
||||
'ArcanistGitLandEngine' => 'ArcanistLandEngine',
|
||||
'ArcanistGitRevisionHardpointLoader' => 'ArcanistGitHardpointLoader',
|
||||
'ArcanistGitUpstreamPath' => 'Phobject',
|
||||
'ArcanistGitWorkingCopy' => 'ArcanistWorkingCopy',
|
||||
'ArcanistGitWorkingCopyRevisionHardpointQuery' => 'ArcanistWorkflowGitHardpointQuery',
|
||||
|
@ -1207,7 +1181,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistHardpointEngine' => 'Phobject',
|
||||
'ArcanistHardpointFutureList' => 'Phobject',
|
||||
'ArcanistHardpointList' => 'Phobject',
|
||||
'ArcanistHardpointLoader' => 'Phobject',
|
||||
'ArcanistHardpointObject' => 'Phobject',
|
||||
'ArcanistHardpointQuery' => 'Phobject',
|
||||
'ArcanistHardpointRequest' => 'Phobject',
|
||||
|
@ -1293,15 +1266,11 @@ phutil_register_library_map(array(
|
|||
'ArcanistLowercaseFunctionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
|
||||
'ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||
'ArcanistMercurialAPI' => 'ArcanistRepositoryAPI',
|
||||
'ArcanistMercurialBranchCommitHardpointLoader' => 'ArcanistMercurialHardpointLoader',
|
||||
'ArcanistMercurialHardpointLoader' => 'ArcanistHardpointLoader',
|
||||
'ArcanistMercurialParser' => 'Phobject',
|
||||
'ArcanistMercurialParserTestCase' => 'PhutilTestCase',
|
||||
'ArcanistMercurialWorkingCopy' => 'ArcanistWorkingCopy',
|
||||
'ArcanistMercurialWorkingCopyCommitHardpointLoader' => 'ArcanistMercurialHardpointLoader',
|
||||
'ArcanistMergeConflictLinter' => 'ArcanistLinter',
|
||||
'ArcanistMergeConflictLinterTestCase' => 'ArcanistLinterTestCase',
|
||||
'ArcanistMessageRevisionHardpointLoader' => 'ArcanistHardpointLoader',
|
||||
'ArcanistMessageRevisionHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
|
||||
'ArcanistMissingArgumentTerminatorException' => 'Exception',
|
||||
'ArcanistMissingLinterException' => 'Exception',
|
||||
|
@ -1373,7 +1342,6 @@ phutil_register_library_map(array(
|
|||
'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
|
||||
'ArcanistRef' => 'ArcanistHardpointObject',
|
||||
'ArcanistRefInspector' => 'Phobject',
|
||||
'ArcanistRefQuery' => 'Phobject',
|
||||
'ArcanistRepositoryAPI' => 'Phobject',
|
||||
'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase',
|
||||
'ArcanistRepositoryAPIStateTestCase' => 'PhutilTestCase',
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistBrowseCommitHardpointLoader
|
||||
extends ArcanistHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'browse.ref.commit';
|
||||
|
||||
public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistBrowseRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'commitRefs');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$query = $this->getQuery();
|
||||
|
||||
$api = $query->getRepositoryAPI();
|
||||
if (!$api) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
return array();
|
||||
}
|
||||
$repository_phid = $repository_ref->getPHID();
|
||||
|
||||
$commit_map = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
$token = $ref->getToken();
|
||||
|
||||
if ($token === '.') {
|
||||
// Git resolves "." like HEAD, but we want to treat it as "browse the
|
||||
// current directory" instead in all cases.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Always resolve the empty token; top-level loaders filter out
|
||||
// irrelevant tokens before this stage.
|
||||
if ($token === null) {
|
||||
$token = $api->getHeadCommit();
|
||||
}
|
||||
|
||||
// TODO: We should pull a full commit ref out of the API as soon as it
|
||||
// is able to provide them. In particular, we currently miss Git tree
|
||||
// hashes which reduces the accuracy of lookups.
|
||||
|
||||
try {
|
||||
$commit = $api->getCanonicalRevisionName($token);
|
||||
if ($commit) {
|
||||
$commit_map[$commit][] = $key;
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
// Ignore anything we can't resolve.
|
||||
}
|
||||
}
|
||||
|
||||
if (!$commit_map) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$results = array();
|
||||
foreach ($commit_map as $commit_identifier => $ref_keys) {
|
||||
foreach ($ref_keys as $key) {
|
||||
$commit_ref = id(new ArcanistCommitRef())
|
||||
->setCommitHash($commit_identifier);
|
||||
$results[$key][] = $commit_ref;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistBrowseCommitURIHardpointLoader
|
||||
extends ArcanistBrowseURIHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'browse.uri.commit';
|
||||
const BROWSETYPE = 'commit';
|
||||
|
||||
public function willLoadBrowseURIRefs(array $refs) {
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
|
||||
if (!$refs) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = $this->getQuery();
|
||||
|
||||
$working_ref = $query->getWorkingCopyRef();
|
||||
if (!$working_ref) {
|
||||
// If we aren't in a working copy, don't warn about this.
|
||||
return;
|
||||
}
|
||||
|
||||
$repository_ref = $this->getQuery()->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
echo pht(
|
||||
'NO REPOSITORY: Unable to determine which repository this working '.
|
||||
'copy belongs to, so arguments can not be resolved as commits. Use '.
|
||||
'"%s" to understand how repositories are resolved.',
|
||||
'arc which');
|
||||
echo "\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$query = $this->getQuery();
|
||||
|
||||
$api = $query->getRepositoryAPI();
|
||||
if (!$api) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
if (!$refs) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$this->newQuery($refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'commitRefs',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$commit_refs = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
foreach ($ref->getCommitRefs() as $commit_ref) {
|
||||
$commit_refs[] = $commit_ref;
|
||||
}
|
||||
}
|
||||
|
||||
$this->newQuery($commit_refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'upstream',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$results = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
$commit_refs = $ref->getCommitRefs();
|
||||
foreach ($commit_refs as $commit_ref) {
|
||||
$uri = $commit_ref->getURI();
|
||||
if ($uri !== null) {
|
||||
$results[$key][] = id(new ArcanistBrowseURIRef())
|
||||
->setURI($uri)
|
||||
->setType(self::BROWSETYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistBrowseObjectNameURIHardpointLoader
|
||||
extends ArcanistBrowseURIHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'browse.uri.name';
|
||||
const BROWSETYPE = 'object';
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
|
||||
$name_map = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
$token = $ref->getToken();
|
||||
if (!strlen($token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name_map[$key] = $token;
|
||||
}
|
||||
|
||||
if (!$name_map) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$objects = $this->resolveCall(
|
||||
'phid.lookup',
|
||||
array(
|
||||
'names' => $name_map,
|
||||
));
|
||||
|
||||
$result = array();
|
||||
|
||||
$reverse_map = array_flip($name_map);
|
||||
foreach ($objects as $name => $object) {
|
||||
$key = idx($reverse_map, $name);
|
||||
if ($key === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$uri = idx($object, 'uri');
|
||||
if (!strlen($uri)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$key][] = id(new ArcanistBrowseURIRef())
|
||||
->setURI($object['uri'])
|
||||
->setType('object');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistBrowsePathURIHardpointLoader
|
||||
extends ArcanistBrowseURIHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'browse.uri.path';
|
||||
const BROWSETYPE = 'path';
|
||||
|
||||
public function willLoadBrowseURIRefs(array $refs) {
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
if (!$refs) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = $this->getQuery();
|
||||
|
||||
$working_ref = $query->getWorkingCopyRef();
|
||||
if (!$working_ref) {
|
||||
echo pht(
|
||||
'NO WORKING COPY: The current directory is not a repository '.
|
||||
'working copy, so arguments can not be resolved as paths. Run '.
|
||||
'this command inside a working copy to resolve paths.');
|
||||
echo "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
echo pht(
|
||||
'NO REPOSITORY: Unable to determine which repository this working '.
|
||||
'copy belongs to, so arguments can not be resolved as paths. Use '.
|
||||
'"%s" to understand how repositories are resolved.',
|
||||
'arc which');
|
||||
echo "\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function didFailToLoadBrowseURIRefs(array $refs) {
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
if (!$refs) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = $this->getQuery();
|
||||
|
||||
$working_ref = $query->getWorkingCopyRef();
|
||||
if (!$working_ref) {
|
||||
return;
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo pht(
|
||||
'Use "--types path" to force arguments to be interpreted as paths.');
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$query = $this->getQuery();
|
||||
|
||||
$working_ref = $query->getWorkingCopyRef();
|
||||
if (!$working_ref) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
$project_root = $working_ref->getRootDirectory();
|
||||
|
||||
$results = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
$is_path = $ref->hasType(self::BROWSETYPE);
|
||||
|
||||
$path = $ref->getToken();
|
||||
if ($path === null) {
|
||||
// If we're explicitly resolving no arguments as a path, treat it
|
||||
// as the current working directory.
|
||||
if ($is_path) {
|
||||
$path = '.';
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$lines = null;
|
||||
$parts = explode(':', $path);
|
||||
if (count($parts) > 1) {
|
||||
$lines = array_pop($parts);
|
||||
}
|
||||
$path = implode(':', $parts);
|
||||
|
||||
$full_path = Filesystem::resolvePath($path);
|
||||
|
||||
if (!Filesystem::pathExists($full_path)) {
|
||||
if (!$is_path) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($full_path == $project_root) {
|
||||
$path = '';
|
||||
} else {
|
||||
$path = Filesystem::readablePath($full_path, $project_root);
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'path' => $path,
|
||||
'lines' => $lines,
|
||||
'branch' => $ref->getBranch(),
|
||||
);
|
||||
|
||||
$uri = $repository_ref->newBrowseURI($params);
|
||||
|
||||
$results[$key][] = id(new ArcanistBrowseURIRef())
|
||||
->setURI($uri)
|
||||
->setType(self::BROWSETYPE);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistBrowseRevisionURIHardpointLoader
|
||||
extends ArcanistBrowseURIHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'browse.uri.revision';
|
||||
const BROWSETYPE = 'revision';
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$query = $this->getQuery();
|
||||
|
||||
$working_ref = $query->getWorkingCopyRef();
|
||||
if (!$working_ref) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$refs = $this->getRefsWithSupportedTypes($refs);
|
||||
if (!$refs) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$this->newQuery($refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'commitRefs',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$states = array();
|
||||
$map = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
foreach ($ref->getCommitRefs() as $commit_ref) {
|
||||
$hash = $commit_ref->getCommitHash();
|
||||
$states[$hash] = id(clone $working_ref)
|
||||
->setCommitRef($commit_ref);
|
||||
$map[$hash][] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$states) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$this->newQuery($states)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'revisionRefs',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$results = array();
|
||||
foreach ($states as $hash => $state) {
|
||||
foreach ($state->getRevisionRefs() as $revision) {
|
||||
if ($revision->isClosed()) {
|
||||
// Don't resolve closed revisions.
|
||||
continue;
|
||||
}
|
||||
|
||||
$uri = $revision->getURI();
|
||||
|
||||
foreach ($map[$hash] as $key) {
|
||||
$results[$key][] = id(new ArcanistBrowseURIRef())
|
||||
->setURI($uri)
|
||||
->setType(self::BROWSETYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
abstract class ArcanistBrowseURIHardpointLoader
|
||||
extends ArcanistHardpointLoader {
|
||||
|
||||
public function getSupportedBrowseType() {
|
||||
return $this->getPhobjectClassConstant('BROWSETYPE', 32);
|
||||
}
|
||||
|
||||
public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistBrowseRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'uris');
|
||||
}
|
||||
|
||||
public function didFailToLoadBrowseURIRefs(array $refs) {
|
||||
return;
|
||||
}
|
||||
|
||||
public function getRefsWithSupportedTypes(array $refs) {
|
||||
$type = $this->getSupportedBrowseType();
|
||||
|
||||
foreach ($refs as $key => $ref) {
|
||||
if ($ref->isUntyped()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ref->hasType($type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($refs[$key]);
|
||||
}
|
||||
|
||||
return $refs;
|
||||
}
|
||||
|
||||
public static function getAllBrowseLoaders() {
|
||||
return id(new PhutilClassMapQuery())
|
||||
->setAncestorClass(__CLASS__)
|
||||
->setUniqueMethod('getLoaderKey')
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
|
@ -82,7 +82,7 @@ EOTEXT
|
|||
pht(
|
||||
'Argument "--force" for "arc browse" is deprecated. Use '.
|
||||
'"--type %s" instead.',
|
||||
ArcanistBrowsePathURIHardpointLoader::BROWSETYPE));
|
||||
ArcanistBrowsePathURIHardpointQuery::BROWSETYPE));
|
||||
}
|
||||
|
||||
$types = $this->getArgument('types');
|
||||
|
@ -90,7 +90,7 @@ EOTEXT
|
|||
$types = preg_split('/[\s,]+/', $types);
|
||||
} else {
|
||||
if ($is_force) {
|
||||
$types = array(ArcanistBrowsePathURIHardpointLoader::BROWSETYPE);
|
||||
$types = array(ArcanistBrowsePathURIHardpointQuery::BROWSETYPE);
|
||||
} else {
|
||||
$types = array();
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistCommitUpstreamHardpointLoader
|
||||
extends ArcanistHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'commit.conduit';
|
||||
|
||||
public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistCommitRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'upstream');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$query = $this->getQuery();
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if (!$repository_ref) {
|
||||
return array_fill_keys(array_keys($refs), null);
|
||||
}
|
||||
$repository_phid = $repository_ref->getPHID();
|
||||
|
||||
$commit_map = array();
|
||||
foreach ($refs as $key => $ref) {
|
||||
$hash = $ref->getCommitHash();
|
||||
$commit_map[$hash][] = $key;
|
||||
}
|
||||
|
||||
$commit_info = $this->resolveCall(
|
||||
'diffusion.querycommits',
|
||||
array(
|
||||
'repositoryPHID' => $repository_phid,
|
||||
'names' => array_keys($commit_map),
|
||||
));
|
||||
|
||||
$results = array();
|
||||
foreach ($commit_map as $hash => $keys) {
|
||||
$commit_phid = idx($commit_info['identifierMap'], $hash);
|
||||
if ($commit_phid) {
|
||||
$commit_data = idx($commit_info['data'], $commit_phid);
|
||||
} else {
|
||||
$commit_data = null;
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$results[$key] = $commit_data;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistGitCommitMessageHardpointLoader
|
||||
extends ArcanistGitHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'git.commit.message';
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistCommitRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'message');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$api = $this->getQuery()->getRepositoryAPI();
|
||||
|
||||
|
||||
$futures = array();
|
||||
foreach ($refs as $ref_key => $ref) {
|
||||
$hash = $ref->getCommitHash();
|
||||
|
||||
$futures[$ref_key] = $api->execFutureLocal(
|
||||
'log -n1 --format=%C %s --',
|
||||
'%s%n%n%b',
|
||||
$hash);
|
||||
}
|
||||
|
||||
$iterator = $this->newFutureIterator($futures);
|
||||
|
||||
$results = array();
|
||||
foreach ($iterator as $ref_key => $future) {
|
||||
list($stdout) = $future->resolvex();
|
||||
$results[$ref_key] = $stdout;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
abstract class ArcanistGitHardpointLoader
|
||||
extends ArcanistHardpointLoader {
|
||||
|
||||
public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api) {
|
||||
return ($api instanceof ArcanistGitAPI);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistGitRevisionHardpointLoader
|
||||
extends ArcanistGitHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'git.revision';
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistWorkingCopyStateRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'revisionRefs');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$this->newQuery($refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'commitRef',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$hashes = array();
|
||||
$map = array();
|
||||
foreach ($refs as $ref_key => $ref) {
|
||||
$commit = $ref->getCommitRef();
|
||||
|
||||
$commit_hashes = array();
|
||||
|
||||
$commit_hashes[] = array(
|
||||
'gtcm',
|
||||
$commit->getCommitHash(),
|
||||
);
|
||||
|
||||
if ($commit->getTreeHash()) {
|
||||
$commit_hashes[] = array(
|
||||
'gttr',
|
||||
$commit->getTreeHash(),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($commit_hashes as $hash) {
|
||||
$hashes[] = $hash;
|
||||
$hash_key = $this->getHashKey($hash);
|
||||
$map[$hash_key][$ref_key] = $ref;
|
||||
}
|
||||
}
|
||||
|
||||
$results = array();
|
||||
if ($hashes) {
|
||||
$revisions = $this->resolveCall(
|
||||
'differential.query',
|
||||
array(
|
||||
'commitHashes' => $hashes,
|
||||
));
|
||||
|
||||
foreach ($revisions as $dict) {
|
||||
$revision_hashes = idx($dict, 'hashes');
|
||||
if (!$revision_hashes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$revision_ref = ArcanistRevisionRef::newFromConduit($dict);
|
||||
foreach ($revision_hashes as $revision_hash) {
|
||||
$hash_key = $this->getHashKey($revision_hash);
|
||||
$state_refs = idx($map, $hash_key, array());
|
||||
foreach ($state_refs as $ref_key => $state_ref) {
|
||||
$results[$ref_key][] = $revision_ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function getHashKey(array $hash) {
|
||||
return $hash[0].':'.$hash[1];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
abstract class ArcanistHardpointLoader
|
||||
extends Phobject {
|
||||
|
||||
private $query;
|
||||
private $conduitEngine;
|
||||
|
||||
abstract public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api);
|
||||
abstract public function canLoadRef(ArcanistRef $ref);
|
||||
abstract public function canLoadHardpoint(ArcanistRef $ref, $hardpoint);
|
||||
abstract public function loadHardpoints(array $refs, $hardpoint);
|
||||
|
||||
final public function setQuery(ArcanistRefQuery $query) {
|
||||
$this->query = $query;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getQuery() {
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
final public function getConduitEngine() {
|
||||
return $this->getQuery()->getConduitEngine();
|
||||
}
|
||||
|
||||
final protected function newQuery(array $refs) {
|
||||
$result = id(new ArcanistRefQuery())
|
||||
->setConduitEngine($this->getQuery()->getConduitEngine())
|
||||
->setRefs($refs);
|
||||
|
||||
$query = $this->getQuery();
|
||||
|
||||
$repository_api = $query->getRepositoryAPI();
|
||||
if ($repository_api) {
|
||||
$result->setRepositoryAPI($repository_api);
|
||||
}
|
||||
|
||||
$repository_ref = $query->getRepositoryRef();
|
||||
if ($repository_ref) {
|
||||
$result->setRepositoryRef($repository_ref);
|
||||
}
|
||||
|
||||
$working_ref = $query->getWorkingCopyRef();
|
||||
if ($working_ref) {
|
||||
$result->setWorkingCopyRef($working_ref);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
final public function getLoaderKey() {
|
||||
return $this->getPhobjectClassConstant('LOADERKEY', 64);
|
||||
}
|
||||
|
||||
final public static function getAllLoaders() {
|
||||
return id(new PhutilClassMapQuery())
|
||||
->setAncestorClass(__CLASS__)
|
||||
->setUniqueMethod('getLoaderKey')
|
||||
->execute();
|
||||
}
|
||||
|
||||
final public function resolveCall($method, array $parameters) {
|
||||
return $this->newCall($method, $parameters)->resolve();
|
||||
}
|
||||
|
||||
final public function newCall($method, array $parameters) {
|
||||
return $this->getConduitEngine()->newCall($method, $parameters);
|
||||
}
|
||||
|
||||
final protected function newFutureIterator(array $futures) {
|
||||
return id(new FutureIterator($futures))
|
||||
->limit(16);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistMercurialBranchCommitHardpointLoader
|
||||
extends ArcanistMercurialHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'hg.branch.commit';
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistBranchRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'commitRef');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$api = $this->getQuery()->getRepositoryAPI();
|
||||
|
||||
$futures = array();
|
||||
foreach ($refs as $ref_key => $branch) {
|
||||
$branch_name = $branch->getBranchName();
|
||||
|
||||
$futures[$ref_key] = $api->execFutureLocal(
|
||||
'log -l 1 --template %s -r %s',
|
||||
"{node}\1{date|hgdate}\1{p1node}\1{desc|firstline}\1{desc}",
|
||||
hgsprintf('%s', $branch_name));
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
$iterator = $this->newFutureIterator($futures);
|
||||
foreach ($iterator as $ref_key => $future) {
|
||||
list($info) = $future->resolvex();
|
||||
|
||||
$fields = explode("\1", trim($info), 5);
|
||||
list($hash, $epoch, $parent, $desc, $text) = $fields;
|
||||
|
||||
$commit_ref = $api->newCommitRef()
|
||||
->setCommitHash($hash)
|
||||
->setCommitEpoch((int)$epoch)
|
||||
->attachMessage($text);
|
||||
|
||||
$results[$ref_key] = $commit_ref;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
abstract class ArcanistMercurialHardpointLoader
|
||||
extends ArcanistHardpointLoader {
|
||||
|
||||
public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api) {
|
||||
return ($api instanceof ArcanistMercurialAPI);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistMercurialWorkingCopyCommitHardpointLoader
|
||||
extends ArcanistMercurialHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'hg.state.commit';
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistWorkingCopyStateRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'commitRef');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$branch_refs = array();
|
||||
foreach ($refs as $ref_key => $ref) {
|
||||
if ($ref->hasAttachedHardpoint('branchRef')) {
|
||||
$branch_refs[$ref_key] = $ref->getBranchRef();
|
||||
}
|
||||
}
|
||||
|
||||
if ($branch_refs) {
|
||||
$this->newQuery($branch_refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'commitRef',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
return mpull($branch_refs, 'getCommitRef');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistMessageRevisionHardpointLoader
|
||||
extends ArcanistHardpointLoader {
|
||||
|
||||
const LOADERKEY = 'message.revision';
|
||||
|
||||
public function canLoadRepositoryAPI(ArcanistRepositoryAPI $api) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canLoadRef(ArcanistRef $ref) {
|
||||
return ($ref instanceof ArcanistWorkingCopyStateRef);
|
||||
}
|
||||
|
||||
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
|
||||
return ($hardpoint == 'revisionRefs');
|
||||
}
|
||||
|
||||
public function loadHardpoints(array $refs, $hardpoint) {
|
||||
$this->newQuery($refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'commitRef',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$commit_refs = array();
|
||||
foreach ($refs as $ref) {
|
||||
$commit_refs[] = $ref->getCommitRef();
|
||||
}
|
||||
|
||||
$this->newQuery($commit_refs)
|
||||
->needHardpoints(
|
||||
array(
|
||||
'message',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$map = array();
|
||||
foreach ($refs as $ref_key => $ref) {
|
||||
$commit_ref = $ref->getCommitRef();
|
||||
$corpus = $commit_ref->getMessage();
|
||||
|
||||
$id = null;
|
||||
try {
|
||||
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($corpus);
|
||||
$id = $message->getRevisionID();
|
||||
} catch (ArcanistUsageException $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$map[$id][$ref_key] = $ref;
|
||||
}
|
||||
|
||||
$results = array();
|
||||
if ($map) {
|
||||
$revisions = $this->resolveCall(
|
||||
'differential.query',
|
||||
array(
|
||||
'ids' => array_keys($map),
|
||||
));
|
||||
|
||||
foreach ($revisions as $dict) {
|
||||
$revision_ref = ArcanistRevisionRef::newFromConduit($dict);
|
||||
$id = $dict['id'];
|
||||
|
||||
$state_refs = idx($map, $id, array());
|
||||
foreach ($state_refs as $ref_key => $state_ref) {
|
||||
$results[$ref_key][] = $revision_ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,188 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ArcanistRefQuery extends Phobject {
|
||||
|
||||
private $repositoryAPI;
|
||||
private $conduitEngine;
|
||||
private $repositoryRef;
|
||||
private $workingCopyRef;
|
||||
|
||||
private $refs;
|
||||
private $hardpoints;
|
||||
private $loaders;
|
||||
|
||||
public function setRefs(array $refs) {
|
||||
assert_instances_of($refs, 'ArcanistRef');
|
||||
$this->refs = $refs;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefs() {
|
||||
return $this->refs;
|
||||
}
|
||||
|
||||
public function setRepositoryAPI(ArcanistRepositoryAPI $repository_api) {
|
||||
$this->repositoryAPI = $repository_api;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRepositoryAPI() {
|
||||
return $this->repositoryAPI;
|
||||
}
|
||||
|
||||
public function setRepositoryRef(ArcanistRepositoryRef $repository_ref) {
|
||||
$this->repositoryRef = $repository_ref;
|
||||
return $this;
|
||||
}
|
||||
public function getRepositoryRef() {
|
||||
return $this->repositoryRef;
|
||||
}
|
||||
|
||||
public function setConduitEngine(ArcanistConduitEngine $conduit_engine) {
|
||||
$this->conduitEngine = $conduit_engine;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConduitEngine() {
|
||||
return $this->conduitEngine;
|
||||
}
|
||||
|
||||
public function setWorkingCopyRef(ArcanistWorkingCopyStateRef $working_ref) {
|
||||
$this->workingCopyRef = $working_ref;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWorkingCopyRef() {
|
||||
return $this->workingCopyRef;
|
||||
}
|
||||
|
||||
public function needHardpoints(array $hardpoints) {
|
||||
$this->hardpoints = $hardpoints;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLoaders(array $loaders) {
|
||||
assert_instances_of($loaders, 'ArcanistHardpointLoader');
|
||||
|
||||
foreach ($loaders as $key => $loader) {
|
||||
$loader->setQuery($this);
|
||||
}
|
||||
$this->loaders = $loaders;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$refs = $this->getRefs();
|
||||
|
||||
if ($this->refs === null) {
|
||||
throw new PhutilInvalidStateException('setRefs');
|
||||
}
|
||||
|
||||
if ($this->hardpoints === null) {
|
||||
throw new PhutilInvalidStateException('needHardpoints');
|
||||
}
|
||||
|
||||
if ($this->loaders == null) {
|
||||
$all_loaders = ArcanistHardpointLoader::getAllLoaders();
|
||||
foreach ($all_loaders as $key => $loader) {
|
||||
$all_loaders[$key] = clone $loader;
|
||||
}
|
||||
$this->setLoaders($all_loaders);
|
||||
}
|
||||
|
||||
$all_loaders = $this->loaders;
|
||||
|
||||
$api = $this->getRepositoryAPI();
|
||||
$loaders = array();
|
||||
foreach ($all_loaders as $loader_key => $loader) {
|
||||
if ($api) {
|
||||
if (!$loader->canLoadRepositoryAPI($api)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$loaders[$loader_key] = id(clone $loader)
|
||||
->setQuery($this);
|
||||
}
|
||||
|
||||
foreach ($this->hardpoints as $hardpoint) {
|
||||
$load = array();
|
||||
$need = array();
|
||||
$has_hardpoint = false;
|
||||
foreach ($refs as $ref_key => $ref) {
|
||||
if (!$ref->hasHardpoint($hardpoint)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$has_hardpoint = true;
|
||||
|
||||
if ($ref->hasAttachedHardpoint($hardpoint)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($loaders as $loader_key => $loader) {
|
||||
if (!$loader->canLoadRef($ref)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$loader->canLoadHardpoint($ref, $hardpoint)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$load[$loader_key][$ref_key] = $ref;
|
||||
}
|
||||
|
||||
$need[$ref_key] = $ref_key;
|
||||
}
|
||||
|
||||
if ($refs && !$has_hardpoint) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'No ref in query has hardpoint "%s".',
|
||||
$hardpoint));
|
||||
}
|
||||
|
||||
$vectors = array();
|
||||
foreach ($need as $ref_key) {
|
||||
$ref = $refs[$ref_key];
|
||||
if ($ref->isVectorHardpoint($hardpoint)) {
|
||||
$vectors[$ref_key] = $ref_key;
|
||||
$ref->attachHardpoint($hardpoint, array());
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($load as $loader_key => $loader_refs) {
|
||||
$loader_refs = array_select_keys($loader_refs, $need);
|
||||
|
||||
$loader = $loaders[$loader_key];
|
||||
$data = $loader->loadHardpoints($loader_refs, $hardpoint);
|
||||
|
||||
foreach ($data as $ref_key => $value) {
|
||||
$ref = $refs[$ref_key];
|
||||
if (isset($vectors[$ref_key])) {
|
||||
$ref->appendHardpoint($hardpoint, $value);
|
||||
} else {
|
||||
unset($need[$ref_key]);
|
||||
$ref->attachHardpoint($hardpoint, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($vectors as $ref_key) {
|
||||
unset($need[$ref_key]);
|
||||
}
|
||||
|
||||
if ($need) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Nothing could attach data to hardpoint "%s" for ref "%s".',
|
||||
$hardpoint,
|
||||
$refs[head($need)]->getRefIdentifier()));
|
||||
}
|
||||
}
|
||||
|
||||
return $refs;
|
||||
}
|
||||
|
||||
}
|
|
@ -2250,31 +2250,6 @@ abstract class ArcanistWorkflow extends Phobject {
|
|||
return $this->conduitEngine;
|
||||
}
|
||||
|
||||
final protected function newRefQuery(array $refs) {
|
||||
assert_instances_of($refs, 'ArcanistRef');
|
||||
|
||||
$query = id(new ArcanistRefQuery())
|
||||
->setConduitEngine($this->getConduitEngine())
|
||||
->setRefs($refs);
|
||||
|
||||
if ($this->hasRepositoryAPI()) {
|
||||
$query->setRepositoryAPI($this->getRepositoryAPI());
|
||||
}
|
||||
|
||||
$repository_ref = $this->getRepositoryRef();
|
||||
if ($repository_ref) {
|
||||
$query->setRepositoryRef($repository_ref);
|
||||
}
|
||||
|
||||
$working_copy = $this->getWorkingCopyIdentity();
|
||||
if ($working_copy) {
|
||||
$working_ref = $this->newWorkingCopyStateRef();
|
||||
$query->setWorkingCopyRef($working_ref);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
final public function getRepositoryRef() {
|
||||
$configuration_engine = $this->getConfigurationEngine();
|
||||
if ($configuration_engine) {
|
||||
|
|
Loading…
Reference in a new issue