mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-24 15:52:40 +01:00
Collect scattered implementations of "getDisplayHash()" into RepositoryAPI
Summary: Ref T13546. All of LandEngine, LocalState, and RepositoryAPI implement "getDisplayHash()". Always use the RepositoryAPI implementation. Test Plan: Grepped for symbols. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21353
This commit is contained in:
parent
63f2e667b9
commit
33bb0acf97
7 changed files with 45 additions and 48 deletions
|
@ -34,7 +34,7 @@ final class ArcanistGitLandEngine
|
||||||
$recovery_command = csprintf(
|
$recovery_command = csprintf(
|
||||||
'git checkout -b %s %s',
|
'git checkout -b %s %s',
|
||||||
$branch_name,
|
$branch_name,
|
||||||
$this->getDisplayHash($branch_hash));
|
$api->getDisplayHash($branch_hash));
|
||||||
|
|
||||||
$log->writeStatus(
|
$log->writeStatus(
|
||||||
pht('CLEANUP'),
|
pht('CLEANUP'),
|
||||||
|
@ -174,8 +174,8 @@ final class ArcanistGitLandEngine
|
||||||
'Branch "%s" does not rebase cleanly from "%s" onto '.
|
'Branch "%s" does not rebase cleanly from "%s" onto '.
|
||||||
'"%s", skipping.',
|
'"%s", skipping.',
|
||||||
$branch_name,
|
$branch_name,
|
||||||
$this->getDisplayHash($old_commit),
|
$api->getDisplayHash($old_commit),
|
||||||
$this->getDisplayHash($rebase_target)));
|
$api->getDisplayHash($rebase_target)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,15 +287,15 @@ final class ArcanistGitLandEngine
|
||||||
pht(
|
pht(
|
||||||
'Merging local "%s" into "%s" produces an empty diff. '.
|
'Merging local "%s" into "%s" produces an empty diff. '.
|
||||||
'This usually means these changes have already landed.',
|
'This usually means these changes have already landed.',
|
||||||
$this->getDisplayHash($max_hash),
|
$api->getDisplayHash($max_hash),
|
||||||
$this->getDisplayHash($into_commit)));
|
$api->getDisplayHash($into_commit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$log->writeStatus(
|
$log->writeStatus(
|
||||||
pht('MERGING'),
|
pht('MERGING'),
|
||||||
pht(
|
pht(
|
||||||
'%s %s',
|
'%s %s',
|
||||||
$this->getDisplayHash($max_hash),
|
$api->getDisplayHash($max_hash),
|
||||||
$max_commit->getDisplaySummary()));
|
$max_commit->getDisplaySummary()));
|
||||||
|
|
||||||
$argv = array();
|
$argv = array();
|
||||||
|
@ -355,23 +355,23 @@ final class ArcanistGitLandEngine
|
||||||
$message = pht(
|
$message = pht(
|
||||||
'Local commit "%s" (%s) does not merge cleanly into "%s". '.
|
'Local commit "%s" (%s) does not merge cleanly into "%s". '.
|
||||||
'Merge or rebase local changes so they can merge cleanly.',
|
'Merge or rebase local changes so they can merge cleanly.',
|
||||||
$this->getDisplayHash($max_hash),
|
$api->getDisplayHash($max_hash),
|
||||||
$this->getDisplaySymbols($direct_symbols),
|
$this->getDisplaySymbols($direct_symbols),
|
||||||
$this->getDisplayHash($into_commit));
|
$api->getDisplayHash($into_commit));
|
||||||
} else if ($indirect_symbols) {
|
} else if ($indirect_symbols) {
|
||||||
$message = pht(
|
$message = pht(
|
||||||
'Local commit "%s" (reachable from: %s) does not merge cleanly '.
|
'Local commit "%s" (reachable from: %s) does not merge cleanly '.
|
||||||
'into "%s". Merge or rebase local changes so they can merge '.
|
'into "%s". Merge or rebase local changes so they can merge '.
|
||||||
'cleanly.',
|
'cleanly.',
|
||||||
$this->getDisplayHash($max_hash),
|
$api->getDisplayHash($max_hash),
|
||||||
$this->getDisplaySymbols($indirect_symbols),
|
$this->getDisplaySymbols($indirect_symbols),
|
||||||
$this->getDisplayHash($into_commit));
|
$api->getDisplayHash($into_commit));
|
||||||
} else {
|
} else {
|
||||||
$message = pht(
|
$message = pht(
|
||||||
'Local commit "%s" does not merge cleanly into "%s". Merge or '.
|
'Local commit "%s" does not merge cleanly into "%s". Merge or '.
|
||||||
'rebase local changes so they can merge cleanly.',
|
'rebase local changes so they can merge cleanly.',
|
||||||
$this->getDisplayHash($max_hash),
|
$api->getDisplayHash($max_hash),
|
||||||
$this->getDisplayHash($into_commit));
|
$api->getDisplayHash($into_commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo tsprintf(
|
echo tsprintf(
|
||||||
|
@ -1235,6 +1235,7 @@ final class ArcanistGitLandEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function selectIntoCommit() {
|
protected function selectIntoCommit() {
|
||||||
|
$api = $this->getRepositoryAPI();
|
||||||
// Make sure that our "into" target is valid.
|
// Make sure that our "into" target is valid.
|
||||||
$log = $this->getLogEngine();
|
$log = $this->getLogEngine();
|
||||||
|
|
||||||
|
@ -1251,7 +1252,6 @@ final class ArcanistGitLandEngine
|
||||||
if ($this->getIntoLocal()) {
|
if ($this->getIntoLocal()) {
|
||||||
// If we're running under "--into-local", just make sure that the
|
// If we're running under "--into-local", just make sure that the
|
||||||
// target identifies some actual commit.
|
// target identifies some actual commit.
|
||||||
$api = $this->getRepositoryAPI();
|
|
||||||
$local_ref = $this->getIntoRef();
|
$local_ref = $this->getIntoRef();
|
||||||
|
|
||||||
list($err, $stdout) = $api->execManualLocal(
|
list($err, $stdout) = $api->execManualLocal(
|
||||||
|
@ -1272,7 +1272,7 @@ final class ArcanistGitLandEngine
|
||||||
pht(
|
pht(
|
||||||
'Preparing merge into local target "%s", at commit "%s".',
|
'Preparing merge into local target "%s", at commit "%s".',
|
||||||
$local_ref,
|
$local_ref,
|
||||||
$this->getDisplayHash($into_commit)));
|
$api->getDisplayHash($into_commit)));
|
||||||
|
|
||||||
return $into_commit;
|
return $into_commit;
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1289,7 @@ final class ArcanistGitLandEngine
|
||||||
'Preparing merge into "%s" from remote "%s", at commit "%s".',
|
'Preparing merge into "%s" from remote "%s", at commit "%s".',
|
||||||
$target->getRef(),
|
$target->getRef(),
|
||||||
$target->getRemote(),
|
$target->getRemote(),
|
||||||
$this->getDisplayHash($commit)));
|
$api->getDisplayHash($commit)));
|
||||||
return $commit;
|
return $commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1492,12 +1492,13 @@ final class ArcanistGitLandEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
private function newOntoRefArguments($into_commit) {
|
private function newOntoRefArguments($into_commit) {
|
||||||
|
$api = $this->getRepositoryAPI();
|
||||||
$refspecs = array();
|
$refspecs = array();
|
||||||
|
|
||||||
foreach ($this->getOntoRefs() as $onto_ref) {
|
foreach ($this->getOntoRefs() as $onto_ref) {
|
||||||
$refspecs[] = sprintf(
|
$refspecs[] = sprintf(
|
||||||
'%s:refs/heads/%s',
|
'%s:refs/heads/%s',
|
||||||
$this->getDisplayHash($into_commit),
|
$api->getDisplayHash($into_commit),
|
||||||
$onto_ref);
|
$onto_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -766,6 +766,7 @@ abstract class ArcanistLandEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
||||||
|
@ -775,7 +776,7 @@ abstract class ArcanistLandEngine
|
||||||
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) {
|
||||||
|
@ -794,6 +795,7 @@ abstract class ArcanistLandEngine
|
||||||
|
|
||||||
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();
|
||||||
|
@ -937,7 +939,7 @@ abstract class ArcanistLandEngine
|
||||||
$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();
|
||||||
|
|
||||||
|
@ -979,15 +981,11 @@ abstract class ArcanistLandEngine
|
||||||
// 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);
|
||||||
|
|
||||||
|
@ -997,7 +995,7 @@ abstract class ArcanistLandEngine
|
||||||
'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",
|
||||||
|
@ -1029,7 +1027,7 @@ abstract class ArcanistLandEngine
|
||||||
'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(
|
||||||
|
@ -1054,7 +1052,7 @@ abstract class ArcanistLandEngine
|
||||||
} else {
|
} else {
|
||||||
echo tsprintf(
|
echo tsprintf(
|
||||||
" %s %s\n",
|
" %s %s\n",
|
||||||
$this->getDisplayHash($commit->getHash()),
|
$api->getDisplayHash($commit->getHash()),
|
||||||
$commit->getDisplaySummary());
|
$commit->getDisplaySummary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,12 +1148,12 @@ abstract class ArcanistLandEngine
|
||||||
'"%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;
|
||||||
|
|
|
@ -61,13 +61,13 @@ final class ArcanistMercurialLandEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
$commit = $api->getCanonicalRevisionName('.');
|
$commit = $api->getCanonicalRevisionName('.');
|
||||||
$commit = $this->getDisplayHash($commit);
|
$commit = $api->getDisplayHash($commit);
|
||||||
|
|
||||||
$log->writeStatus(
|
$log->writeStatus(
|
||||||
pht('SOURCE'),
|
pht('SOURCE'),
|
||||||
pht(
|
pht(
|
||||||
'Landing the active commit, "%s".',
|
'Landing the active commit, "%s".',
|
||||||
$this->getDisplayHash($commit)));
|
$api->getDisplayHash($commit)));
|
||||||
|
|
||||||
return array($commit);
|
return array($commit);
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ final class ArcanistMercurialLandEngine
|
||||||
pht(
|
pht(
|
||||||
'Preparing merge into local target "%s", at commit "%s".',
|
'Preparing merge into local target "%s", at commit "%s".',
|
||||||
$local_ref,
|
$local_ref,
|
||||||
$this->getDisplayHash($into_commit)));
|
$api->getDisplayHash($into_commit)));
|
||||||
|
|
||||||
return $into_commit;
|
return $into_commit;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ final class ArcanistMercurialLandEngine
|
||||||
'Preparing merge into "%s" from remote "%s", at commit "%s".',
|
'Preparing merge into "%s" from remote "%s", at commit "%s".',
|
||||||
$target->getRef(),
|
$target->getRef(),
|
||||||
$target->getRemote(),
|
$target->getRemote(),
|
||||||
$this->getDisplayHash($commit)));
|
$api->getDisplayHash($commit)));
|
||||||
return $commit;
|
return $commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,7 +874,7 @@ final class ArcanistMercurialLandEngine
|
||||||
'bookmark',
|
'bookmark',
|
||||||
'--force',
|
'--force',
|
||||||
'--rev',
|
'--rev',
|
||||||
hgsprintf('%s', $this->getDisplayHash($new_position)),
|
hgsprintf('%s', $api->getDisplayHash($new_position)),
|
||||||
'--',
|
'--',
|
||||||
$bookmark_name,
|
$bookmark_name,
|
||||||
);
|
);
|
||||||
|
@ -922,7 +922,7 @@ final class ArcanistMercurialLandEngine
|
||||||
} else {
|
} else {
|
||||||
$tail[] = '--force';
|
$tail[] = '--force';
|
||||||
$tail[] = '--rev';
|
$tail[] = '--rev';
|
||||||
$tail[] = hgsprintf('%s', $this->getDisplayHash($old_position));
|
$tail[] = hgsprintf('%s', $api->getDisplayHash($old_position));
|
||||||
}
|
}
|
||||||
|
|
||||||
$tail[] = '--';
|
$tail[] = '--';
|
||||||
|
|
|
@ -168,7 +168,7 @@ final class ArcanistRevisionRef
|
||||||
protected function buildRefView(ArcanistRefView $view) {
|
protected function buildRefView(ArcanistRefView $view) {
|
||||||
$view
|
$view
|
||||||
->setObjectName($this->getMonogram())
|
->setObjectName($this->getMonogram())
|
||||||
->setTitle($this->getTitle());
|
->setTitle($this->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ final class ArcanistGitLocalState
|
||||||
$ref = null;
|
$ref = null;
|
||||||
$where = pht(
|
$where = pht(
|
||||||
'Saving local state (at detached commit "%s").',
|
'Saving local state (at detached commit "%s").',
|
||||||
$this->getDisplayHash($commit));
|
$api->getDisplayHash($commit));
|
||||||
} else {
|
} else {
|
||||||
$where = pht(
|
$where = pht(
|
||||||
'Saving local state (on ref "%s" at commit "%s").',
|
'Saving local state (on ref "%s" at commit "%s").',
|
||||||
$ref,
|
$ref,
|
||||||
$this->getDisplayHash($commit));
|
$api->getDisplayHash($commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->localRef = $ref;
|
$this->localRef = $ref;
|
||||||
|
@ -56,11 +56,11 @@ final class ArcanistGitLocalState
|
||||||
$where = pht(
|
$where = pht(
|
||||||
'Restoring local state (to ref "%s" at commit "%s").',
|
'Restoring local state (to ref "%s" at commit "%s").',
|
||||||
$ref,
|
$ref,
|
||||||
$this->getDisplayHash($commit));
|
$api->getDisplayHash($commit));
|
||||||
} else {
|
} else {
|
||||||
$where = pht(
|
$where = pht(
|
||||||
'Restoring local state (to detached commit "%s").',
|
'Restoring local state (to detached commit "%s").',
|
||||||
$this->getDisplayHash($commit));
|
$api->getDisplayHash($commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
$log->writeStatus(pht('LOAD STATE'), $where);
|
$log->writeStatus(pht('LOAD STATE'), $where);
|
||||||
|
@ -84,6 +84,7 @@ final class ArcanistGitLocalState
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newRestoreCommandsForDisplay() {
|
protected function newRestoreCommandsForDisplay() {
|
||||||
|
$api = $this->getRepositoryAPI();
|
||||||
$ref = $this->localRef;
|
$ref = $this->localRef;
|
||||||
$commit = $this->localCommit;
|
$commit = $this->localCommit;
|
||||||
|
|
||||||
|
@ -93,11 +94,11 @@ final class ArcanistGitLocalState
|
||||||
$commands[] = csprintf(
|
$commands[] = csprintf(
|
||||||
'git checkout -B %s %s --',
|
'git checkout -B %s %s --',
|
||||||
$ref,
|
$ref,
|
||||||
$this->getDisplayHash($commit));
|
$api->getDisplayHash($commit));
|
||||||
} else {
|
} else {
|
||||||
$commands[] = csprintf(
|
$commands[] = csprintf(
|
||||||
'git checkout %s --',
|
'git checkout %s --',
|
||||||
$this->getDisplayHash($commit));
|
$api->getDisplayHash($commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: We run "submodule update" in the real restore workflow, but
|
// NOTE: We run "submodule update" in the real restore workflow, but
|
||||||
|
|
|
@ -22,7 +22,7 @@ final class ArcanistMercurialLocalState
|
||||||
pht('SAVE STATE'),
|
pht('SAVE STATE'),
|
||||||
pht(
|
pht(
|
||||||
'Saving local state (at "%s" on branch "%s").',
|
'Saving local state (at "%s" on branch "%s").',
|
||||||
$this->getDisplayHash($this->localCommit),
|
$api->getDisplayHash($this->localCommit),
|
||||||
$this->localBranch));
|
$this->localBranch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ final class ArcanistMercurialLocalState
|
||||||
pht('LOAD STATE'),
|
pht('LOAD STATE'),
|
||||||
pht(
|
pht(
|
||||||
'Restoring local state (at "%s" on branch "%s").',
|
'Restoring local state (at "%s" on branch "%s").',
|
||||||
$this->getDisplayHash($this->localCommit),
|
$api->getDisplayHash($this->localCommit),
|
||||||
$this->localBranch));
|
$this->localBranch));
|
||||||
|
|
||||||
$api->execxLocal('update -- %s', $this->localCommit);
|
$api->execxLocal('update -- %s', $this->localCommit);
|
||||||
|
@ -59,11 +59,12 @@ final class ArcanistMercurialLocalState
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newRestoreCommandsForDisplay() {
|
protected function newRestoreCommandsForDisplay() {
|
||||||
|
$api = $this->getRepositoryAPI();
|
||||||
$commands = array();
|
$commands = array();
|
||||||
|
|
||||||
$commands[] = csprintf(
|
$commands[] = csprintf(
|
||||||
'hg update -- %s',
|
'hg update -- %s',
|
||||||
$this->getDisplayHash($this->localCommit));
|
$api->getDisplayHash($this->localCommit));
|
||||||
|
|
||||||
$commands[] = csprintf(
|
$commands[] = csprintf(
|
||||||
'hg branch --force -- %s',
|
'hg branch --force -- %s',
|
||||||
|
|
|
@ -256,8 +256,4 @@ abstract class ArcanistRepositoryLocalState
|
||||||
echo tsprintf("\n");
|
echo tsprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getDisplayHash($hash) {
|
|
||||||
return substr($hash, 0, 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue