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 @@ -55,19 +55,13 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ 'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistCommitRef' => 'ArcanistRef', 'ArcanistCommitRefInspector' => 'ArcanistRefInspector', - 'ArcanistCommitUpstreamHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistCommitUpstreamHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistCommitWorkflow' => 'ArcanistWorkflow', 'ArcanistCompilerLintRenderer' => 'ArcanistLintRenderer', @@ -1187,11 +1164,8 @@ '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 @@ 'ArcanistHardpointEngine' => 'Phobject', 'ArcanistHardpointFutureList' => 'Phobject', 'ArcanistHardpointList' => 'Phobject', - 'ArcanistHardpointLoader' => 'Phobject', 'ArcanistHardpointObject' => 'Phobject', 'ArcanistHardpointQuery' => 'Phobject', 'ArcanistHardpointRequest' => 'Phobject', @@ -1293,15 +1266,11 @@ '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 @@ 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistRef' => 'ArcanistHardpointObject', 'ArcanistRefInspector' => 'Phobject', - 'ArcanistRefQuery' => 'Phobject', 'ArcanistRepositoryAPI' => 'Phobject', 'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase', 'ArcanistRepositoryAPIStateTestCase' => 'PhutilTestCase', diff --git a/src/browse/loader/ArcanistBrowseCommitHardpointLoader.php b/src/browse/loader/ArcanistBrowseCommitHardpointLoader.php deleted file mode 100644 --- a/src/browse/loader/ArcanistBrowseCommitHardpointLoader.php +++ /dev/null @@ -1,80 +0,0 @@ -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; - } - -} diff --git a/src/browse/loader/ArcanistBrowseCommitURIHardpointLoader.php b/src/browse/loader/ArcanistBrowseCommitURIHardpointLoader.php deleted file mode 100644 --- a/src/browse/loader/ArcanistBrowseCommitURIHardpointLoader.php +++ /dev/null @@ -1,92 +0,0 @@ -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; - } - - -} diff --git a/src/browse/loader/ArcanistBrowseObjectNameURIHardpointLoader.php b/src/browse/loader/ArcanistBrowseObjectNameURIHardpointLoader.php deleted file mode 100644 --- a/src/browse/loader/ArcanistBrowseObjectNameURIHardpointLoader.php +++ /dev/null @@ -1,54 +0,0 @@ -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; - } - -} diff --git a/src/browse/loader/ArcanistBrowsePathURIHardpointLoader.php b/src/browse/loader/ArcanistBrowsePathURIHardpointLoader.php deleted file mode 100644 --- a/src/browse/loader/ArcanistBrowsePathURIHardpointLoader.php +++ /dev/null @@ -1,132 +0,0 @@ -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; - } - - -} diff --git a/src/browse/loader/ArcanistBrowseRevisionURIHardpointLoader.php b/src/browse/loader/ArcanistBrowseRevisionURIHardpointLoader.php deleted file mode 100644 --- a/src/browse/loader/ArcanistBrowseRevisionURIHardpointLoader.php +++ /dev/null @@ -1,78 +0,0 @@ -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; - } - - -} diff --git a/src/browse/loader/ArcanistBrowseURIHardpointLoader.php b/src/browse/loader/ArcanistBrowseURIHardpointLoader.php deleted file mode 100644 --- a/src/browse/loader/ArcanistBrowseURIHardpointLoader.php +++ /dev/null @@ -1,51 +0,0 @@ -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(); - } - -} diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php --- a/src/browse/workflow/ArcanistBrowseWorkflow.php +++ b/src/browse/workflow/ArcanistBrowseWorkflow.php @@ -82,7 +82,7 @@ pht( 'Argument "--force" for "arc browse" is deprecated. Use '. '"--type %s" instead.', - ArcanistBrowsePathURIHardpointLoader::BROWSETYPE)); + ArcanistBrowsePathURIHardpointQuery::BROWSETYPE)); } $types = $this->getArgument('types'); @@ -90,7 +90,7 @@ $types = preg_split('/[\s,]+/', $types); } else { if ($is_force) { - $types = array(ArcanistBrowsePathURIHardpointLoader::BROWSETYPE); + $types = array(ArcanistBrowsePathURIHardpointQuery::BROWSETYPE); } else { $types = array(); } diff --git a/src/loader/ArcanistCommitUpstreamHardpointLoader.php b/src/loader/ArcanistCommitUpstreamHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistCommitUpstreamHardpointLoader.php +++ /dev/null @@ -1,59 +0,0 @@ -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; - } - -} diff --git a/src/loader/ArcanistGitCommitMessageHardpointLoader.php b/src/loader/ArcanistGitCommitMessageHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistGitCommitMessageHardpointLoader.php +++ /dev/null @@ -1,41 +0,0 @@ -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; - } - -} diff --git a/src/loader/ArcanistGitHardpointLoader.php b/src/loader/ArcanistGitHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistGitHardpointLoader.php +++ /dev/null @@ -1,10 +0,0 @@ -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]; - } - -} diff --git a/src/loader/ArcanistHardpointLoader.php b/src/loader/ArcanistHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistHardpointLoader.php +++ /dev/null @@ -1,76 +0,0 @@ -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); - } - -} diff --git a/src/loader/ArcanistMercurialBranchCommitHardpointLoader.php b/src/loader/ArcanistMercurialBranchCommitHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistMercurialBranchCommitHardpointLoader.php +++ /dev/null @@ -1,49 +0,0 @@ -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; - } - -} diff --git a/src/loader/ArcanistMercurialHardpointLoader.php b/src/loader/ArcanistMercurialHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistMercurialHardpointLoader.php +++ /dev/null @@ -1,10 +0,0 @@ - $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'); - } - -} diff --git a/src/loader/ArcanistMessageRevisionHardpointLoader.php b/src/loader/ArcanistMessageRevisionHardpointLoader.php deleted file mode 100644 --- a/src/loader/ArcanistMessageRevisionHardpointLoader.php +++ /dev/null @@ -1,82 +0,0 @@ -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; - } - -} diff --git a/src/ref/ArcanistRefQuery.php b/src/ref/ArcanistRefQuery.php deleted file mode 100644 --- a/src/ref/ArcanistRefQuery.php +++ /dev/null @@ -1,188 +0,0 @@ -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; - } - -} diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -2250,31 +2250,6 @@ 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) {