From dc42f51cf70c21c117e3562a3ea9203c48beea43 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 11 Apr 2020 06:16:22 -0700 Subject: [PATCH] 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 ", "arc diff", searched for affected symbols. Maniphest Tasks: T11968 Differential Revision: https://secure.phabricator.com/D21082 --- src/__phutil_library_map__.php | 16 +-- .../ArcanistBrowseURIHardpointLoader.php | 4 - .../ArcanistBrowseCommitHardpointQuery.php | 8 +- .../ArcanistBrowseCommitURIHardpointQuery.php | 31 +----- .../ArcanistBrowsePathURIHardpointQuery.php | 54 ---------- ...rcanistBrowseRevisionURIHardpointQuery.php | 4 +- .../query/ArcanistBrowseURIHardpointQuery.php | 8 +- src/browse/ref/ArcanistBrowseRef.php | 23 ++-- src/browse/ref/ArcanistBrowseRefPro.php | 69 ------------ src/browse/ref/ArcanistBrowseURIRef.php | 2 +- src/browse/ref/ArcanistBrowseURIRefPro.php | 35 ------ .../workflow/ArcanistBrowseWorkflow.php | 31 +++--- src/inspector/ArcanistBrowseRefInspector.php | 2 +- src/inspector/ArcanistCommitRefInspector.php | 2 +- .../ArcanistWorkingCopyStateRefInspector.php | 4 +- .../ArcanistCommitUpstreamHardpointQuery.php | 6 +- ...ArcanistGitCommitMessageHardpointQuery.php | 6 +- ...stGitWorkingCopyRevisionHardpointQuery.php | 10 +- .../ArcanistMessageRevisionHardpointQuery.php | 12 +-- ...rcanistWorkingCopyCommitHardpointQuery.php | 10 +- src/ref/ArcanistBranchRef.php | 14 +-- src/ref/ArcanistBranchRefPro.php | 57 ---------- src/ref/ArcanistCommitRef.php | 23 ++-- src/ref/ArcanistCommitRefPro.php | 93 ---------------- src/ref/ArcanistRef.php | 102 +----------------- src/ref/ArcanistRefPro.php | 8 -- src/ref/ArcanistRepositoryRef.php | 2 +- src/ref/ArcanistRevisionRef.php | 6 +- src/ref/ArcanistRevisionRefPro.php | 76 ------------- src/ref/ArcanistWorkingCopyStateRef.php | 90 ++-------------- src/ref/ArcanistWorkingCopyStateRefPro.php | 54 ---------- .../query/ArcanistWorkflowHardpointQuery.php | 6 +- src/workflow/ArcanistDiffWorkflow.php | 19 ++-- src/workflow/ArcanistFeatureWorkflow.php | 28 +++-- src/workflow/ArcanistInspectWorkflow.php | 8 +- src/workflow/ArcanistWorkflow.php | 9 -- 36 files changed, 136 insertions(+), 796 deletions(-) delete mode 100644 src/browse/ref/ArcanistBrowseRefPro.php delete mode 100644 src/browse/ref/ArcanistBrowseURIRefPro.php delete mode 100644 src/ref/ArcanistBranchRefPro.php delete mode 100644 src/ref/ArcanistCommitRefPro.php delete mode 100644 src/ref/ArcanistRefPro.php delete mode 100644 src/ref/ArcanistRevisionRefPro.php delete mode 100644 src/ref/ArcanistWorkingCopyStateRefPro.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 518240e0..1bd187ab 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -54,7 +54,6 @@ phutil_register_library_map(array( 'ArcanistBraceFormattingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php', 'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php', 'ArcanistBranchRef' => 'ref/ArcanistBranchRef.php', - 'ArcanistBranchRefPro' => 'ref/ArcanistBranchRefPro.php', 'ArcanistBranchWorkflow' => 'workflow/ArcanistBranchWorkflow.php', 'ArcanistBrowseCommitHardpointLoader' => 'browse/loader/ArcanistBrowseCommitHardpointLoader.php', 'ArcanistBrowseCommitHardpointQuery' => 'browse/query/ArcanistBrowseCommitHardpointQuery.php', @@ -66,13 +65,11 @@ phutil_register_library_map(array( 'ArcanistBrowsePathURIHardpointQuery' => 'browse/query/ArcanistBrowsePathURIHardpointQuery.php', 'ArcanistBrowseRef' => 'browse/ref/ArcanistBrowseRef.php', 'ArcanistBrowseRefInspector' => 'inspector/ArcanistBrowseRefInspector.php', - 'ArcanistBrowseRefPro' => 'browse/ref/ArcanistBrowseRefPro.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', - 'ArcanistBrowseURIRefPro' => 'browse/ref/ArcanistBrowseURIRefPro.php', 'ArcanistBrowseWorkflow' => 'browse/workflow/ArcanistBrowseWorkflow.php', 'ArcanistBuildPlanRef' => 'ref/ArcanistBuildPlanRef.php', 'ArcanistBuildRef' => 'ref/ArcanistBuildRef.php', @@ -113,7 +110,6 @@ phutil_register_library_map(array( 'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistCommentStyleXHPASTLinterRuleTestCase.php', 'ArcanistCommitRef' => 'ref/ArcanistCommitRef.php', 'ArcanistCommitRefInspector' => 'inspector/ArcanistCommitRefInspector.php', - 'ArcanistCommitRefPro' => 'ref/ArcanistCommitRefPro.php', 'ArcanistCommitUpstreamHardpointLoader' => 'loader/ArcanistCommitUpstreamHardpointLoader.php', 'ArcanistCommitUpstreamHardpointQuery' => 'query/ArcanistCommitUpstreamHardpointQuery.php', 'ArcanistCommitWorkflow' => 'workflow/ArcanistCommitWorkflow.php', @@ -401,7 +397,6 @@ phutil_register_library_map(array( 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase.php', 'ArcanistRef' => 'ref/ArcanistRef.php', 'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php', - 'ArcanistRefPro' => 'ref/ArcanistRefPro.php', 'ArcanistRefQuery' => 'ref/ArcanistRefQuery.php', 'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php', 'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php', @@ -415,7 +410,6 @@ phutil_register_library_map(array( 'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistReusedIteratorXHPASTLinterRuleTestCase.php', 'ArcanistRevertWorkflow' => 'workflow/ArcanistRevertWorkflow.php', 'ArcanistRevisionRef' => 'ref/ArcanistRevisionRef.php', - 'ArcanistRevisionRefPro' => 'ref/ArcanistRevisionRefPro.php', 'ArcanistRevisionRefSource' => 'ref/ArcanistRevisionRefSource.php', 'ArcanistRuboCopLinter' => 'lint/linter/ArcanistRuboCopLinter.php', 'ArcanistRuboCopLinterTestCase' => 'lint/linter/__tests__/ArcanistRuboCopLinterTestCase.php', @@ -521,7 +515,6 @@ phutil_register_library_map(array( 'ArcanistWorkingCopyPath' => 'workingcopy/ArcanistWorkingCopyPath.php', 'ArcanistWorkingCopyStateRef' => 'ref/ArcanistWorkingCopyStateRef.php', 'ArcanistWorkingCopyStateRefInspector' => 'inspector/ArcanistWorkingCopyStateRefInspector.php', - 'ArcanistWorkingCopyStateRefPro' => 'ref/ArcanistWorkingCopyStateRefPro.php', 'ArcanistXHPASTLintNamingHook' => 'lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php', 'ArcanistXHPASTLintNamingHookTestCase' => 'lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php', 'ArcanistXHPASTLintSwitchHook' => 'lint/linter/xhpast/ArcanistXHPASTLintSwitchHook.php', @@ -1037,7 +1030,6 @@ phutil_register_library_map(array( 'ArcanistBraceFormattingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistBranchRef' => 'ArcanistRef', - 'ArcanistBranchRefPro' => 'ArcanistRefPro', 'ArcanistBranchWorkflow' => 'ArcanistFeatureWorkflow', 'ArcanistBrowseCommitHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistBrowseCommitHardpointQuery' => 'ArcanistWorkflowHardpointQuery', @@ -1049,13 +1041,11 @@ phutil_register_library_map(array( 'ArcanistBrowsePathURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery', 'ArcanistBrowseRef' => 'ArcanistRef', 'ArcanistBrowseRefInspector' => 'ArcanistRefInspector', - 'ArcanistBrowseRefPro' => 'ArcanistRefPro', 'ArcanistBrowseRevisionURIHardpointLoader' => 'ArcanistBrowseURIHardpointLoader', 'ArcanistBrowseRevisionURIHardpointQuery' => 'ArcanistBrowseURIHardpointQuery', 'ArcanistBrowseURIHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistBrowseURIHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistBrowseURIRef' => 'ArcanistRef', - 'ArcanistBrowseURIRefPro' => 'ArcanistRefPro', 'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow', 'ArcanistBuildPlanRef' => 'Phobject', 'ArcanistBuildRef' => 'Phobject', @@ -1096,7 +1086,6 @@ phutil_register_library_map(array( 'ArcanistCommentStyleXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistCommitRef' => 'ArcanistRef', 'ArcanistCommitRefInspector' => 'ArcanistRefInspector', - 'ArcanistCommitRefPro' => 'ArcanistRefPro', 'ArcanistCommitUpstreamHardpointLoader' => 'ArcanistHardpointLoader', 'ArcanistCommitUpstreamHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistCommitWorkflow' => 'ArcanistWorkflow', @@ -1382,9 +1371,8 @@ phutil_register_library_map(array( 'ArcanistPyLintLinterTestCase' => 'ArcanistExternalLinterTestCase', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', - 'ArcanistRef' => 'Phobject', + 'ArcanistRef' => 'ArcanistHardpointObject', 'ArcanistRefInspector' => 'Phobject', - 'ArcanistRefPro' => 'ArcanistHardpointObject', 'ArcanistRefQuery' => 'Phobject', 'ArcanistRepositoryAPI' => 'Phobject', 'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase', @@ -1398,7 +1386,6 @@ phutil_register_library_map(array( 'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistRevertWorkflow' => 'ArcanistWorkflow', 'ArcanistRevisionRef' => 'ArcanistRef', - 'ArcanistRevisionRefPro' => 'ArcanistRefPro', 'ArcanistRevisionRefSource' => 'Phobject', 'ArcanistRuboCopLinter' => 'ArcanistExternalLinter', 'ArcanistRuboCopLinterTestCase' => 'ArcanistExternalLinterTestCase', @@ -1503,7 +1490,6 @@ phutil_register_library_map(array( 'ArcanistWorkingCopyPath' => 'Phobject', 'ArcanistWorkingCopyStateRef' => 'ArcanistRef', 'ArcanistWorkingCopyStateRefInspector' => 'ArcanistRefInspector', - 'ArcanistWorkingCopyStateRefPro' => 'ArcanistRefPro', 'ArcanistXHPASTLintNamingHook' => 'Phobject', 'ArcanistXHPASTLintNamingHookTestCase' => 'PhutilTestCase', 'ArcanistXHPASTLintSwitchHook' => 'Phobject', diff --git a/src/browse/loader/ArcanistBrowseURIHardpointLoader.php b/src/browse/loader/ArcanistBrowseURIHardpointLoader.php index ab328fa5..5b074caa 100644 --- a/src/browse/loader/ArcanistBrowseURIHardpointLoader.php +++ b/src/browse/loader/ArcanistBrowseURIHardpointLoader.php @@ -19,10 +19,6 @@ abstract class ArcanistBrowseURIHardpointLoader return ($hardpoint == 'uris'); } - public function willLoadBrowseURIRefs(array $refs) { - return; - } - public function didFailToLoadBrowseURIRefs(array $refs) { return; } diff --git a/src/browse/query/ArcanistBrowseCommitHardpointQuery.php b/src/browse/query/ArcanistBrowseCommitHardpointQuery.php index 5be53b1a..37fbaf83 100644 --- a/src/browse/query/ArcanistBrowseCommitHardpointQuery.php +++ b/src/browse/query/ArcanistBrowseCommitHardpointQuery.php @@ -5,12 +5,12 @@ final class ArcanistBrowseCommitHardpointQuery public function getHardpoints() { return array( - ArcanistBrowseRefPro::HARDPOINT_COMMITREFS, + ArcanistBrowseRef::HARDPOINT_COMMITREFS, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistBrowseRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistBrowseRef); } public function loadHardpoint(array $refs, $hardpoint) { @@ -53,7 +53,7 @@ final class ArcanistBrowseCommitHardpointQuery $results = array(); foreach ($commit_map as $commit_identifier => $ref_keys) { foreach ($ref_keys as $key) { - $commit_ref = id(new ArcanistCommitRefPro()) + $commit_ref = id(new ArcanistCommitRef()) ->setCommitHash($commit_identifier); $results[$key][] = $commit_ref; } diff --git a/src/browse/query/ArcanistBrowseCommitURIHardpointQuery.php b/src/browse/query/ArcanistBrowseCommitURIHardpointQuery.php index f423abd7..7567456c 100644 --- a/src/browse/query/ArcanistBrowseCommitURIHardpointQuery.php +++ b/src/browse/query/ArcanistBrowseCommitURIHardpointQuery.php @@ -5,33 +5,6 @@ final class ArcanistBrowseCommitURIHardpointQuery 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) { $refs = $this->getRefsWithSupportedTypes($refs); if (!$refs) { @@ -41,7 +14,7 @@ final class ArcanistBrowseCommitURIHardpointQuery yield $this->yieldRequests( $refs, array( - ArcanistBrowseRefPro::HARDPOINT_COMMITREFS, + ArcanistBrowseRef::HARDPOINT_COMMITREFS, )); $commit_refs = array(); @@ -54,7 +27,7 @@ final class ArcanistBrowseCommitURIHardpointQuery yield $this->yieldRequests( $commit_refs, array( - ArcanistCommitRefPro::HARDPOINT_UPSTREAM, + ArcanistCommitRef::HARDPOINT_UPSTREAM, )); $results = array(); diff --git a/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php b/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php index ac7dacc8..f6faec2b 100644 --- a/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php +++ b/src/browse/query/ArcanistBrowsePathURIHardpointQuery.php @@ -5,60 +5,6 @@ final class ArcanistBrowsePathURIHardpointQuery 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) { $refs = $this->getRefsWithSupportedTypes($refs); if (!$refs) { diff --git a/src/browse/query/ArcanistBrowseRevisionURIHardpointQuery.php b/src/browse/query/ArcanistBrowseRevisionURIHardpointQuery.php index b314fc70..13e87336 100644 --- a/src/browse/query/ArcanistBrowseRevisionURIHardpointQuery.php +++ b/src/browse/query/ArcanistBrowseRevisionURIHardpointQuery.php @@ -14,7 +14,7 @@ final class ArcanistBrowseRevisionURIHardpointQuery yield $this->yieldRequests( $refs, array( - ArcanistBrowseRefPro::HARDPOINT_COMMITREFS, + ArcanistBrowseRef::HARDPOINT_COMMITREFS, )); $states = array(); @@ -22,7 +22,7 @@ final class ArcanistBrowseRevisionURIHardpointQuery foreach ($refs as $key => $ref) { foreach ($ref->getCommitRefs() as $commit_ref) { $hash = $commit_ref->getCommitHash(); - $states[$hash] = id(new ArcanistWorkingCopyStateRefPro()) + $states[$hash] = id(new ArcanistWorkingCopyStateRef()) ->setCommitRef($commit_ref); $map[$hash][] = $key; } diff --git a/src/browse/query/ArcanistBrowseURIHardpointQuery.php b/src/browse/query/ArcanistBrowseURIHardpointQuery.php index 0f164edb..52494506 100644 --- a/src/browse/query/ArcanistBrowseURIHardpointQuery.php +++ b/src/browse/query/ArcanistBrowseURIHardpointQuery.php @@ -9,12 +9,12 @@ abstract class ArcanistBrowseURIHardpointQuery public function getHardpoints() { return array( - ArcanistBrowseRefPro::HARDPOINT_URIS, + ArcanistBrowseRef::HARDPOINT_URIS, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistBrowseRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistBrowseRef); } public function getRefsWithSupportedTypes(array $refs) { @@ -42,7 +42,7 @@ abstract class ArcanistBrowseURIHardpointQuery } final protected function newBrowseURIRef() { - return id(new ArcanistBrowseURIRefPro()) + return id(new ArcanistBrowseURIRef()) ->setType($this->getSupportedBrowseType()); } diff --git a/src/browse/ref/ArcanistBrowseRef.php b/src/browse/ref/ArcanistBrowseRef.php index f07c4b2c..f27def01 100644 --- a/src/browse/ref/ArcanistBrowseRef.php +++ b/src/browse/ref/ArcanistBrowseRef.php @@ -3,24 +3,21 @@ final class ArcanistBrowseRef extends ArcanistRef { + const HARDPOINT_URIS = 'uris'; + const HARDPOINT_COMMITREFS = 'commitRefs'; + private $token; - private $types; + private $types = array(); private $branch; - public function getRefIdentifier() { + public function getRefDisplayName() { return pht('Browse Query "%s"', $this->getToken()); } - public function defineHardpoints() { + protected function newHardpoints() { return array( - 'commitRefs' => array( - 'type' => 'ArcanistCommitRef', - 'vector' => true, - ), - 'uris' => array( - 'type' => 'ArcanistBrowseURIRef', - 'vector' => true, - ), + $this->newVectorHardpoint(self::HARDPOINT_COMMITREFS), + $this->newVectorHardpoint(self::HARDPOINT_URIS), ); } @@ -62,11 +59,11 @@ final class ArcanistBrowseRef } public function getURIs() { - return $this->getHardpoint('uris'); + return $this->getHardpoint(self::HARDPOINT_URIS); } public function getCommitRefs() { - return $this->getHardpoint('commitRefs'); + return $this->getHardpoint(self::HARDPOINT_COMMITREFS); } } diff --git a/src/browse/ref/ArcanistBrowseRefPro.php b/src/browse/ref/ArcanistBrowseRefPro.php deleted file mode 100644 index 93729965..00000000 --- a/src/browse/ref/ArcanistBrowseRefPro.php +++ /dev/null @@ -1,69 +0,0 @@ -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); - } - -} diff --git a/src/browse/ref/ArcanistBrowseURIRef.php b/src/browse/ref/ArcanistBrowseURIRef.php index 9444d2e0..e5ac2314 100644 --- a/src/browse/ref/ArcanistBrowseURIRef.php +++ b/src/browse/ref/ArcanistBrowseURIRef.php @@ -6,7 +6,7 @@ final class ArcanistBrowseURIRef private $uri; private $type; - public function getRefIdentifier() { + public function getRefDisplayName() { return pht('Browse URI "%s"', $this->getURI()); } diff --git a/src/browse/ref/ArcanistBrowseURIRefPro.php b/src/browse/ref/ArcanistBrowseURIRefPro.php deleted file mode 100644 index 210f3e68..00000000 --- a/src/browse/ref/ArcanistBrowseURIRefPro.php +++ /dev/null @@ -1,35 +0,0 @@ -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; - } - -} diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php index 331c06d0..50e1b127 100644 --- a/src/browse/workflow/ArcanistBrowseWorkflow.php +++ b/src/browse/workflow/ArcanistBrowseWorkflow.php @@ -107,23 +107,22 @@ EOTEXT } } - $loaders = ArcanistBrowseURIHardpointLoader::getAllBrowseLoaders(); - foreach ($loaders as $key => $loader) { - $loaders[$key] = clone $loader; - } + // TODO: The "Path" and "Commit" queries should regain the ability to warn + // when this command is not run in a working copy that belongs to a + // recognized repository, so they won't ever be able to resolve things. - $query = $this->newRefQuery($refs) - ->needHardpoints( - array( - 'uris', - )) - ->setLoaders($loaders); + // TODO: When you run "arc browse" with no arguments, we should either + // take you to the repository home page or show help. - foreach ($loaders as $loader) { - $loader->willLoadBrowseURIRefs($refs); - } + // TODO: When you "arc browse something/like/a/path.c" but it does not + // 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(); $open_uris = array(); @@ -221,10 +220,6 @@ EOTEXT $ref->getToken())); } } - - foreach ($loaders as $loader) { - $loader->didFailToLoadBrowseURIRefs($refs); - } } $uris = array(); diff --git a/src/inspector/ArcanistBrowseRefInspector.php b/src/inspector/ArcanistBrowseRefInspector.php index d3725572..21fa4b9b 100644 --- a/src/inspector/ArcanistBrowseRefInspector.php +++ b/src/inspector/ArcanistBrowseRefInspector.php @@ -15,7 +15,7 @@ final class ArcanistBrowseRefInspector 'token.')); } - return id(new ArcanistBrowseRefPro()) + return id(new ArcanistBrowseRef()) ->setToken($argv[0]); } diff --git a/src/inspector/ArcanistCommitRefInspector.php b/src/inspector/ArcanistCommitRefInspector.php index 5190e155..07ffb4f1 100644 --- a/src/inspector/ArcanistCommitRefInspector.php +++ b/src/inspector/ArcanistCommitRefInspector.php @@ -15,7 +15,7 @@ final class ArcanistCommitRefInspector 'commit hash.')); } - return id(new ArcanistCommitRefPro()) + return id(new ArcanistCommitRef()) ->setCommitHash($argv[0]); } diff --git a/src/inspector/ArcanistWorkingCopyStateRefInspector.php b/src/inspector/ArcanistWorkingCopyStateRefInspector.php index 3651c632..a08a3265 100644 --- a/src/inspector/ArcanistWorkingCopyStateRefInspector.php +++ b/src/inspector/ArcanistWorkingCopyStateRefInspector.php @@ -16,10 +16,10 @@ final class ArcanistWorkingCopyStateRefInspector } $commit_hash = $argv[0]; - $commit_ref = id(new ArcanistCommitRefPro()) + $commit_ref = id(new ArcanistCommitRef()) ->setCommitHash($commit_hash); - return id(new ArcanistWorkingCopyStateRefPro()) + return id(new ArcanistWorkingCopyStateRef()) ->setCommitRef($commit_ref); } diff --git a/src/query/ArcanistCommitUpstreamHardpointQuery.php b/src/query/ArcanistCommitUpstreamHardpointQuery.php index a2b92926..b6020e7e 100644 --- a/src/query/ArcanistCommitUpstreamHardpointQuery.php +++ b/src/query/ArcanistCommitUpstreamHardpointQuery.php @@ -5,12 +5,12 @@ final class ArcanistCommitUpstreamHardpointQuery public function getHardpoints() { return array( - ArcanistCommitRefPro::HARDPOINT_UPSTREAM, + ArcanistCommitRef::HARDPOINT_UPSTREAM, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistCommitRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistCommitRef); } public function loadHardpoint(array $refs, $hardpoint) { diff --git a/src/query/ArcanistGitCommitMessageHardpointQuery.php b/src/query/ArcanistGitCommitMessageHardpointQuery.php index 2f76e954..fd5b1659 100644 --- a/src/query/ArcanistGitCommitMessageHardpointQuery.php +++ b/src/query/ArcanistGitCommitMessageHardpointQuery.php @@ -5,12 +5,12 @@ final class ArcanistGitCommitMessageHardpointQuery public function getHardpoints() { return array( - ArcanistCommitRefPro::HARDPOINT_MESSAGE, + ArcanistCommitRef::HARDPOINT_MESSAGE, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistCommitRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistCommitRef); } public function loadHardpoint(array $refs, $hardpoint) { diff --git a/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php b/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php index 8029803b..065e8d57 100644 --- a/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php +++ b/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php @@ -5,19 +5,19 @@ final class ArcanistGitWorkingCopyRevisionHardpointQuery public function getHardpoints() { return array( - ArcanistWorkingCopyStateRefPro::HARDPOINT_REVISIONREFS, + ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistWorkingCopyStateRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistWorkingCopyStateRef); } public function loadHardpoint(array $refs, $hardpoint) { yield $this->yieldRequests( $refs, array( - ArcanistWorkingCopyStateRefPro::HARDPOINT_COMMITREF, + ArcanistWorkingCopyStateRef::HARDPOINT_COMMITREF, )); $hashes = array(); @@ -60,7 +60,7 @@ final class ArcanistGitWorkingCopyRevisionHardpointQuery continue; } - $revision_ref = ArcanistRevisionRefPro::newFromConduit($dict); + $revision_ref = ArcanistRevisionRef::newFromConduit($dict); foreach ($revision_hashes as $revision_hash) { $hash_key = $this->getHashKey($revision_hash); $state_refs = idx($map, $hash_key, array()); diff --git a/src/query/ArcanistMessageRevisionHardpointQuery.php b/src/query/ArcanistMessageRevisionHardpointQuery.php index 70ef8936..ab871a5d 100644 --- a/src/query/ArcanistMessageRevisionHardpointQuery.php +++ b/src/query/ArcanistMessageRevisionHardpointQuery.php @@ -5,19 +5,19 @@ final class ArcanistMessageRevisionHardpointQuery public function getHardpoints() { return array( - ArcanistWorkingCopyStateRefPro::HARDPOINT_REVISIONREFS, + ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistWorkingCopyStateRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistWorkingCopyStateRef); } public function loadHardpoint(array $refs, $hardpoint) { yield $this->yieldRequests( $refs, array( - ArcanistWorkingCopyStateRefPro::HARDPOINT_COMMITREF, + ArcanistWorkingCopyStateRef::HARDPOINT_COMMITREF, )); $commit_refs = array(); @@ -28,7 +28,7 @@ final class ArcanistMessageRevisionHardpointQuery yield $this->yieldRequests( $commit_refs, array( - ArcanistCommitRefPro::HARDPOINT_MESSAGE, + ArcanistCommitRef::HARDPOINT_MESSAGE, )); $map = array(); @@ -60,7 +60,7 @@ final class ArcanistMessageRevisionHardpointQuery ))); foreach ($revisions as $dict) { - $revision_ref = ArcanistRevisionRefPro::newFromConduit($dict); + $revision_ref = ArcanistRevisionRef::newFromConduit($dict); $id = $dict['id']; $state_refs = idx($map, $id, array()); diff --git a/src/query/ArcanistWorkingCopyCommitHardpointQuery.php b/src/query/ArcanistWorkingCopyCommitHardpointQuery.php index b20baf25..9f78d2af 100644 --- a/src/query/ArcanistWorkingCopyCommitHardpointQuery.php +++ b/src/query/ArcanistWorkingCopyCommitHardpointQuery.php @@ -5,19 +5,19 @@ final class ArcanistWorkingCopyCommitHardpointQuery public function getHardpoints() { return array( - ArcanistWorkingCopyStateRefPro::HARDPOINT_COMMITREF, + ArcanistWorkingCopyStateRef::HARDPOINT_COMMITREF, ); } - protected function canLoadRef(ArcanistRefPro $ref) { - return ($ref instanceof ArcanistWorkingCopyStateRefPro); + protected function canLoadRef(ArcanistRef $ref) { + return ($ref instanceof ArcanistWorkingCopyStateRef); } public function loadHardpoint(array $refs, $hardpoint) { yield $this->yieldRequests( $refs, array( - ArcanistWorkingCopyStateRefPro::HARDPOINT_BRANCHREF, + ArcanistWorkingCopyStateRef::HARDPOINT_BRANCHREF, )); $branch_refs = mpull($refs, 'getBranchRef'); @@ -25,7 +25,7 @@ final class ArcanistWorkingCopyCommitHardpointQuery yield $this->yieldRequests( $branch_refs, array( - ArcanistBranchRefPro::HARDPOINT_COMMITREF, + ArcanistBranchRef::HARDPOINT_COMMITREF, )); $results = array(); diff --git a/src/ref/ArcanistBranchRef.php b/src/ref/ArcanistBranchRef.php index 34a75017..067e5a2e 100644 --- a/src/ref/ArcanistBranchRef.php +++ b/src/ref/ArcanistBranchRef.php @@ -3,19 +3,19 @@ final class ArcanistBranchRef extends ArcanistRef { + const HARDPOINT_COMMITREF = 'commitRef'; + private $branchName; private $refName; private $isCurrentBranch; - public function getRefIdentifier() { + public function getRefDisplayName() { return pht('Branch %s', $this->getBranchName()); } - public function defineHardpoints() { + protected function newHardpoints() { return array( - 'commitRef' => array( - 'type' => 'ArcanistCommitRef', - ), + $this->newHardpoint(self::HARDPOINT_COMMITREF), ); } @@ -47,11 +47,11 @@ final class ArcanistBranchRef } public function attachCommitRef(ArcanistCommitRef $ref) { - return $this->attachHardpoint('commitRef', $ref); + return $this->attachHardpoint(self::HARDPOINT_COMMITREF, $ref); } public function getCommitRef() { - return $this->getHardpoint('commitRef'); + return $this->getHardpoint(self::HARDPOINT_COMMITREF); } } diff --git a/src/ref/ArcanistBranchRefPro.php b/src/ref/ArcanistBranchRefPro.php deleted file mode 100644 index 6998c2b1..00000000 --- a/src/ref/ArcanistBranchRefPro.php +++ /dev/null @@ -1,57 +0,0 @@ -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); - } - -} diff --git a/src/ref/ArcanistCommitRef.php b/src/ref/ArcanistCommitRef.php index 8058c74a..d5ff3cb7 100644 --- a/src/ref/ArcanistCommitRef.php +++ b/src/ref/ArcanistCommitRef.php @@ -9,18 +9,17 @@ final class ArcanistCommitRef private $authorEpoch; private $upstream; - public function getRefIdentifier() { - return pht('Commit %s', $this->getCommitHash()); + const HARDPOINT_MESSAGE = 'message'; + const HARDPOINT_UPSTREAM = 'upstream'; + + public function getRefDisplayName() { + return pht('Commit "%s"', $this->getCommitHash()); } - public function defineHardpoints() { + protected function newHardpoints() { return array( - 'message' => array( - 'type' => 'string', - ), - 'upstream' => array( - 'type' => 'wild', - ), + $this->newHardpoint(self::HARDPOINT_MESSAGE), + $this->newHardpoint(self::HARDPOINT_UPSTREAM), ); } @@ -70,11 +69,11 @@ final class ArcanistCommitRef } public function attachMessage($message) { - return $this->attachHardpoint('message', $message); + return $this->attachHardpoint(self::HARDPOINT_MESSAGE, $message); } public function getMessage() { - return $this->getHardpoint('message'); + return $this->getHardpoint(self::HARDPOINT_MESSAGE); } public function getURI() { @@ -82,7 +81,7 @@ final class ArcanistCommitRef } private function getUpstreamProperty($key, $default = null) { - $upstream = $this->getHardpoint('upstream'); + $upstream = $this->getHardpoint(self::HARDPOINT_UPSTREAM); if (!$upstream) { return $default; diff --git a/src/ref/ArcanistCommitRefPro.php b/src/ref/ArcanistCommitRefPro.php deleted file mode 100644 index c2b03be2..00000000 --- a/src/ref/ArcanistCommitRefPro.php +++ /dev/null @@ -1,93 +0,0 @@ -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); - } - -} diff --git a/src/ref/ArcanistRef.php b/src/ref/ArcanistRef.php index 2c1869cf..1577c22e 100644 --- a/src/ref/ArcanistRef.php +++ b/src/ref/ArcanistRef.php @@ -1,106 +1,8 @@ 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)); - } + abstract public function getRefDisplayName(); } diff --git a/src/ref/ArcanistRefPro.php b/src/ref/ArcanistRefPro.php deleted file mode 100644 index 8807d871..00000000 --- a/src/ref/ArcanistRefPro.php +++ /dev/null @@ -1,8 +0,0 @@ -getMonogram()); } @@ -52,6 +52,10 @@ final class ArcanistRevisionRef return idx($this->parameters, 'id'); } + public function getPHID() { + return idx($this->parameters, 'phid'); + } + public function getName() { return idx($this->parameters, 'title'); } diff --git a/src/ref/ArcanistRevisionRefPro.php b/src/ref/ArcanistRevisionRefPro.php deleted file mode 100644 index f8707211..00000000 --- a/src/ref/ArcanistRevisionRefPro.php +++ /dev/null @@ -1,76 +0,0 @@ -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; - } - -} diff --git a/src/ref/ArcanistWorkingCopyStateRef.php b/src/ref/ArcanistWorkingCopyStateRef.php index ad468518..7a141f16 100644 --- a/src/ref/ArcanistWorkingCopyStateRef.php +++ b/src/ref/ArcanistWorkingCopyStateRef.php @@ -3,56 +3,34 @@ final class ArcanistWorkingCopyStateRef 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 // insightful. return pht('Working Copy State'); } - public function defineHardpoints() { + protected function newHardpoints() { + $object_list = new ArcanistObjectListHardpoint(); return array( - 'commitRef' => array( - 'type' => 'ArcanistCommitRef', - ), - 'branchRef' => array( - 'type' => 'ArcanistBranchRef', - ), - 'revisionRefs' => array( - 'type' => 'ArcanistRevisionRef', - 'vector' => true, - ), + $this->newHardpoint(self::HARDPOINT_COMMITREF), + $this->newTemplateHardpoint(self::HARDPOINT_REVISIONREFS, $object_list), ); } - public function setRootDirectory($root_directory) { - $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'); - } - + // TODO: This should be "attachCommitRef()". public function setCommitRef(ArcanistCommitRef $commit_ref) { - return $this->attachHardpoint('commitRef', $commit_ref); + return $this->attachHardpoint(self::HARDPOINT_COMMITREF, $commit_ref); } public function getCommitRef() { - return $this->getHardpoint('commitRef'); + return $this->getHardpoint(self::HARDPOINT_COMMITREF); } public function getRevisionRefs() { - return $this->getHardpoint('revisionRefs'); + return $this->getHardpoint(self::HARDPOINT_REVISIONREFS); } public function getRevisionRef() { @@ -73,50 +51,4 @@ final class ArcanistWorkingCopyStateRef 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); - } - } diff --git a/src/ref/ArcanistWorkingCopyStateRefPro.php b/src/ref/ArcanistWorkingCopyStateRefPro.php deleted file mode 100644 index f6f0d810..00000000 --- a/src/ref/ArcanistWorkingCopyStateRefPro.php +++ /dev/null @@ -1,54 +0,0 @@ -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); - } - -} diff --git a/src/toolset/query/ArcanistWorkflowHardpointQuery.php b/src/toolset/query/ArcanistWorkflowHardpointQuery.php index fceafbdd..0246b2ce 100644 --- a/src/toolset/query/ArcanistWorkflowHardpointQuery.php +++ b/src/toolset/query/ArcanistWorkflowHardpointQuery.php @@ -38,7 +38,7 @@ abstract class ArcanistWorkflowHardpointQuery return false; } - if (!$object instanceof ArcanistRefPro) { + if (!$object instanceof ArcanistRef) { return false; } @@ -49,7 +49,7 @@ abstract class ArcanistWorkflowHardpointQuery return true; } - abstract protected function canLoadRef(ArcanistRefPro $ref); + abstract protected function canLoadRef(ArcanistRef $ref); final public function yieldConduit($method, array $parameters) { $conduit_engine = $this->getWorkflow() @@ -74,7 +74,7 @@ abstract class ArcanistWorkflowHardpointQuery } final public function yieldValue(array $refs, $value) { - assert_instances_of($refs, 'ArcanistRefPro'); + assert_instances_of($refs, 'ArcanistRef'); $keys = array_keys($refs); $map = array_fill_keys($keys, $value); diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 8fb324f4..06e755b1 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -3051,18 +3051,23 @@ EOTEXT } 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(); $base_ref = $api->getBaseCommitRef(); - $state_ref = $this->newWorkingCopyStateRef() + $state_ref = id(new ArcanistWorkingCopyStateRef()) ->setCommitRef($base_ref); - $this->newRefQuery(array($state_ref)) - ->needHardpoints( - array( - 'revisionRefs', - )) - ->execute(); + $this->loadHardpoints( + array( + $state_ref, + ), + array( + ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS, + )); $revision_refs = $state_ref->getRevisionRefs(); $viewer_phid = $this->getUserPHID(); diff --git a/src/workflow/ArcanistFeatureWorkflow.php b/src/workflow/ArcanistFeatureWorkflow.php index 2dfc97c5..8d995429 100644 --- a/src/workflow/ArcanistFeatureWorkflow.php +++ b/src/workflow/ArcanistFeatureWorkflow.php @@ -71,17 +71,22 @@ EOHELP } $states = array(); - foreach ($branches as $branch) { - $states[] = $this->newWorkingCopyStateRef() - ->attachBranchRef($branch); + foreach ($branches as $branch_key => $branch) { + $state_ref = id(new ArcanistWorkingCopyStateRef()) + ->setCommitRef($branch->getCommitRef()); + + $states[] = array( + 'branch' => $branch, + 'state' => $state_ref, + ); } - $this->newRefQuery($states) - ->needHardpoints( - array( - 'revisionRefs', - )) - ->execute(); + $this->loadHardpoints( + ipull($states, 'state'), + array( + ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS, + )); + $this->printBranches($states); @@ -177,8 +182,9 @@ EOHELP ); $out = array(); - foreach ($states as $state) { - $branch = $state->getBranchRef(); + foreach ($states as $objects) { + $state = $objects['state']; + $branch = $objects['branch']; $revision = null; if ($state->hasAmbiguousRevisionRefs()) { diff --git a/src/workflow/ArcanistInspectWorkflow.php b/src/workflow/ArcanistInspectWorkflow.php index 52e0df7c..7cd7fd81 100644 --- a/src/workflow/ArcanistInspectWorkflow.php +++ b/src/workflow/ArcanistInspectWorkflow.php @@ -117,7 +117,7 @@ EOTEXT return 0; } - private function describeRef(ArcanistRefPro $ref, $depth) { + private function describeRef(ArcanistRef $ref, $depth) { $indent = str_repeat(' ', $depth); $out = array(); @@ -139,7 +139,7 @@ EOTEXT } private function describeHardpoint( - ArcanistRefPro $ref, + ArcanistRef $ref, ArcanistHardpoint $hardpoint, $depth) { $indent = str_repeat(' ', $depth); @@ -152,11 +152,11 @@ EOTEXT $mode = '*'; $value = $ref->getHardpoint($hardpoint_key); - if ($value instanceof ArcanistRefPro) { + if ($value instanceof ArcanistRef) { $children[] = $value; } else if (is_array($value)) { foreach ($value as $key => $child) { - if ($child instanceof ArcanistRefPro) { + if ($child instanceof ArcanistRef) { $children[] = $child; } else { $values[] = $value; diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index fd6fa20f..373c25dc 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -2250,15 +2250,6 @@ abstract class ArcanistWorkflow extends Phobject { 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) { assert_instances_of($refs, 'ArcanistRef');