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',
'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',

View file

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

View file

@ -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;
}

View file

@ -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();

View file

@ -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) {

View file

@ -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;
}

View file

@ -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());
}

View file

@ -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);
}
}

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 $type;
public function getRefIdentifier() {
public function getRefDisplayName() {
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();
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();

View file

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

View file

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

View file

@ -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);
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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());

View file

@ -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());

View file

@ -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();

View file

@ -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);
}
}

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 $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;

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
abstract class ArcanistRef
extends Phobject {
extends ArcanistHardpointObject {
private $hardpoints = array();
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));
}
abstract public function getRefDisplayName();
}

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 $browseURI;
public function getRefIdentifier() {
public function getRefDisplayName() {
return pht('Remote Repository');
}

View file

@ -6,7 +6,7 @@ final class ArcanistRevisionRef
private $parameters;
private $sources = array();
public function getRefIdentifier() {
public function getRefDisplayName() {
return pht('Revision %s', $this->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');
}

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
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);
}
}

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;
}
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);

View file

@ -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();

View file

@ -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()) {

View file

@ -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;

View file

@ -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');