Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistLandWorkflow.php
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | return array( | ||||
'actually modify or land the commits.'), | 'actually modify or land the commits.'), | ||||
), | ), | ||||
'*' => 'branch', | '*' => 'branch', | ||||
); | ); | ||||
} | } | ||||
public function run() { | public function run() { | ||||
$this->readArguments(); | $this->readArguments(); | ||||
$engine = null; | |||||
if ($this->isGit && !$this->isGitSvn) { | |||||
$engine = new ArcanistGitLandEngine(); | |||||
} | |||||
if ($engine) { | |||||
$obsolete = array( | |||||
'delete-remote', | |||||
'update-with-merge', | |||||
'update-with-rebase', | |||||
); | |||||
foreach ($obsolete as $flag) { | |||||
if ($this->getArgument($flag)) { | |||||
throw new ArcanistUsageException( | |||||
pht( | |||||
'Flag "%s" is no longer supported under Git.', | |||||
'--'.$flag)); | |||||
} | |||||
} | |||||
$this->requireCleanWorkingCopy(); | |||||
$should_hold = $this->getArgument('hold'); | |||||
$engine | |||||
->setWorkflow($this) | |||||
->setRepositoryAPI($this->getRepositoryAPI()) | |||||
->setSourceRef($this->branch) | |||||
->setTargetRemote($this->remote) | |||||
->setTargetOnto($this->onto) | |||||
->setShouldHold($should_hold) | |||||
->setShouldKeep($this->keepBranch) | |||||
->setShouldSquash($this->useSquash) | |||||
->setShouldPreview($this->preview) | |||||
->setBuildMessageCallback(array($this, 'buildEngineMessage')); | |||||
$engine->execute(); | |||||
if (!$should_hold) { | |||||
$this->didPush(); | |||||
} | |||||
return 0; | |||||
} | |||||
$this->validate(); | $this->validate(); | ||||
try { | try { | ||||
$this->pullFromRemote(); | $this->pullFromRemote(); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$this->restoreBranch(); | $this->restoreBranch(); | ||||
throw $ex; | throw $ex; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 873 Lines • ▼ Show 20 Lines | if ($this->getArgument('hold')) { | ||||
$cmd, | $cmd, | ||||
'arc land')); | 'arc land')); | ||||
} | } | ||||
throw new ArcanistUsageException(pht( | throw new ArcanistUsageException(pht( | ||||
"'%s' failed! Fix the error and push this change manually.", | "'%s' failed! Fix the error and push this change manually.", | ||||
$cmd)); | $cmd)); | ||||
} | } | ||||
$this->askForRepositoryUpdate(); | $this->didPush(); | ||||
$mark_workflow = $this->buildChildWorkflow( | |||||
'close-revision', | |||||
array( | |||||
'--finalize', | |||||
'--quiet', | |||||
$this->revision['id'], | |||||
)); | |||||
$mark_workflow->run(); | |||||
echo "\n"; | echo "\n"; | ||||
} | } | ||||
} | } | ||||
private function executeCleanupAfterFailedPush() { | private function executeCleanupAfterFailedPush() { | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
if ($this->isGit) { | if ($this->isGit) { | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
public function getSupportedRevisionControlSystems() { | public function getSupportedRevisionControlSystems() { | ||||
return array('git', 'hg'); | return array('git', 'hg'); | ||||
} | } | ||||
private function getBranchOrBookmark() { | private function getBranchOrBookmark() { | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
if ($this->isGit) { | if ($this->isGit) { | ||||
$branch = $repository_api->getBranchName(); | $branch = $repository_api->getBranchName(); | ||||
// If we don't have a branch name, just use whatever's at HEAD. | |||||
if (!strlen($branch) && !$this->isGitSvn) { | |||||
$branch = $repository_api->getWorkingCopyRevision(); | |||||
} | |||||
} else if ($this->isHg) { | } else if ($this->isHg) { | ||||
$branch = $repository_api->getActiveBookmark(); | $branch = $repository_api->getActiveBookmark(); | ||||
if (!$branch) { | if (!$branch) { | ||||
$branch = $repository_api->getBranchName(); | $branch = $repository_api->getBranchName(); | ||||
} | } | ||||
} | } | ||||
return $branch; | return $branch; | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | $console->writeOut( | ||||
pht('Harbormaster URI'), | pht('Harbormaster URI'), | ||||
$buildable['uri']); | $buildable['uri']); | ||||
if (!$console->confirm($prompt)) { | if (!$console->confirm($prompt)) { | ||||
throw new ArcanistUserAbortException(); | throw new ArcanistUserAbortException(); | ||||
} | } | ||||
} | } | ||||
public function buildEngineMessage(ArcanistLandEngine $engine) { | |||||
// TODO: This is oh-so-gross. | |||||
$this->findRevision(); | |||||
$engine->setCommitMessageFile($this->messageFile); | |||||
} | |||||
public function didPush() { | |||||
$this->askForRepositoryUpdate(); | |||||
$mark_workflow = $this->buildChildWorkflow( | |||||
'close-revision', | |||||
array( | |||||
'--finalize', | |||||
'--quiet', | |||||
$this->revision['id'], | |||||
)); | |||||
$mark_workflow->run(); | |||||
} | |||||
} | } |