Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistPatchWorkflow.php
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | return array( | ||||
'branch and deletes the temporary branch.', | 'branch and deletes the temporary branch.', | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'update' => true, | 'update' => true, | ||||
), | ), | ||||
), | ), | ||||
'force' => array( | 'force' => array( | ||||
'help' => 'Do not run any sanity checks.', | 'help' => 'Do not run any sanity checks.', | ||||
), | ), | ||||
'keep-redundant-commits' => array( | |||||
'supports' => array('git'), | |||||
'help' => | |||||
'Normally, git will not allow you to cherry-pick empty commits, '. | |||||
'however if you have dependent diffs where some of the '. | |||||
'dependencies have landed into HEAD, then you might want to force '. | |||||
'git to do so to be able to successfully patch dependent diffs. '. | |||||
'This flag gets passed down to git cherry-pick which then cretes '. | |||||
'empty commits for the dependencies.', | |||||
), | |||||
'*' => 'name', | '*' => 'name', | ||||
); | ); | ||||
} | } | ||||
protected function didParseArguments() { | protected function didParseArguments() { | ||||
$source = null; | $source = null; | ||||
$requested = 0; | $requested = 0; | ||||
if ($this->getArgument('revision')) { | if ($this->getArgument('revision')) { | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | EOTEXT | ||||
private function shouldBranch() { | private function shouldBranch() { | ||||
$no_branch = $this->getArgument('nobranch', false); | $no_branch = $this->getArgument('nobranch', false); | ||||
if ($no_branch) { | if ($no_branch) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
private function shouldKeepRedundantCommits() { | |||||
return $this->getArgument('keep-redundant-commits', false); | |||||
} | |||||
private function getBranchName(ArcanistBundle $bundle) { | private function getBranchName(ArcanistBundle $bundle) { | ||||
$branch_name = null; | $branch_name = null; | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
$revision_id = $bundle->getRevisionID(); | $revision_id = $bundle->getRevisionID(); | ||||
$base_name = 'arcpatch'; | $base_name = 'arcpatch'; | ||||
if ($revision_id) { | if ($revision_id) { | ||||
$base_name .= "-D{$revision_id}"; | $base_name .= "-D{$revision_id}"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 485 Lines • ▼ Show 20 Lines | if ($repository_api instanceof ArcanistSubversionAPI) { | ||||
} | } | ||||
if ($this->canBranch() && | if ($this->canBranch() && | ||||
!$this->shouldBranch() && | !$this->shouldBranch() && | ||||
$this->shouldCommit() && $has_base_revision) { | $this->shouldCommit() && $has_base_revision) { | ||||
$repository_api->execxLocal('checkout %s', $original_branch); | $repository_api->execxLocal('checkout %s', $original_branch); | ||||
$ex = null; | $ex = null; | ||||
try { | try { | ||||
if ($this->shouldKeepRedundantCommits()) { | |||||
$repository_api->execxLocal( | |||||
'cherry-pick --keep-redundant-commits %s', | |||||
$new_branch); | |||||
} else { | |||||
$repository_api->execxLocal('cherry-pick %s', $new_branch); | $repository_api->execxLocal('cherry-pick %s', $new_branch); | ||||
} | |||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
// do nothing | // do nothing | ||||
} | } | ||||
$repository_api->execxLocal('branch -D %s', $new_branch); | $repository_api->execxLocal('branch -D %s', $new_branch); | ||||
if ($ex) { | if ($ex) { | ||||
echo phutil_console_format( | echo phutil_console_format( | ||||
"\n<bg:red>** Cherry Pick Failed!**</bg>\n"); | "\n<bg:red>** Cherry Pick Failed!**</bg>\n"); | ||||
throw $ex; | throw $ex; | ||||
▲ Show 20 Lines • Show All 369 Lines • Show Last 20 Lines |