Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | abstract class ArcanistWorkflow extends Phobject { | ||||
| private $command; | private $command; | ||||
| private $stashed; | private $stashed; | ||||
| private $shouldAmend; | private $shouldAmend; | ||||
| private $projectInfo; | private $projectInfo; | ||||
| private $repositoryInfo; | private $repositoryInfo; | ||||
| private $repositoryReasons; | private $repositoryReasons; | ||||
| private $repositoryRef; | |||||
| private $arcanistConfiguration; | private $arcanistConfiguration; | ||||
| private $parentWorkflow; | private $parentWorkflow; | ||||
| private $workingDirectory; | private $workingDirectory; | ||||
| private $repositoryVersion; | private $repositoryVersion; | ||||
| private $changeCache = array(); | private $changeCache = array(); | ||||
| private $conduitEngine; | |||||
| public function __construct() {} | public function __construct() {} | ||||
| abstract public function run(); | abstract public function run(); | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 497 Lines • ▼ Show 20 Lines | /* -( Conduit )------------------------------------------------------------ */ | ||||
| final protected function getParentWorkflow() { | final protected function getParentWorkflow() { | ||||
| return $this->parentWorkflow; | return $this->parentWorkflow; | ||||
| } | } | ||||
| final public function buildChildWorkflow($command, array $argv) { | final public function buildChildWorkflow($command, array $argv) { | ||||
| $arc_config = $this->getArcanistConfiguration(); | $arc_config = $this->getArcanistConfiguration(); | ||||
| $workflow = $arc_config->buildWorkflow($command); | $workflow = $arc_config->buildWorkflow($command); | ||||
| $workflow->setParentWorkflow($this); | $workflow->setParentWorkflow($this); | ||||
| $workflow->setConduitEngine($this->getConduitEngine()); | |||||
| $workflow->setCommand($command); | $workflow->setCommand($command); | ||||
| $workflow->setConfigurationManager($this->getConfigurationManager()); | $workflow->setConfigurationManager($this->getConfigurationManager()); | ||||
| if ($this->repositoryAPI) { | if ($this->repositoryAPI) { | ||||
| $workflow->setRepositoryAPI($this->repositoryAPI); | $workflow->setRepositoryAPI($this->repositoryAPI); | ||||
| } | } | ||||
| if ($this->userPHID) { | if ($this->userPHID) { | ||||
| ▲ Show 20 Lines • Show All 1,175 Lines • ▼ Show 20 Lines | /* -( Phabricator Repositories )------------------------------------------- */ | ||||
| */ | */ | ||||
| private function loadRepositoryInformation() { | private function loadRepositoryInformation() { | ||||
| list($query, $reasons) = $this->getRepositoryQuery(); | list($query, $reasons) = $this->getRepositoryQuery(); | ||||
| if (!$query) { | if (!$query) { | ||||
| return array(null, $reasons); | return array(null, $reasons); | ||||
| } | } | ||||
| try { | try { | ||||
| $results = $this->getConduit()->callMethodSynchronous( | $method = 'repository.query'; | ||||
| 'repository.query', | $results = $this->getConduitEngine()->newCall($method, $query) | ||||
| $query); | ->resolve(); | ||||
| } catch (ConduitClientException $ex) { | } catch (ConduitClientException $ex) { | ||||
| if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { | if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { | ||||
| $reasons[] = pht( | $reasons[] = pht( | ||||
| 'This version of Arcanist is more recent than the version of '. | 'This version of Arcanist is more recent than the version of '. | ||||
| 'Phabricator you are connecting to: the Phabricator install is '. | 'Phabricator you are connecting to: the Phabricator install is '. | ||||
| 'out of date and does not have support for identifying '. | 'out of date and does not have support for identifying '. | ||||
| 'repositories by callsign or URI. Update Phabricator to enable '. | 'repositories by callsign or URI. Update Phabricator to enable '. | ||||
| 'these features.'); | 'these features.'); | ||||
| ▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | private function getModernCommonDictionary(array $map) { | ||||
| foreach ($map as $key => $value) { | foreach ($map as $key => $value) { | ||||
| if ($value === null) { | if ($value === null) { | ||||
| unset($map[$key]); | unset($map[$key]); | ||||
| } | } | ||||
| } | } | ||||
| return $map; | return $map; | ||||
| } | } | ||||
| final public function setConduitEngine( | |||||
| ArcanistConduitEngine $conduit_engine) { | |||||
| $this->conduitEngine = $conduit_engine; | |||||
| return $this; | |||||
| } | |||||
| final public function getConduitEngine() { | |||||
| return $this->conduitEngine; | |||||
| } | |||||
| final protected function newWorkingCopyStateRef() { | |||||
| $ref = new ArcanistWorkingCopyStateRef(); | |||||
| $working_copy = $this->getWorkingCopy(); | |||||
| $ref->setRootDirectory($working_copy->getProjectRoot()); | |||||
| return $ref; | |||||
| } | |||||
| final protected function newRefQuery(array $refs) { | |||||
| assert_instances_of($refs, 'ArcanistRef'); | |||||
| $query = id(new ArcanistRefQuery()) | |||||
| ->setConduitEngine($this->getConduitEngine()) | |||||
| ->setRefs($refs); | |||||
| if ($this->hasRepositoryAPI()) { | |||||
| $query->setRepositoryAPI($this->getRepositoryAPI()); | |||||
| } | |||||
| $repository_ref = $this->getRepositoryRef(); | |||||
| if ($repository_ref) { | |||||
| $query->setRepositoryRef($repository_ref); | |||||
| } | |||||
| $working_copy = $this->getConfigurationManager()->getWorkingCopyIdentity(); | |||||
| if ($working_copy) { | |||||
| $working_ref = $this->newWorkingCopyStateRef(); | |||||
| $query->setWorkingCopyRef($working_ref); | |||||
| } | |||||
| return $query; | |||||
| } | |||||
| final public function getRepositoryRef() { | |||||
| if (!$this->getConfigurationManager()->getWorkingCopyIdentity()) { | |||||
| return null; | |||||
| } | |||||
| if (!$this->repositoryAPI) { | |||||
| return null; | |||||
| } | |||||
| if (!$this->repositoryRef) { | |||||
| $ref = id(new ArcanistRepositoryRef()) | |||||
| ->setPHID($this->getRepositoryPHID()) | |||||
| ->setBrowseURI($this->getRepositoryURI()); | |||||
| $this->repositoryRef = $ref; | |||||
| } | |||||
| return $this->repositoryRef; | |||||
| } | |||||
| } | } | ||||