Changeset View
Changeset View
Standalone View
Standalone View
src/land/engine/ArcanistLandEngine.php
Show All 25 Lines | abstract class ArcanistLandEngine extends Phobject { | ||||
private $ontoRemote; | private $ontoRemote; | ||||
private $ontoRefs; | private $ontoRefs; | ||||
private $intoRemote; | private $intoRemote; | ||||
private $intoRef; | private $intoRef; | ||||
private $intoEmpty; | private $intoEmpty; | ||||
private $intoLocal; | private $intoLocal; | ||||
private $localState; | |||||
final public function setViewer($viewer) { | final public function setViewer($viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function getViewer() { | final public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | final public function setIntoArgument($into_argument) { | ||||
$this->intoArgument = $into_argument; | $this->intoArgument = $into_argument; | ||||
return $this; | return $this; | ||||
} | } | ||||
final public function getIntoArgument() { | final public function getIntoArgument() { | ||||
return $this->intoArgument; | return $this->intoArgument; | ||||
} | } | ||||
private function setLocalState(ArcanistRepositoryLocalState $local_state) { | |||||
$this->localState = $local_state; | |||||
return $this; | |||||
} | |||||
final protected function getLocalState() { | |||||
return $this->localState; | |||||
} | |||||
final protected function getOntoFromConfiguration() { | final protected function getOntoFromConfiguration() { | ||||
$config_key = $this->getOntoConfigurationKey(); | $config_key = $this->getOntoConfigurationKey(); | ||||
return $this->getWorkflow()->getConfig($config_key); | return $this->getWorkflow()->getConfig($config_key); | ||||
} | } | ||||
final protected function getOntoConfigurationKey() { | final protected function getOntoConfigurationKey() { | ||||
return 'arc.land.onto'; | return 'arc.land.onto'; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 958 Lines • ▼ Show 20 Lines | public function execute() { | ||||
$is_incremental = $this->getIsIncremental(); | $is_incremental = $this->getIsIncremental(); | ||||
$is_hold = $this->getShouldHold(); | $is_hold = $this->getShouldHold(); | ||||
$is_keep = $this->getShouldKeep(); | $is_keep = $this->getShouldKeep(); | ||||
$local_state = $api->newLocalState() | $local_state = $api->newLocalState() | ||||
->setWorkflow($workflow) | ->setWorkflow($workflow) | ||||
->saveLocalState(); | ->saveLocalState(); | ||||
$this->setLocalState($local_state); | |||||
$seen_into = array(); | $seen_into = array(); | ||||
try { | try { | ||||
$last_key = last_key($sets); | $last_key = last_key($sets); | ||||
$need_cascade = array(); | $need_cascade = array(); | ||||
$need_prune = array(); | $need_prune = array(); | ||||
foreach ($sets as $set_key => $set) { | foreach ($sets as $set_key => $set) { | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | try { | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if ($is_hold) { | if ($is_hold) { | ||||
$this->didHoldChanges($local_state); | $this->didHoldChanges($into_commit); | ||||
$local_state->discardLocalState(); | $local_state->discardLocalState(); | ||||
} else { | } else { | ||||
$this->reconcileLocalState($into_commit, $local_state); | |||||
} | |||||
// TODO: Restore this. | // TODO: Restore this. | ||||
// $this->getWorkflow()->askForRepositoryUpdate(); | // $this->getWorkflow()->askForRepositoryUpdate(); | ||||
// TODO: This is misleading under "--hold". | $this->reconcileLocalState($into_commit, $local_state); | ||||
$log->writeSuccess( | $log->writeSuccess( | ||||
pht('DONE'), | pht('DONE'), | ||||
pht('Landed changes.')); | pht('Landed changes.')); | ||||
} | |||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$local_state->restoreLocalState(); | $local_state->restoreLocalState(); | ||||
throw $ex; | throw $ex; | ||||
} catch (Throwable $ex) { | } catch (Throwable $ex) { | ||||
$local_state->restoreLocalState(); | $local_state->restoreLocalState(); | ||||
throw $ex; | throw $ex; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
abstract protected function pruneBranches(array $sets); | abstract protected function pruneBranches(array $sets); | ||||
abstract protected function reconcileLocalState( | abstract protected function reconcileLocalState( | ||||
$into_commit, | $into_commit, | ||||
ArcanistRepositoryLocalState $state); | ArcanistRepositoryLocalState $state); | ||||
abstract protected function didHoldChanges($into_commit); | |||||
private function selectMergeStrategy() { | private function selectMergeStrategy() { | ||||
$log = $this->getLogEngine(); | $log = $this->getLogEngine(); | ||||
$supported_strategies = array( | $supported_strategies = array( | ||||
'merge', | 'merge', | ||||
'squash', | 'squash', | ||||
); | ); | ||||
$supported_strategies = array_fuse($supported_strategies); | $supported_strategies = array_fuse($supported_strategies); | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |