Changeset View
Changeset View
Standalone View
Standalone View
src/land/engine/ArcanistLandEngine.php
Show First 20 Lines • Show All 760 Lines • ▼ Show 20 Lines | final protected function getDisplaySymbols(array $symbols) { | ||||
foreach ($symbols as $symbol) { | foreach ($symbols as $symbol) { | ||||
$display[] = sprintf('"%s"', addcslashes($symbol->getSymbol(), '\\"')); | $display[] = sprintf('"%s"', addcslashes($symbol->getSymbol(), '\\"')); | ||||
} | } | ||||
return implode(', ', $display); | return implode(', ', $display); | ||||
} | } | ||||
final protected function printCommitSet(ArcanistLandCommitSet $set) { | final protected function printCommitSet(ArcanistLandCommitSet $set) { | ||||
$api = $this->getRepositoryAPI(); | |||||
$revision_ref = $set->getRevisionRef(); | $revision_ref = $set->getRevisionRef(); | ||||
echo tsprintf( | echo tsprintf( | ||||
"\n%s", | "\n%s", | ||||
$revision_ref->newRefView()); | $revision_ref->newRefView()); | ||||
foreach ($set->getCommits() as $commit) { | foreach ($set->getCommits() as $commit) { | ||||
$is_implicit = $commit->getIsImplicitCommit(); | $is_implicit = $commit->getIsImplicitCommit(); | ||||
$display_hash = $this->getDisplayHash($commit->getHash()); | $display_hash = $api->getDisplayHash($commit->getHash()); | ||||
$display_summary = $commit->getDisplaySummary(); | $display_summary = $commit->getDisplaySummary(); | ||||
if ($is_implicit) { | if ($is_implicit) { | ||||
echo tsprintf( | echo tsprintf( | ||||
" <bg:yellow> %s </bg> %s\n", | " <bg:yellow> %s </bg> %s\n", | ||||
$display_hash, | $display_hash, | ||||
$display_summary); | $display_summary); | ||||
} else { | } else { | ||||
echo tsprintf( | echo tsprintf( | ||||
" %s %s\n", | " %s %s\n", | ||||
$display_hash, | $display_hash, | ||||
$display_summary); | $display_summary); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
final protected function loadRevisionRefs(array $commit_map) { | final protected function loadRevisionRefs(array $commit_map) { | ||||
assert_instances_of($commit_map, 'ArcanistLandCommit'); | assert_instances_of($commit_map, 'ArcanistLandCommit'); | ||||
$api = $this->getRepositoryAPI(); | |||||
$workflow = $this->getWorkflow(); | $workflow = $this->getWorkflow(); | ||||
$state_refs = array(); | $state_refs = array(); | ||||
foreach ($commit_map as $commit) { | foreach ($commit_map as $commit) { | ||||
$hash = $commit->getHash(); | $hash = $commit->getHash(); | ||||
$commit_ref = id(new ArcanistCommitRef()) | $commit_ref = id(new ArcanistCommitRef()) | ||||
->setCommitHash($hash); | ->setCommitHash($hash); | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | foreach ($commit_map as $commit) { | ||||
$ambiguous[] = $commit; | $ambiguous[] = $commit; | ||||
} | } | ||||
if ($ambiguous) { | if ($ambiguous) { | ||||
foreach ($ambiguous as $commit) { | foreach ($ambiguous as $commit) { | ||||
$symbols = $commit->getIndirectSymbols(); | $symbols = $commit->getIndirectSymbols(); | ||||
$raw_symbols = mpull($symbols, 'getSymbol'); | $raw_symbols = mpull($symbols, 'getSymbol'); | ||||
$symbol_list = implode(', ', $raw_symbols); | $symbol_list = implode(', ', $raw_symbols); | ||||
$display_hash = $this->getDisplayHash($hash); | $display_hash = $api->getDisplayHash($hash); | ||||
$revision_refs = $commit->getRelatedRevisionRefs(); | $revision_refs = $commit->getRelatedRevisionRefs(); | ||||
// TODO: Include "use 'arc look --type commit abc' to figure out why" | // TODO: Include "use 'arc look --type commit abc' to figure out why" | ||||
// once that works? | // once that works? | ||||
// TODO: We could print all the ambiguous commits. | // TODO: We could print all the ambiguous commits. | ||||
Show All 25 Lines | if ($ambiguous) { | ||||
$display_hash)); | $display_hash)); | ||||
} | } | ||||
} | } | ||||
// NOTE: We may exit this method with commits that are still unassociated. | // NOTE: We may exit this method with commits that are still unassociated. | ||||
// These will be handled later by the "implicit commits" mechanism. | // These will be handled later by the "implicit commits" mechanism. | ||||
} | } | ||||
final protected function getDisplayHash($hash) { | |||||
// TODO: This should be on the API object. | |||||
return substr($hash, 0, 12); | |||||
} | |||||
final protected function confirmCommits( | final protected function confirmCommits( | ||||
$into_commit, | $into_commit, | ||||
array $symbols, | array $symbols, | ||||
array $commit_map) { | array $commit_map) { | ||||
$api = $this->getRepositoryAPI(); | |||||
$commit_count = count($commit_map); | $commit_count = count($commit_map); | ||||
if (!$commit_count) { | if (!$commit_count) { | ||||
$message = pht( | $message = pht( | ||||
'There are no commits reachable from the specified sources (%s) '. | 'There are no commits reachable from the specified sources (%s) '. | ||||
'which are not already present in the state you are merging '. | 'which are not already present in the state you are merging '. | ||||
'into ("%s"), so nothing can land.', | 'into ("%s"), so nothing can land.', | ||||
$this->getDisplaySymbols($symbols), | $this->getDisplaySymbols($symbols), | ||||
$this->getDisplayHash($into_commit)); | $api->getDisplayHash($into_commit)); | ||||
echo tsprintf( | echo tsprintf( | ||||
"\n%!\n%W\n\n", | "\n%!\n%W\n\n", | ||||
pht('NOTHING TO LAND'), | pht('NOTHING TO LAND'), | ||||
$message); | $message); | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht('There are no commits to land.')); | pht('There are no commits to land.')); | ||||
Show All 15 Lines | if ($commit_count > $warn_limit) { | ||||
$this->getDisplaySymbols($symbols)); | $this->getDisplaySymbols($symbols)); | ||||
} else { | } else { | ||||
$message = pht( | $message = pht( | ||||
'There are %s commit(s) reachable from the specified sources (%s) '. | 'There are %s commit(s) reachable from the specified sources (%s) '. | ||||
'that are not present in the repository state you are merging '. | 'that are not present in the repository state you are merging '. | ||||
'into ("%s"). All of these commits will land:', | 'into ("%s"). All of these commits will land:', | ||||
new PhutilNumber($commit_count), | new PhutilNumber($commit_count), | ||||
$this->getDisplaySymbols($symbols), | $this->getDisplaySymbols($symbols), | ||||
$this->getDisplayHash($into_commit)); | $api->getDisplayHash($into_commit)); | ||||
} | } | ||||
echo tsprintf( | echo tsprintf( | ||||
"\n%!\n%W\n", | "\n%!\n%W\n", | ||||
pht('LARGE WORKING SET'), | pht('LARGE WORKING SET'), | ||||
$message); | $message); | ||||
$display_commits = array_merge( | $display_commits = array_merge( | ||||
array_slice($commit_map, 0, $show_limit), | array_slice($commit_map, 0, $show_limit), | ||||
array(null), | array(null), | ||||
array_slice($commit_map, -$show_limit)); | array_slice($commit_map, -$show_limit)); | ||||
echo tsprintf("\n"); | echo tsprintf("\n"); | ||||
foreach ($display_commits as $commit) { | foreach ($display_commits as $commit) { | ||||
if ($commit === null) { | if ($commit === null) { | ||||
echo tsprintf( | echo tsprintf( | ||||
" %s\n", | " %s\n", | ||||
pht( | pht( | ||||
'< ... %s more commits ... >', | '< ... %s more commits ... >', | ||||
new PhutilNumber($commit_count - ($show_limit * 2)))); | new PhutilNumber($commit_count - ($show_limit * 2)))); | ||||
} else { | } else { | ||||
echo tsprintf( | echo tsprintf( | ||||
" %s %s\n", | " %s %s\n", | ||||
$this->getDisplayHash($commit->getHash()), | $api->getDisplayHash($commit->getHash()), | ||||
$commit->getDisplaySummary()); | $commit->getDisplaySummary()); | ||||
} | } | ||||
} | } | ||||
$query = pht( | $query = pht( | ||||
'Land %s commit(s)?', | 'Land %s commit(s)?', | ||||
new PhutilNumber($commit_count)); | new PhutilNumber($commit_count)); | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | foreach ($commit_map as $commit_hash => $commit) { | ||||
echo tsprintf( | echo tsprintf( | ||||
"\n%!\n%W\n\n", | "\n%!\n%W\n\n", | ||||
pht('UNKNOWN REVISION'), | pht('UNKNOWN REVISION'), | ||||
pht( | pht( | ||||
'Unable to determine which revision is associated with commit '. | 'Unable to determine which revision is associated with commit '. | ||||
'"%s". Use "arc diff" to create or update a revision with this '. | '"%s". Use "arc diff" to create or update a revision with this '. | ||||
'commit, or "--revision" to force selection of a particular '. | 'commit, or "--revision" to force selection of a particular '. | ||||
'revision.', | 'revision.', | ||||
$this->getDisplayHash($commit_hash))); | $api->getDisplayHash($commit_hash))); | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'Unable to determine revision for commit "%s".', | 'Unable to determine revision for commit "%s".', | ||||
$this->getDisplayHash($commit_hash))); | $api->getDisplayHash($commit_hash))); | ||||
} | } | ||||
$revision_groups[$revision_ref->getPHID()][] = $commit; | $revision_groups[$revision_ref->getPHID()][] = $commit; | ||||
} | } | ||||
$commit_heads = array(); | $commit_heads = array(); | ||||
foreach ($commit_map as $commit) { | foreach ($commit_map as $commit) { | ||||
if ($commit->getIsHeadCommit()) { | if ($commit->getIsHeadCommit()) { | ||||
▲ Show 20 Lines • Show All 408 Lines • Show Last 20 Lines |