diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4a63a96b..7c45ea87 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -437,6 +437,7 @@ phutil_register_library_map(array( 'ArcanistSubversionAPI' => 'repository/api/ArcanistSubversionAPI.php', 'ArcanistSubversionWorkingCopy' => 'workingcopy/ArcanistSubversionWorkingCopy.php', 'ArcanistSummaryLintRenderer' => 'lint/renderer/ArcanistSummaryLintRenderer.php', + 'ArcanistSymbolEngine' => 'ref/symbol/ArcanistSymbolEngine.php', 'ArcanistSymbolRef' => 'ref/symbol/ArcanistSymbolRef.php', 'ArcanistSyntaxErrorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistSyntaxErrorXHPASTLinterRule.php', 'ArcanistSystemConfigurationSource' => 'config/source/ArcanistSystemConfigurationSource.php', @@ -1381,7 +1382,10 @@ phutil_register_library_map(array( 'ArcanistReusedIteratorXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistRevertWorkflow' => 'ArcanistWorkflow', 'ArcanistRevisionCommitMessageHardpointQuery' => 'ArcanistWorkflowHardpointQuery', - 'ArcanistRevisionRef' => 'ArcanistRef', + 'ArcanistRevisionRef' => array( + 'ArcanistRef', + 'ArcanistDisplayRefInterface', + ), 'ArcanistRevisionRefSource' => 'Phobject', 'ArcanistRevisionSymbolHardpointQuery' => 'ArcanistWorkflowHardpointQuery', 'ArcanistRevisionSymbolRef' => 'ArcanistSymbolRef', @@ -1417,6 +1421,7 @@ phutil_register_library_map(array( 'ArcanistSubversionAPI' => 'ArcanistRepositoryAPI', 'ArcanistSubversionWorkingCopy' => 'ArcanistWorkingCopy', 'ArcanistSummaryLintRenderer' => 'ArcanistLintRenderer', + 'ArcanistSymbolEngine' => 'Phobject', 'ArcanistSymbolRef' => 'ArcanistRef', 'ArcanistSyntaxErrorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistSystemConfigurationSource' => 'ArcanistFilesystemConfigurationSource', diff --git a/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php b/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php index 2902f346..63d93c11 100644 --- a/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php +++ b/src/ref/commit/ArcanistGitCommitSymbolCommitHardpointQuery.php @@ -76,6 +76,17 @@ final class ArcanistGitCommitSymbolCommitHardpointQuery $results[$key] = $hash_map[$symbol]; } + foreach ($results as $key => $result) { + if ($result === null) { + continue; + } + + $ref = id(new ArcanistCommitRef()) + ->setCommitHash($result); + + $results[$key] = $ref; + } + yield $this->yieldMap($results); } diff --git a/src/ref/revision/ArcanistRevisionRef.php b/src/ref/revision/ArcanistRevisionRef.php index 33b9f0bb..d0f3321c 100644 --- a/src/ref/revision/ArcanistRevisionRef.php +++ b/src/ref/revision/ArcanistRevisionRef.php @@ -1,7 +1,9 @@ sources; } + public function getDisplayRefObjectName() { + return $this->getMonogram(); + } + + public function getDisplayRefTitle() { + return $this->getName(); + } + } diff --git a/src/ref/symbol/ArcanistSymbolEngine.php b/src/ref/symbol/ArcanistSymbolEngine.php new file mode 100644 index 00000000..e5a3c60f --- /dev/null +++ b/src/ref/symbol/ArcanistSymbolEngine.php @@ -0,0 +1,78 @@ +workflow = $workflow; + return $this; + } + + public function getWorkflow() { + return $this->workflow; + } + + public function loadRevisionForSymbol($symbol) { + $refs = $this->loadRevisionsForSymbols(array($symbol)); + return head($refs)->getObject(); + } + + public function loadRevisionsForSymbols(array $symbols) { + return $this->loadRefsForSymbols( + new ArcanistRevisionSymbolRef(), + $symbols); + } + + public function loadUserForSymbol($symbol) { + $refs = $this->loadUsersForSymbols(array($symbol)); + return head($refs)->getObject(); + } + + public function loadUsersForSymbols(array $symbols) { + return $this->loadRefsForSymbols( + new ArcanistUserSymbolRef(), + $symbols); + } + + public function loadCommitForSymbol($symbol) { + $refs = $this->loadCommitsForSymbols(array($symbol)); + return head($refs)->getObject(); + } + + public function loadCommitsForSymbols(array $symbols) { + return $this->loadRefsForSymbols( + new ArcanistCommitSymbolRef(), + $symbols); + } + + public function loadRefsForSymbols( + ArcanistSymbolRef $template, + array $symbols) { + + $refs = array(); + $load_refs = array(); + foreach ($symbols as $symbol) { + $ref = id(clone $template) + ->setSymbol($symbol); + + $ref_key = $ref->getSymbolEngineCacheKey(); + if (!isset($this->refs[$ref_key])) { + $this->refs[$ref_key] = $ref; + $load_refs[] = $ref; + } + + $refs[$symbol] = $ref; + } + + $workflow = $this->getWorkflow(); + if ($load_refs) { + $workflow->loadHardpoints($refs, ArcanistSymbolRef::HARDPOINT_OBJECT); + } + + return $refs; + } + +} diff --git a/src/ref/symbol/ArcanistSymbolRef.php b/src/ref/symbol/ArcanistSymbolRef.php index ef27f1b4..8ee5f3c4 100644 --- a/src/ref/symbol/ArcanistSymbolRef.php +++ b/src/ref/symbol/ArcanistSymbolRef.php @@ -4,6 +4,7 @@ abstract class ArcanistSymbolRef extends ArcanistRef { private $symbol; + private $cacheKey; const HARDPOINT_OBJECT = 'ref.symbol.object'; @@ -24,6 +25,27 @@ abstract class ArcanistSymbolRef return $this->symbol; } + final public function getSymbolEngineCacheKey() { + if ($this->cacheKey === null) { + $parts = array(); + $parts[] = sprintf('class(%s)', get_class($this)); + + foreach ($this->newCacheKeyParts() as $part) { + $parts[] = $part; + } + + $parts[] = $this->getSymbol(); + + $this->cacheKey = implode('.', $parts); + } + + return $this->cacheKey; + } + + protected function newCacheKeyParts() { + return array(); + } + final public function attachObject(ArcanistRef $object) { return $this->attachHardpoint(self::HARDPOINT_OBJECT, $object); } @@ -36,6 +58,4 @@ abstract class ArcanistSymbolRef return $symbol; } - - } diff --git a/src/ref/user/ArcanistUserRef.php b/src/ref/user/ArcanistUserRef.php index af4f37b2..c55fd8ff 100644 --- a/src/ref/user/ArcanistUserRef.php +++ b/src/ref/user/ArcanistUserRef.php @@ -34,8 +34,6 @@ final class ArcanistUserRef } public function getRealName() { - var_dump($this->parameters); - return idxv($this->parameters, array('fields', 'realName')); } diff --git a/src/ref/user/ArcanistUserSymbolRef.php b/src/ref/user/ArcanistUserSymbolRef.php index 527f0064..b293d08a 100644 --- a/src/ref/user/ArcanistUserSymbolRef.php +++ b/src/ref/user/ArcanistUserSymbolRef.php @@ -14,6 +14,12 @@ final class ArcanistUserSymbolRef return pht('User Symbol "%s"', $this->getSymbol()); } + protected function newCacheKeyParts() { + return array( + sprintf('type(%s)', $this->type), + ); + } + public function getSymbolType() { return $this->type; } diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 015b8170..807e6b40 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -76,7 +76,9 @@ abstract class ArcanistWorkflow extends Phobject { private $configurationEngine; private $configurationSourceList; + private $viewer; private $hardpointEngine; + private $symbolEngine; private $promptMap; final public function setToolset(ArcanistToolset $toolset) { @@ -2298,7 +2300,7 @@ abstract class ArcanistWorkflow extends Phobject { ->setExecutableFuture($future); } - final protected function loadHardpoints( + final public function loadHardpoints( $objects, $requests) { @@ -2401,4 +2403,32 @@ abstract class ArcanistWorkflow extends Phobject { return clone $prompt; } + final protected function getSymbolEngine() { + if ($this->symbolEngine === null) { + $this->symbolEngine = $this->newSymbolEngine(); + } + return $this->symbolEngine; + } + + private function newSymbolEngine() { + return id(new ArcanistSymbolEngine()) + ->setWorkflow($this); + } + + final protected function getViewer() { + if (!$this->viewer) { + $viewer = $this->getSymbolEngine() + ->loadUserForSymbol('viewer()'); + + // TODO: Deal with anonymous stuff. + if (!$viewer) { + throw new Exception(pht('No viewer!')); + } + + $this->viewer = $viewer; + } + + return $this->viewer; + } + }