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

Reroute all RefQuery callers to HardpointEngine

Summary:
Ref T11968. "arc browse", "arc branch", and "arc diff" currently may execute into the RefQuery engine. Reroute them to the HardpointEngine.

This removes older-generation "Ref" objects and renames the replacement "RefPro" objects to "Ref".

Test Plan: Ran "arc branch", "arc browse <various things>", "arc diff", searched for affected symbols.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21082
This commit is contained in:
epriestley 2020-04-11 06:16:22 -07:00
parent 9e72e4ed1d
commit dc42f51cf7
36 changed files with 136 additions and 796 deletions

View file

@ -54,7 +54,6 @@ phutil_register_library_map(array(
'ArcanistBraceFormattingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php', 'ArcanistBraceFormattingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php',
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php', 'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php',
'ArcanistBranchRef' => 'ref/ArcanistBranchRef.php', 'ArcanistBranchRef' => 'ref/ArcanistBranchRef.php',
'ArcanistBranchRefPro' => 'ref/ArcanistBranchRefPro.php',
'ArcanistBranchWorkflow' => 'workflow/ArcanistBranchWorkflow.php', 'ArcanistBranchWorkflow' => 'workflow/ArcanistBranchWorkflow.php',
'ArcanistBrowseCommitHardpointLoader' => 'browse/loader/ArcanistBrowseCommitHardpointLoader.php', 'ArcanistBrowseCommitHardpointLoader' => 'browse/loader/ArcanistBrowseCommitHardpointLoader.php',
'ArcanistBrowseCommitHardpointQuery' => 'browse/query/ArcanistBrowseCommitHardpointQuery.php', 'ArcanistBrowseCommitHardpointQuery' => 'browse/query/ArcanistBrowseCommitHardpointQuery.php',
@ -66,13 +65,11 @@ phutil_register_library_map(array(
'ArcanistBrowsePathURIHardpointQuery' => 'browse/query/ArcanistBrowsePathURIHardpointQuery.php', 'ArcanistBrowsePathURIHardpointQuery' => 'browse/query/ArcanistBrowsePathURIHardpointQuery.php',
'ArcanistBrowseRef' => 'browse/ref/ArcanistBrowseRef.php', 'ArcanistBrowseRef' => 'browse/ref/ArcanistBrowseRef.php',
'ArcanistBrowseRefInspector' => 'inspector/ArcanistBrowseRefInspector.php', 'ArcanistBrowseRefInspector' => 'inspector/ArcanistBrowseRefInspector.php',
'ArcanistBrowseRefPro' => 'browse/ref/ArcanistBrowseRefPro.php',
'ArcanistBrowseRevisionURIHardpointLoader' => 'browse/loader/ArcanistBrowseRevisionURIHardpointLoader.php', 'ArcanistBrowseRevisionURIHardpointLoader' => 'browse/loader/ArcanistBrowseRevisionURIHardpointLoader.php',
'ArcanistBrowseRevisionURIHardpointQuery' => 'browse/query/ArcanistBrowseRevisionURIHardpointQuery.php', 'ArcanistBrowseRevisionURIHardpointQuery' => 'browse/query/ArcanistBrowseRevisionURIHardpointQuery.php',
'ArcanistBrowseURIHardpointLoader' => 'browse/loader/ArcanistBrowseURIHardpointLoader.php', 'ArcanistBrowseURIHardpointLoader' => 'browse/loader/ArcanistBrowseURIHardpointLoader.php',
'ArcanistBrowseURIHardpointQuery' => 'browse/query/ArcanistBrowseURIHardpointQuery.php', 'ArcanistBrowseURIHardpointQuery' => 'browse/query/ArcanistBrowseURIHardpointQuery.php',
'ArcanistBrowseURIRef' => 'browse/ref/ArcanistBrowseURIRef.php', 'ArcanistBrowseURIRef' => 'browse/ref/ArcanistBrowseURIRef.php',
'ArcanistBrowseURIRefPro' => 'browse/ref/ArcanistBrowseURIRefPro.php',
'ArcanistBrowseWorkflow' => 'browse/workflow/ArcanistBrowseWorkflow.php', 'ArcanistBrowseWorkflow' => 'browse/workflow/ArcanistBrowseWorkflow.php',
'ArcanistBuildPlanRef' => 'ref/ArcanistBuildPlanRef.php', 'ArcanistBuildPlanRef' => 'ref/ArcanistBuildPlanRef.php',
'ArcanistBuildRef' => 'ref/ArcanistBuildRef.php', 'ArcanistBuildRef' => 'ref/ArcanistBuildRef.php',
@ -113,7 +110,6 @@ phutil_register_library_map(array(
'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistCommentStyleXHPASTLinterRuleTestCase.php', 'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistCommentStyleXHPASTLinterRuleTestCase.php',
'ArcanistCommitRef' => 'ref/ArcanistCommitRef.php', 'ArcanistCommitRef' => 'ref/ArcanistCommitRef.php',
'ArcanistCommitRefInspector' => 'inspector/ArcanistCommitRefInspector.php', 'ArcanistCommitRefInspector' => 'inspector/ArcanistCommitRefInspector.php',
'ArcanistCommitRefPro' => 'ref/ArcanistCommitRefPro.php',
'ArcanistCommitUpstreamHardpointLoader' => 'loader/ArcanistCommitUpstreamHardpointLoader.php', 'ArcanistCommitUpstreamHardpointLoader' => 'loader/ArcanistCommitUpstreamHardpointLoader.php',
'ArcanistCommitUpstreamHardpointQuery' => 'query/ArcanistCommitUpstreamHardpointQuery.php', 'ArcanistCommitUpstreamHardpointQuery' => 'query/ArcanistCommitUpstreamHardpointQuery.php',
'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php', 'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php',
@ -401,7 +397,6 @@ phutil_register_library_map(array(
'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase.php', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase.php',
'ArcanistRef' => 'ref/ArcanistRef.php', 'ArcanistRef' => 'ref/ArcanistRef.php',
'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php', 'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php',
'ArcanistRefPro' => 'ref/ArcanistRefPro.php',
'ArcanistRefQuery' => 'ref/ArcanistRefQuery.php', 'ArcanistRefQuery' => 'ref/ArcanistRefQuery.php',
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php', 'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php', 'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php',
@ -415,7 +410,6 @@ phutil_register_library_map(array(
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorXHPASTLinterRuleTestCase.php', 'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorXHPASTLinterRuleTestCase.php',
'ArcanistRevertWorkflow' => 'workflow/ArcanistRevertWorkflow.php', 'ArcanistRevertWorkflow' => 'workflow/ArcanistRevertWorkflow.php',
'ArcanistRevisionRef' => 'ref/ArcanistRevisionRef.php', 'ArcanistRevisionRef' => 'ref/ArcanistRevisionRef.php',
'ArcanistRevisionRefPro' => 'ref/ArcanistRevisionRefPro.php',
'ArcanistRevisionRefSource' => 'ref/ArcanistRevisionRefSource.php', 'ArcanistRevisionRefSource' => 'ref/ArcanistRevisionRefSource.php',
'ArcanistRuboCopLinter' => 'lint/linter/ArcanistRuboCopLinter.php', 'ArcanistRuboCopLinter' => 'lint/linter/ArcanistRuboCopLinter.php',
'ArcanistRuboCopLinterTestCase' => 'lint/linter/__tests__/ArcanistRuboCopLinterTestCase.php', 'ArcanistRuboCopLinterTestCase' => 'lint/linter/__tests__/ArcanistRuboCopLinterTestCase.php',
@ -521,7 +515,6 @@ phutil_register_library_map(array(
'ArcanistWorkingCopyPath' => 'workingcopy/ArcanistWorkingCopyPath.php', 'ArcanistWorkingCopyPath' => 'workingcopy/ArcanistWorkingCopyPath.php',
'ArcanistWorkingCopyStateRef' => 'ref/ArcanistWorkingCopyStateRef.php', 'ArcanistWorkingCopyStateRef' => 'ref/ArcanistWorkingCopyStateRef.php',
'ArcanistWorkingCopyStateRefInspector' => 'inspector/ArcanistWorkingCopyStateRefInspector.php', 'ArcanistWorkingCopyStateRefInspector' => 'inspector/ArcanistWorkingCopyStateRefInspector.php',
'ArcanistWorkingCopyStateRefPro' => 'ref/ArcanistWorkingCopyStateRefPro.php',
'ArcanistXHPASTLintNamingHook' => 'lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php', 'ArcanistXHPASTLintNamingHook' => 'lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php',
'ArcanistXHPASTLintNamingHookTestCase' => 'lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php', 'ArcanistXHPASTLintNamingHookTestCase' => 'lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php',
'ArcanistXHPASTLintSwitchHook' => 'lint/linter/xhpast/ArcanistXHPASTLintSwitchHook.php', 'ArcanistXHPASTLintSwitchHook' => 'lint/linter/xhpast/ArcanistXHPASTLintSwitchHook.php',
@ -1037,7 +1030,6 @@ phutil_register_library_map(array(
'ArcanistBraceFormattingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistBraceFormattingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistBranchRef' => 'ArcanistRef', 'ArcanistBranchRef' => 'ArcanistRef',
'ArcanistBranchRefPro' => 'ArcanistRefPro',
'ArcanistBranchWorkflow' => 'ArcanistFeatureWorkflow', 'ArcanistBranchWorkflow' => 'ArcanistFeatureWorkflow',
'ArcanistBrowseCommitHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistBrowseCommitHardpointLoader' => 'ArcanistHardpointLoader',
'ArcanistBrowseCommitHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistBrowseCommitHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
@ -1049,13 +1041,11 @@ phutil_register_library_map(array(
'ArcanistBrowsePathURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery', 'ArcanistBrowsePathURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery',
'ArcanistBrowseRef' => 'ArcanistRef', 'ArcanistBrowseRef' => 'ArcanistRef',
'ArcanistBrowseRefInspector' => 'ArcanistRefInspector', 'ArcanistBrowseRefInspector' => 'ArcanistRefInspector',
'ArcanistBrowseRefPro' => 'ArcanistRefPro',
'ArcanistBrowseRevisionURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader', 'ArcanistBrowseRevisionURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader',
'ArcanistBrowseRevisionURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery', 'ArcanistBrowseRevisionURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery',
'ArcanistBrowseURIHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistBrowseURIHardpointLoader' => 'ArcanistHardpointLoader',
'ArcanistBrowseURIHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistBrowseURIHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
'ArcanistBrowseURIRef' => 'ArcanistRef', 'ArcanistBrowseURIRef' => 'ArcanistRef',
'ArcanistBrowseURIRefPro' => 'ArcanistRefPro',
'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow', 'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow',
'ArcanistBuildPlanRef' => 'Phobject', 'ArcanistBuildPlanRef' => 'Phobject',
'ArcanistBuildRef' => 'Phobject', 'ArcanistBuildRef' => 'Phobject',
@ -1096,7 +1086,6 @@ phutil_register_library_map(array(
'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistCommitRef' => 'ArcanistRef', 'ArcanistCommitRef' => 'ArcanistRef',
'ArcanistCommitRefInspector' => 'ArcanistRefInspector', 'ArcanistCommitRefInspector' => 'ArcanistRefInspector',
'ArcanistCommitRefPro' => 'ArcanistRefPro',
'ArcanistCommitUpstreamHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistCommitUpstreamHardpointLoader' => 'ArcanistHardpointLoader',
'ArcanistCommitUpstreamHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistCommitUpstreamHardpointQuery' => 'ArcanistWorkflowHardpointQuery',
'ArcanistCommitWorkflow' => 'ArcanistWorkflow', 'ArcanistCommitWorkflow' => 'ArcanistWorkflow',
@ -1382,9 +1371,8 @@ phutil_register_library_map(array(
'ArcanistPyLintLinterTestCase' => 'ArcanistExternalLinterTestCase', 'ArcanistPyLintLinterTestCase' => 'ArcanistExternalLinterTestCase',
'ArcanistRaggedClassTreeEdgeXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistRef' => 'Phobject', 'ArcanistRef' => 'ArcanistHardpointObject',
'ArcanistRefInspector' => 'Phobject', 'ArcanistRefInspector' => 'Phobject',
'ArcanistRefPro' => 'ArcanistHardpointObject',
'ArcanistRefQuery' => 'Phobject', 'ArcanistRefQuery' => 'Phobject',
'ArcanistRepositoryAPI' => 'Phobject', 'ArcanistRepositoryAPI' => 'Phobject',
'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase', 'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase',
@ -1398,7 +1386,6 @@ phutil_register_library_map(array(
'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistRevertWorkflow' => 'ArcanistWorkflow', 'ArcanistRevertWorkflow' => 'ArcanistWorkflow',
'ArcanistRevisionRef' => 'ArcanistRef', 'ArcanistRevisionRef' => 'ArcanistRef',
'ArcanistRevisionRefPro' => 'ArcanistRefPro',
'ArcanistRevisionRefSource' => 'Phobject', 'ArcanistRevisionRefSource' => 'Phobject',
'ArcanistRuboCopLinter' => 'ArcanistExternalLinter', 'ArcanistRuboCopLinter' => 'ArcanistExternalLinter',
'ArcanistRuboCopLinterTestCase' => 'ArcanistExternalLinterTestCase', 'ArcanistRuboCopLinterTestCase' => 'ArcanistExternalLinterTestCase',
@ -1503,7 +1490,6 @@ phutil_register_library_map(array(
'ArcanistWorkingCopyPath' => 'Phobject', 'ArcanistWorkingCopyPath' => 'Phobject',
'ArcanistWorkingCopyStateRef' => 'ArcanistRef', 'ArcanistWorkingCopyStateRef' => 'ArcanistRef',
'ArcanistWorkingCopyStateRefInspector' => 'ArcanistRefInspector', 'ArcanistWorkingCopyStateRefInspector' => 'ArcanistRefInspector',
'ArcanistWorkingCopyStateRefPro' => 'ArcanistRefPro',
'ArcanistXHPASTLintNamingHook' => 'Phobject', 'ArcanistXHPASTLintNamingHook' => 'Phobject',
'ArcanistXHPASTLintNamingHookTestCase' => 'PhutilTestCase', 'ArcanistXHPASTLintNamingHookTestCase' => 'PhutilTestCase',
'ArcanistXHPASTLintSwitchHook' => 'Phobject', 'ArcanistXHPASTLintSwitchHook' => 'Phobject',

View file

@ -19,10 +19,6 @@ abstract class ArcanistBrowseURIHardpointLoader
return ($hardpoint == 'uris'); return ($hardpoint == 'uris');
} }
public function willLoadBrowseURIRefs(array $refs) {
return;
}
public function didFailToLoadBrowseURIRefs(array $refs) { public function didFailToLoadBrowseURIRefs(array $refs) {
return; return;
} }

View file

@ -5,12 +5,12 @@ final class ArcanistBrowseCommitHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistBrowseRefPro::HARDPOINT_COMMITREFS, ArcanistBrowseRef::HARDPOINT_COMMITREFS,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistBrowseRefPro); return ($ref instanceof ArcanistBrowseRef);
} }
public function loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {
@ -53,7 +53,7 @@ final class ArcanistBrowseCommitHardpointQuery
$results = array(); $results = array();
foreach ($commit_map as $commit_identifier => $ref_keys) { foreach ($commit_map as $commit_identifier => $ref_keys) {
foreach ($ref_keys as $key) { foreach ($ref_keys as $key) {
$commit_ref = id(new ArcanistCommitRefPro()) $commit_ref = id(new ArcanistCommitRef())
->setCommitHash($commit_identifier); ->setCommitHash($commit_identifier);
$results[$key][] = $commit_ref; $results[$key][] = $commit_ref;
} }

View file

@ -5,33 +5,6 @@ final class ArcanistBrowseCommitURIHardpointQuery
const BROWSETYPE = '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 loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {
$refs = $this->getRefsWithSupportedTypes($refs); $refs = $this->getRefsWithSupportedTypes($refs);
if (!$refs) { if (!$refs) {
@ -41,7 +14,7 @@ final class ArcanistBrowseCommitURIHardpointQuery
yield $this->yieldRequests( yield $this->yieldRequests(
$refs, $refs,
array( array(
ArcanistBrowseRefPro::HARDPOINT_COMMITREFS, ArcanistBrowseRef::HARDPOINT_COMMITREFS,
)); ));
$commit_refs = array(); $commit_refs = array();
@ -54,7 +27,7 @@ final class ArcanistBrowseCommitURIHardpointQuery
yield $this->yieldRequests( yield $this->yieldRequests(
$commit_refs, $commit_refs,
array( array(
ArcanistCommitRefPro::HARDPOINT_UPSTREAM, ArcanistCommitRef::HARDPOINT_UPSTREAM,
)); ));
$results = array(); $results = array();

View file

@ -5,60 +5,6 @@ final class ArcanistBrowsePathURIHardpointQuery
const BROWSETYPE = '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 loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {
$refs = $this->getRefsWithSupportedTypes($refs); $refs = $this->getRefsWithSupportedTypes($refs);
if (!$refs) { if (!$refs) {

View file

@ -14,7 +14,7 @@ final class ArcanistBrowseRevisionURIHardpointQuery
yield $this->yieldRequests( yield $this->yieldRequests(
$refs, $refs,
array( array(
ArcanistBrowseRefPro::HARDPOINT_COMMITREFS, ArcanistBrowseRef::HARDPOINT_COMMITREFS,
)); ));
$states = array(); $states = array();
@ -22,7 +22,7 @@ final class ArcanistBrowseRevisionURIHardpointQuery
foreach ($refs as $key => $ref) { foreach ($refs as $key => $ref) {
foreach ($ref->getCommitRefs() as $commit_ref) { foreach ($ref->getCommitRefs() as $commit_ref) {
$hash = $commit_ref->getCommitHash(); $hash = $commit_ref->getCommitHash();
$states[$hash] = id(new ArcanistWorkingCopyStateRefPro()) $states[$hash] = id(new ArcanistWorkingCopyStateRef())
->setCommitRef($commit_ref); ->setCommitRef($commit_ref);
$map[$hash][] = $key; $map[$hash][] = $key;
} }

View file

@ -9,12 +9,12 @@ abstract class ArcanistBrowseURIHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistBrowseRefPro::HARDPOINT_URIS, ArcanistBrowseRef::HARDPOINT_URIS,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistBrowseRefPro); return ($ref instanceof ArcanistBrowseRef);
} }
public function getRefsWithSupportedTypes(array $refs) { public function getRefsWithSupportedTypes(array $refs) {
@ -42,7 +42,7 @@ abstract class ArcanistBrowseURIHardpointQuery
} }
final protected function newBrowseURIRef() { final protected function newBrowseURIRef() {
return id(new ArcanistBrowseURIRefPro()) return id(new ArcanistBrowseURIRef())
->setType($this->getSupportedBrowseType()); ->setType($this->getSupportedBrowseType());
} }

View file

@ -3,24 +3,21 @@
final class ArcanistBrowseRef final class ArcanistBrowseRef
extends ArcanistRef { extends ArcanistRef {
const HARDPOINT_URIS = 'uris';
const HARDPOINT_COMMITREFS = 'commitRefs';
private $token; private $token;
private $types; private $types = array();
private $branch; private $branch;
public function getRefIdentifier() { public function getRefDisplayName() {
return pht('Browse Query "%s"', $this->getToken()); return pht('Browse Query "%s"', $this->getToken());
} }
public function defineHardpoints() { protected function newHardpoints() {
return array( return array(
'commitRefs' => array( $this->newVectorHardpoint(self::HARDPOINT_COMMITREFS),
'type' => 'ArcanistCommitRef', $this->newVectorHardpoint(self::HARDPOINT_URIS),
'vector' => true,
),
'uris' => array(
'type' => 'ArcanistBrowseURIRef',
'vector' => true,
),
); );
} }
@ -62,11 +59,11 @@ final class ArcanistBrowseRef
} }
public function getURIs() { public function getURIs() {
return $this->getHardpoint('uris'); return $this->getHardpoint(self::HARDPOINT_URIS);
} }
public function getCommitRefs() { public function getCommitRefs() {
return $this->getHardpoint('commitRefs'); return $this->getHardpoint(self::HARDPOINT_COMMITREFS);
} }
} }

View file

@ -1,69 +0,0 @@
<?php
final class ArcanistBrowseRefPro
extends ArcanistRefPro {
const HARDPOINT_URIS = 'uris';
const HARDPOINT_COMMITREFS = 'commitRefs';
private $token;
private $types = array();
private $branch;
public function getRefDisplayName() {
return pht('Browse Query "%s"', $this->getToken());
}
protected function newHardpoints() {
return array(
$this->newVectorHardpoint(self::HARDPOINT_COMMITREFS),
$this->newVectorHardpoint(self::HARDPOINT_URIS),
);
}
public function setToken($token) {
$this->token = $token;
return $this;
}
public function getToken() {
return $this->token;
}
public function setTypes(array $types) {
$this->types = $types;
return $this;
}
public function getTypes() {
return $this->types;
}
public function hasType($type) {
$map = $this->getTypes();
$map = array_fuse($map);
return isset($map[$type]);
}
public function isUntyped() {
return !$this->types;
}
public function setBranch($branch) {
$this->branch = $branch;
return $this;
}
public function getBranch() {
return $this->branch;
}
public function getURIs() {
return $this->getHardpoint(self::HARDPOINT_URIS);
}
public function getCommitRefs() {
return $this->getHardpoint(self::HARDPOINT_COMMITREFS);
}
}

View file

@ -6,7 +6,7 @@ final class ArcanistBrowseURIRef
private $uri; private $uri;
private $type; private $type;
public function getRefIdentifier() { public function getRefDisplayName() {
return pht('Browse URI "%s"', $this->getURI()); return pht('Browse URI "%s"', $this->getURI());
} }

View file

@ -1,35 +0,0 @@
<?php
final class ArcanistBrowseURIRefPro
extends ArcanistRefPro {
private $uri;
private $type;
public function getRefDisplayName() {
return pht('Browse URI "%s"', $this->getURI());
}
public function defineHardpoints() {
return array();
}
public function setURI($uri) {
$this->uri = $uri;
return $this;
}
public function getURI() {
return $this->uri;
}
public function setType($type) {
$this->type = $type;
return $this;
}
public function getType() {
return $this->type;
}
}

View file

@ -107,23 +107,22 @@ EOTEXT
} }
} }
$loaders = ArcanistBrowseURIHardpointLoader::getAllBrowseLoaders(); // TODO: The "Path" and "Commit" queries should regain the ability to warn
foreach ($loaders as $key => $loader) { // when this command is not run in a working copy that belongs to a
$loaders[$key] = clone $loader; // recognized repository, so they won't ever be able to resolve things.
}
$query = $this->newRefQuery($refs) // TODO: When you run "arc browse" with no arguments, we should either
->needHardpoints( // take you to the repository home page or show help.
array(
'uris',
))
->setLoaders($loaders);
foreach ($loaders as $loader) { // TODO: When you "arc browse something/like/a/path.c" but it does not
$loader->willLoadBrowseURIRefs($refs); // exist on disk, it is not resolved unless you explicitly use "--type
} // path". This should be explained more clearly again.
$query->execute(); $this->loadHardpoints(
$refs,
array(
ArcanistBrowseRef::HARDPOINT_URIS,
));
$zero_hits = array(); $zero_hits = array();
$open_uris = array(); $open_uris = array();
@ -221,10 +220,6 @@ EOTEXT
$ref->getToken())); $ref->getToken()));
} }
} }
foreach ($loaders as $loader) {
$loader->didFailToLoadBrowseURIRefs($refs);
}
} }
$uris = array(); $uris = array();

View file

@ -15,7 +15,7 @@ final class ArcanistBrowseRefInspector
'token.')); 'token.'));
} }
return id(new ArcanistBrowseRefPro()) return id(new ArcanistBrowseRef())
->setToken($argv[0]); ->setToken($argv[0]);
} }

View file

@ -15,7 +15,7 @@ final class ArcanistCommitRefInspector
'commit hash.')); 'commit hash.'));
} }
return id(new ArcanistCommitRefPro()) return id(new ArcanistCommitRef())
->setCommitHash($argv[0]); ->setCommitHash($argv[0]);
} }

View file

@ -16,10 +16,10 @@ final class ArcanistWorkingCopyStateRefInspector
} }
$commit_hash = $argv[0]; $commit_hash = $argv[0];
$commit_ref = id(new ArcanistCommitRefPro()) $commit_ref = id(new ArcanistCommitRef())
->setCommitHash($commit_hash); ->setCommitHash($commit_hash);
return id(new ArcanistWorkingCopyStateRefPro()) return id(new ArcanistWorkingCopyStateRef())
->setCommitRef($commit_ref); ->setCommitRef($commit_ref);
} }

View file

@ -5,12 +5,12 @@ final class ArcanistCommitUpstreamHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistCommitRefPro::HARDPOINT_UPSTREAM, ArcanistCommitRef::HARDPOINT_UPSTREAM,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistCommitRefPro); return ($ref instanceof ArcanistCommitRef);
} }
public function loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {

View file

@ -5,12 +5,12 @@ final class ArcanistGitCommitMessageHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistCommitRefPro::HARDPOINT_MESSAGE, ArcanistCommitRef::HARDPOINT_MESSAGE,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistCommitRefPro); return ($ref instanceof ArcanistCommitRef);
} }
public function loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {

View file

@ -5,19 +5,19 @@ final class ArcanistGitWorkingCopyRevisionHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistWorkingCopyStateRefPro::HARDPOINT_REVISIONREFS, ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistWorkingCopyStateRefPro); return ($ref instanceof ArcanistWorkingCopyStateRef);
} }
public function loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {
yield $this->yieldRequests( yield $this->yieldRequests(
$refs, $refs,
array( array(
ArcanistWorkingCopyStateRefPro::HARDPOINT_COMMITREF, ArcanistWorkingCopyStateRef::HARDPOINT_COMMITREF,
)); ));
$hashes = array(); $hashes = array();
@ -60,7 +60,7 @@ final class ArcanistGitWorkingCopyRevisionHardpointQuery
continue; continue;
} }
$revision_ref = ArcanistRevisionRefPro::newFromConduit($dict); $revision_ref = ArcanistRevisionRef::newFromConduit($dict);
foreach ($revision_hashes as $revision_hash) { foreach ($revision_hashes as $revision_hash) {
$hash_key = $this->getHashKey($revision_hash); $hash_key = $this->getHashKey($revision_hash);
$state_refs = idx($map, $hash_key, array()); $state_refs = idx($map, $hash_key, array());

View file

@ -5,19 +5,19 @@ final class ArcanistMessageRevisionHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistWorkingCopyStateRefPro::HARDPOINT_REVISIONREFS, ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistWorkingCopyStateRefPro); return ($ref instanceof ArcanistWorkingCopyStateRef);
} }
public function loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {
yield $this->yieldRequests( yield $this->yieldRequests(
$refs, $refs,
array( array(
ArcanistWorkingCopyStateRefPro::HARDPOINT_COMMITREF, ArcanistWorkingCopyStateRef::HARDPOINT_COMMITREF,
)); ));
$commit_refs = array(); $commit_refs = array();
@ -28,7 +28,7 @@ final class ArcanistMessageRevisionHardpointQuery
yield $this->yieldRequests( yield $this->yieldRequests(
$commit_refs, $commit_refs,
array( array(
ArcanistCommitRefPro::HARDPOINT_MESSAGE, ArcanistCommitRef::HARDPOINT_MESSAGE,
)); ));
$map = array(); $map = array();
@ -60,7 +60,7 @@ final class ArcanistMessageRevisionHardpointQuery
))); )));
foreach ($revisions as $dict) { foreach ($revisions as $dict) {
$revision_ref = ArcanistRevisionRefPro::newFromConduit($dict); $revision_ref = ArcanistRevisionRef::newFromConduit($dict);
$id = $dict['id']; $id = $dict['id'];
$state_refs = idx($map, $id, array()); $state_refs = idx($map, $id, array());

View file

@ -5,19 +5,19 @@ final class ArcanistWorkingCopyCommitHardpointQuery
public function getHardpoints() { public function getHardpoints() {
return array( return array(
ArcanistWorkingCopyStateRefPro::HARDPOINT_COMMITREF, ArcanistWorkingCopyStateRef::HARDPOINT_COMMITREF,
); );
} }
protected function canLoadRef(ArcanistRefPro $ref) { protected function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistWorkingCopyStateRefPro); return ($ref instanceof ArcanistWorkingCopyStateRef);
} }
public function loadHardpoint(array $refs, $hardpoint) { public function loadHardpoint(array $refs, $hardpoint) {
yield $this->yieldRequests( yield $this->yieldRequests(
$refs, $refs,
array( array(
ArcanistWorkingCopyStateRefPro::HARDPOINT_BRANCHREF, ArcanistWorkingCopyStateRef::HARDPOINT_BRANCHREF,
)); ));
$branch_refs = mpull($refs, 'getBranchRef'); $branch_refs = mpull($refs, 'getBranchRef');
@ -25,7 +25,7 @@ final class ArcanistWorkingCopyCommitHardpointQuery
yield $this->yieldRequests( yield $this->yieldRequests(
$branch_refs, $branch_refs,
array( array(
ArcanistBranchRefPro::HARDPOINT_COMMITREF, ArcanistBranchRef::HARDPOINT_COMMITREF,
)); ));
$results = array(); $results = array();

View file

@ -3,19 +3,19 @@
final class ArcanistBranchRef final class ArcanistBranchRef
extends ArcanistRef { extends ArcanistRef {
const HARDPOINT_COMMITREF = 'commitRef';
private $branchName; private $branchName;
private $refName; private $refName;
private $isCurrentBranch; private $isCurrentBranch;
public function getRefIdentifier() { public function getRefDisplayName() {
return pht('Branch %s', $this->getBranchName()); return pht('Branch %s', $this->getBranchName());
} }
public function defineHardpoints() { protected function newHardpoints() {
return array( return array(
'commitRef' => array( $this->newHardpoint(self::HARDPOINT_COMMITREF),
'type' => 'ArcanistCommitRef',
),
); );
} }
@ -47,11 +47,11 @@ final class ArcanistBranchRef
} }
public function attachCommitRef(ArcanistCommitRef $ref) { public function attachCommitRef(ArcanistCommitRef $ref) {
return $this->attachHardpoint('commitRef', $ref); return $this->attachHardpoint(self::HARDPOINT_COMMITREF, $ref);
} }
public function getCommitRef() { public function getCommitRef() {
return $this->getHardpoint('commitRef'); return $this->getHardpoint(self::HARDPOINT_COMMITREF);
} }
} }

View file

@ -1,57 +0,0 @@
<?php
final class ArcanistBranchRefPro
extends ArcanistRefPro {
const HARDPOINT_COMMITREF = 'commitRef';
private $branchName;
private $refName;
private $isCurrentBranch;
public function getRefDisplayName() {
return pht('Branch %s', $this->getBranchName());
}
protected function newHardpoints() {
return array(
$this->newHardpoint(self::HARDPOINT_COMMITREF),
);
}
public function setBranchName($branch_name) {
$this->branchName = $branch_name;
return $this;
}
public function getBranchName() {
return $this->branchName;
}
public function setRefName($ref_name) {
$this->refName = $ref_name;
return $this;
}
public function getRefName() {
return $this->refName;
}
public function setIsCurrentBranch($is_current_branch) {
$this->isCurrentBranch = $is_current_branch;
return $this;
}
public function getIsCurrentBranch() {
return $this->isCurrentBranch;
}
public function attachCommitRef(ArcanistCommitRef $ref) {
return $this->attachHardpoint(self::HARDPOINT_COMMITREF, $ref);
}
public function getCommitRef() {
return $this->getHardpoint(self::HARDPOINT_COMMITREF);
}
}

View file

@ -9,18 +9,17 @@ final class ArcanistCommitRef
private $authorEpoch; private $authorEpoch;
private $upstream; private $upstream;
public function getRefIdentifier() { const HARDPOINT_MESSAGE = 'message';
return pht('Commit %s', $this->getCommitHash()); const HARDPOINT_UPSTREAM = 'upstream';
public function getRefDisplayName() {
return pht('Commit "%s"', $this->getCommitHash());
} }
public function defineHardpoints() { protected function newHardpoints() {
return array( return array(
'message' => array( $this->newHardpoint(self::HARDPOINT_MESSAGE),
'type' => 'string', $this->newHardpoint(self::HARDPOINT_UPSTREAM),
),
'upstream' => array(
'type' => 'wild',
),
); );
} }
@ -70,11 +69,11 @@ final class ArcanistCommitRef
} }
public function attachMessage($message) { public function attachMessage($message) {
return $this->attachHardpoint('message', $message); return $this->attachHardpoint(self::HARDPOINT_MESSAGE, $message);
} }
public function getMessage() { public function getMessage() {
return $this->getHardpoint('message'); return $this->getHardpoint(self::HARDPOINT_MESSAGE);
} }
public function getURI() { public function getURI() {
@ -82,7 +81,7 @@ final class ArcanistCommitRef
} }
private function getUpstreamProperty($key, $default = null) { private function getUpstreamProperty($key, $default = null) {
$upstream = $this->getHardpoint('upstream'); $upstream = $this->getHardpoint(self::HARDPOINT_UPSTREAM);
if (!$upstream) { if (!$upstream) {
return $default; return $default;

View file

@ -1,93 +0,0 @@
<?php
final class ArcanistCommitRefPro
extends ArcanistRefPro {
private $commitHash;
private $treeHash;
private $commitEpoch;
private $authorEpoch;
private $upstream;
const HARDPOINT_MESSAGE = 'message';
const HARDPOINT_UPSTREAM = 'upstream';
public function getRefDisplayName() {
return pht('Commit "%s"', $this->getCommitHash());
}
protected function newHardpoints() {
return array(
$this->newHardpoint(self::HARDPOINT_MESSAGE),
$this->newHardpoint(self::HARDPOINT_UPSTREAM),
);
}
public function setCommitHash($commit_hash) {
$this->commitHash = $commit_hash;
return $this;
}
public function getCommitHash() {
return $this->commitHash;
}
public function setTreeHash($tree_hash) {
$this->treeHash = $tree_hash;
return $this;
}
public function getTreeHash() {
return $this->treeHash;
}
public function setCommitEpoch($commit_epoch) {
$this->commitEpoch = $commit_epoch;
return $this;
}
public function getCommitEpoch() {
return $this->commitEpoch;
}
public function setAuthorEpoch($author_epoch) {
$this->authorEpoch = $author_epoch;
return $this;
}
public function getAuthorEpoch() {
return $this->authorEpoch;
}
public function getSummary() {
$message = $this->getMessage();
$message = trim($message);
$lines = phutil_split_lines($message, false);
return head($lines);
}
public function attachMessage($message) {
return $this->attachHardpoint(self::HARDPOINT_MESSAGE, $message);
}
public function getMessage() {
return $this->getHardpoint(self::HARDPOINT_MESSAGE);
}
public function getURI() {
return $this->getUpstreamProperty('uri');
}
private function getUpstreamProperty($key, $default = null) {
$upstream = $this->getHardpoint(self::HARDPOINT_UPSTREAM);
if (!$upstream) {
return $default;
}
return idx($upstream, $key, $default);
}
}

View file

@ -1,106 +1,8 @@
<?php <?php
abstract class ArcanistRef abstract class ArcanistRef
extends Phobject { extends ArcanistHardpointObject {
private $hardpoints = array(); abstract public function getRefDisplayName();
abstract public function getRefIdentifier();
abstract public function defineHardpoints();
final public function hasHardpoint($hardpoint) {
$map = $this->getHardpointMap();
return isset($map[$hardpoint]);
}
final public function hasAttachedHardpoint($hardpoint) {
if (array_key_exists($hardpoint, $this->hardpoints)) {
return true;
}
return $this->canReadHardpoint($hardpoint);
}
final public function attachHardpoint($hardpoint, $value) {
if (!$this->hasHardpoint($hardpoint)) {
throw new Exception(pht('No hardpoint "%s".', $hardpoint));
}
$this->hardpoints[$hardpoint] = $value;
return $this;
}
final public function appendHardpoint($hardpoint, array $value) {
if (!$this->isVectorHardpoint($hardpoint)) {
throw new Exception(
pht(
'Hardpoint "%s" is not a vector hardpoint.',
$hardpoint));
}
if (!isset($this->hardpoints[$hardpoint])) {
$this->hardpoints[$hardpoint] = array();
}
$this->hardpoints[$hardpoint] = $this->mergeHardpoint(
$hardpoint,
$this->hardpoints[$hardpoint],
$value);
return $this;
}
protected function mergeHardpoint($hardpoint, array $src, array $new) {
foreach ($new as $value) {
$src[] = $value;
}
return $src;
}
final public function isVectorHardpoint($hardpoint) {
if (!$this->hasHardpoint($hardpoint)) {
return false;
}
$map = $this->getHardpointMap();
$spec = idx($map, $hardpoint, array());
return (idx($spec, 'vector') === true);
}
final public function getHardpoint($hardpoint) {
if (!$this->hasAttachedHardpoint($hardpoint)) {
if (!$this->hasHardpoint($hardpoint)) {
throw new Exception(
pht(
'Ref does not have hardpoint "%s"!',
$hardpoint));
} else {
throw new Exception(
pht(
'Hardpoint "%s" is not attached!',
$hardpoint));
}
}
if (array_key_exists($hardpoint, $this->hardpoints)) {
return $this->hardpoints[$hardpoint];
}
return $this->readHardpoint($hardpoint);
}
private function getHardpointMap() {
return $this->defineHardpoints();
}
protected function canReadHardpoint($hardpoint) {
return false;
}
protected function readHardpoint($hardpoint) {
throw new Exception(pht('Can not read hardpoint "%s".', $hardpoint));
}
} }

View file

@ -1,8 +0,0 @@
<?php
abstract class ArcanistRefPro
extends ArcanistHardpointObject {
abstract public function getRefDisplayName();
}

View file

@ -6,7 +6,7 @@ final class ArcanistRepositoryRef
private $phid; private $phid;
private $browseURI; private $browseURI;
public function getRefIdentifier() { public function getRefDisplayName() {
return pht('Remote Repository'); return pht('Remote Repository');
} }

View file

@ -6,7 +6,7 @@ final class ArcanistRevisionRef
private $parameters; private $parameters;
private $sources = array(); private $sources = array();
public function getRefIdentifier() { public function getRefDisplayName() {
return pht('Revision %s', $this->getMonogram()); return pht('Revision %s', $this->getMonogram());
} }
@ -52,6 +52,10 @@ final class ArcanistRevisionRef
return idx($this->parameters, 'id'); return idx($this->parameters, 'id');
} }
public function getPHID() {
return idx($this->parameters, 'phid');
}
public function getName() { public function getName() {
return idx($this->parameters, 'title'); return idx($this->parameters, 'title');
} }

View file

@ -1,76 +0,0 @@
<?php
final class ArcanistRevisionRefPro
extends ArcanistRefPro {
private $parameters;
private $sources = array();
public function getRefDisplayName() {
return pht('Revision %s', $this->getMonogram());
}
public function defineHardpoints() {
return array();
}
public static function newFromConduit(array $dict) {
$ref = new self();
$ref->parameters = $dict;
return $ref;
}
public function getMonogram() {
return 'D'.$this->getID();
}
public function getStatusDisplayName() {
return idx($this->parameters, 'statusName');
}
public function isClosed() {
// TODO: This should use sensible constants, not English language
// display text.
switch ($this->getStatusDisplayName()) {
case 'Abandoned':
case 'Closed':
return true;
}
return false;
}
public function getURI() {
return idx($this->parameters, 'uri');
}
public function getFullName() {
return pht('%s: %s', $this->getMonogram(), $this->getName());
}
public function getID() {
return idx($this->parameters, 'id');
}
public function getPHID() {
return idx($this->parameters, 'phid');
}
public function getName() {
return idx($this->parameters, 'title');
}
public function getAuthorPHID() {
return idx($this->parameters, 'authorPHID');
}
public function addSource(ArcanistRevisionRefSource $source) {
$this->sources[] = $source;
return $this;
}
public function getSources() {
return $this->sources;
}
}

View file

@ -3,56 +3,34 @@
final class ArcanistWorkingCopyStateRef final class ArcanistWorkingCopyStateRef
extends ArcanistRef { extends ArcanistRef {
private $rootDirectory; const HARDPOINT_COMMITREF = 'commitRef';
const HARDPOINT_REVISIONREFS = 'revisionRefs';
public function getRefIdentifier() { public function getRefDisplayName() {
// TODO: This could check attached hardpoints and render something more // TODO: This could check attached hardpoints and render something more
// insightful. // insightful.
return pht('Working Copy State'); return pht('Working Copy State');
} }
public function defineHardpoints() { protected function newHardpoints() {
$object_list = new ArcanistObjectListHardpoint();
return array( return array(
'commitRef' => array( $this->newHardpoint(self::HARDPOINT_COMMITREF),
'type' => 'ArcanistCommitRef', $this->newTemplateHardpoint(self::HARDPOINT_REVISIONREFS, $object_list),
),
'branchRef' => array(
'type' => 'ArcanistBranchRef',
),
'revisionRefs' => array(
'type' => 'ArcanistRevisionRef',
'vector' => true,
),
); );
} }
public function setRootDirectory($root_directory) { // TODO: This should be "attachCommitRef()".
$this->rootDirectory = $root_directory;
return $this;
}
public function getRootDirectory() {
return $this->rootDirectory;
}
public function attachBranchRef(ArcanistBranchRef $branch_ref) {
return $this->attachHardpoint('branchRef', $branch_ref);
}
public function getBranchRef() {
return $this->getHardpoint('branchRef');
}
public function setCommitRef(ArcanistCommitRef $commit_ref) { public function setCommitRef(ArcanistCommitRef $commit_ref) {
return $this->attachHardpoint('commitRef', $commit_ref); return $this->attachHardpoint(self::HARDPOINT_COMMITREF, $commit_ref);
} }
public function getCommitRef() { public function getCommitRef() {
return $this->getHardpoint('commitRef'); return $this->getHardpoint(self::HARDPOINT_COMMITREF);
} }
public function getRevisionRefs() { public function getRevisionRefs() {
return $this->getHardpoint('revisionRefs'); return $this->getHardpoint(self::HARDPOINT_REVISIONREFS);
} }
public function getRevisionRef() { public function getRevisionRef() {
@ -73,50 +51,4 @@ final class ArcanistWorkingCopyStateRef
return (count($this->getRevisionRefs()) > 1); return (count($this->getRevisionRefs()) > 1);
} }
protected function canReadHardpoint($hardpoint) {
switch ($hardpoint) {
case 'commitRef':
// If we have a branch ref, we can try to read the commit ref from the
// branch ref.
if ($this->hasAttachedHardpoint('branchRef')) {
if ($this->getBranchRef()->hasAttachedHardpoint('commitRef')) {
return true;
}
}
break;
}
return false;
}
protected function readHardpoint($hardpoint) {
switch ($hardpoint) {
case 'commitRef':
return $this->getBranchRef()->getCommitRef();
}
return parent::readHardpoint($hardpoint);
}
protected function mergeHardpoint($hardpoint, array $src, array $new) {
if ($hardpoint == 'revisionRefs') {
$src = mpull($src, null, 'getID');
$new = mpull($new, null, 'getID');
foreach ($new as $id => $ref) {
if (isset($src[$id])) {
foreach ($ref->getSources() as $source) {
$src[$id]->addSource($source);
}
} else {
$src[$id] = $ref;
}
}
return array_values($src);
}
return parent::mergeHardpoint($hardpoint, $src, $new);
}
} }

View file

@ -1,54 +0,0 @@
<?php
final class ArcanistWorkingCopyStateRefPro
extends ArcanistRefPro {
const HARDPOINT_COMMITREF = 'commitRef';
const HARDPOINT_REVISIONREFS = 'revisionRefs';
public function getRefDisplayName() {
// TODO: This could check attached hardpoints and render something more
// insightful.
return pht('Working Copy State');
}
protected function newHardpoints() {
$object_list = new ArcanistObjectListHardpoint();
return array(
$this->newHardpoint(self::HARDPOINT_COMMITREF),
$this->newTemplateHardpoint(self::HARDPOINT_REVISIONREFS, $object_list),
);
}
// TODO: This should be "attachCommitRef()".
public function setCommitRef(ArcanistCommitRefPro $commit_ref) {
return $this->attachHardpoint(self::HARDPOINT_COMMITREF, $commit_ref);
}
public function getCommitRef() {
return $this->getHardpoint(self::HARDPOINT_COMMITREF);
}
public function getRevisionRefs() {
return $this->getHardpoint(self::HARDPOINT_REVISIONREFS);
}
public function getRevisionRef() {
if ($this->hasAmbiguousRevisionRefs()) {
throw new Exception(
pht('State has multiple ambiguous revisions refs.'));
}
$refs = $this->getRevisionRefs();
if ($refs) {
return head($refs);
}
return null;
}
public function hasAmbiguousRevisionRefs() {
return (count($this->getRevisionRefs()) > 1);
}
}

View file

@ -38,7 +38,7 @@ abstract class ArcanistWorkflowHardpointQuery
return false; return false;
} }
if (!$object instanceof ArcanistRefPro) { if (!$object instanceof ArcanistRef) {
return false; return false;
} }
@ -49,7 +49,7 @@ abstract class ArcanistWorkflowHardpointQuery
return true; return true;
} }
abstract protected function canLoadRef(ArcanistRefPro $ref); abstract protected function canLoadRef(ArcanistRef $ref);
final public function yieldConduit($method, array $parameters) { final public function yieldConduit($method, array $parameters) {
$conduit_engine = $this->getWorkflow() $conduit_engine = $this->getWorkflow()
@ -74,7 +74,7 @@ abstract class ArcanistWorkflowHardpointQuery
} }
final public function yieldValue(array $refs, $value) { final public function yieldValue(array $refs, $value) {
assert_instances_of($refs, 'ArcanistRefPro'); assert_instances_of($refs, 'ArcanistRef');
$keys = array_keys($refs); $keys = array_keys($refs);
$map = array_fill_keys($keys, $value); $map = array_fill_keys($keys, $value);

View file

@ -3051,18 +3051,23 @@ EOTEXT
} }
private function getDependsOnRevisionRef() { private function getDependsOnRevisionRef() {
// TODO: Restore this behavior after updating for toolsets. Loading the
// required hardpoints currently depends on a "WorkingCopy" existing.
return null;
$api = $this->getRepositoryAPI(); $api = $this->getRepositoryAPI();
$base_ref = $api->getBaseCommitRef(); $base_ref = $api->getBaseCommitRef();
$state_ref = $this->newWorkingCopyStateRef() $state_ref = id(new ArcanistWorkingCopyStateRef())
->setCommitRef($base_ref); ->setCommitRef($base_ref);
$this->newRefQuery(array($state_ref)) $this->loadHardpoints(
->needHardpoints( array(
array( $state_ref,
'revisionRefs', ),
)) array(
->execute(); ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS,
));
$revision_refs = $state_ref->getRevisionRefs(); $revision_refs = $state_ref->getRevisionRefs();
$viewer_phid = $this->getUserPHID(); $viewer_phid = $this->getUserPHID();

View file

@ -71,17 +71,22 @@ EOHELP
} }
$states = array(); $states = array();
foreach ($branches as $branch) { foreach ($branches as $branch_key => $branch) {
$states[] = $this->newWorkingCopyStateRef() $state_ref = id(new ArcanistWorkingCopyStateRef())
->attachBranchRef($branch); ->setCommitRef($branch->getCommitRef());
$states[] = array(
'branch' => $branch,
'state' => $state_ref,
);
} }
$this->newRefQuery($states) $this->loadHardpoints(
->needHardpoints( ipull($states, 'state'),
array( array(
'revisionRefs', ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS,
)) ));
->execute();
$this->printBranches($states); $this->printBranches($states);
@ -177,8 +182,9 @@ EOHELP
); );
$out = array(); $out = array();
foreach ($states as $state) { foreach ($states as $objects) {
$branch = $state->getBranchRef(); $state = $objects['state'];
$branch = $objects['branch'];
$revision = null; $revision = null;
if ($state->hasAmbiguousRevisionRefs()) { if ($state->hasAmbiguousRevisionRefs()) {

View file

@ -117,7 +117,7 @@ EOTEXT
return 0; return 0;
} }
private function describeRef(ArcanistRefPro $ref, $depth) { private function describeRef(ArcanistRef $ref, $depth) {
$indent = str_repeat(' ', $depth); $indent = str_repeat(' ', $depth);
$out = array(); $out = array();
@ -139,7 +139,7 @@ EOTEXT
} }
private function describeHardpoint( private function describeHardpoint(
ArcanistRefPro $ref, ArcanistRef $ref,
ArcanistHardpoint $hardpoint, ArcanistHardpoint $hardpoint,
$depth) { $depth) {
$indent = str_repeat(' ', $depth); $indent = str_repeat(' ', $depth);
@ -152,11 +152,11 @@ EOTEXT
$mode = '*'; $mode = '*';
$value = $ref->getHardpoint($hardpoint_key); $value = $ref->getHardpoint($hardpoint_key);
if ($value instanceof ArcanistRefPro) { if ($value instanceof ArcanistRef) {
$children[] = $value; $children[] = $value;
} else if (is_array($value)) { } else if (is_array($value)) {
foreach ($value as $key => $child) { foreach ($value as $key => $child) {
if ($child instanceof ArcanistRefPro) { if ($child instanceof ArcanistRef) {
$children[] = $child; $children[] = $child;
} else { } else {
$values[] = $value; $values[] = $value;

View file

@ -2250,15 +2250,6 @@ abstract class ArcanistWorkflow extends Phobject {
return $this->conduitEngine; return $this->conduitEngine;
} }
final protected function newWorkingCopyStateRef() {
$ref = new ArcanistWorkingCopyStateRef();
$working_copy = $this->getWorkingCopyIdentity();
$ref->setRootDirectory($working_copy->getProjectRoot());
return $ref;
}
final protected function newRefQuery(array $refs) { final protected function newRefQuery(array $refs) {
assert_instances_of($refs, 'ArcanistRef'); assert_instances_of($refs, 'ArcanistRef');