diff --git a/src/land/engine/ArcanistGitLandEngine.php b/src/land/engine/ArcanistGitLandEngine.php --- a/src/land/engine/ArcanistGitLandEngine.php +++ b/src/land/engine/ArcanistGitLandEngine.php @@ -34,7 +34,7 @@ $recovery_command = csprintf( 'git checkout -b %s %s', $branch_name, - $this->getDisplayHash($branch_hash)); + $api->getDisplayHash($branch_hash)); $log->writeStatus( pht('CLEANUP'), @@ -174,8 +174,8 @@ 'Branch "%s" does not rebase cleanly from "%s" onto '. '"%s", skipping.', $branch_name, - $this->getDisplayHash($old_commit), - $this->getDisplayHash($rebase_target))); + $api->getDisplayHash($old_commit), + $api->getDisplayHash($rebase_target))); } } } @@ -287,15 +287,15 @@ pht( 'Merging local "%s" into "%s" produces an empty diff. '. 'This usually means these changes have already landed.', - $this->getDisplayHash($max_hash), - $this->getDisplayHash($into_commit))); + $api->getDisplayHash($max_hash), + $api->getDisplayHash($into_commit))); } $log->writeStatus( pht('MERGING'), pht( '%s %s', - $this->getDisplayHash($max_hash), + $api->getDisplayHash($max_hash), $max_commit->getDisplaySummary())); $argv = array(); @@ -355,23 +355,23 @@ $message = pht( 'Local commit "%s" (%s) does not merge cleanly into "%s". '. 'Merge or rebase local changes so they can merge cleanly.', - $this->getDisplayHash($max_hash), + $api->getDisplayHash($max_hash), $this->getDisplaySymbols($direct_symbols), - $this->getDisplayHash($into_commit)); + $api->getDisplayHash($into_commit)); } else if ($indirect_symbols) { $message = pht( 'Local commit "%s" (reachable from: %s) does not merge cleanly '. 'into "%s". Merge or rebase local changes so they can merge '. 'cleanly.', - $this->getDisplayHash($max_hash), + $api->getDisplayHash($max_hash), $this->getDisplaySymbols($indirect_symbols), - $this->getDisplayHash($into_commit)); + $api->getDisplayHash($into_commit)); } else { $message = pht( 'Local commit "%s" does not merge cleanly into "%s". Merge or '. 'rebase local changes so they can merge cleanly.', - $this->getDisplayHash($max_hash), - $this->getDisplayHash($into_commit)); + $api->getDisplayHash($max_hash), + $api->getDisplayHash($into_commit)); } echo tsprintf( @@ -1272,7 +1272,7 @@ pht( 'Preparing merge into local target "%s", at commit "%s".', $local_ref, - $this->getDisplayHash($into_commit))); + $api->getDisplayHash($into_commit))); return $into_commit; } @@ -1289,7 +1289,7 @@ 'Preparing merge into "%s" from remote "%s", at commit "%s".', $target->getRef(), $target->getRemote(), - $this->getDisplayHash($commit))); + $api->getDisplayHash($commit))); return $commit; } @@ -1492,12 +1492,13 @@ } private function newOntoRefArguments($into_commit) { + $api = $this->getRepositoryAPI(); $refspecs = array(); foreach ($this->getOntoRefs() as $onto_ref) { $refspecs[] = sprintf( '%s:refs/heads/%s', - $this->getDisplayHash($into_commit), + $api->getDisplayHash($into_commit), $onto_ref); } diff --git a/src/land/engine/ArcanistLandEngine.php b/src/land/engine/ArcanistLandEngine.php --- a/src/land/engine/ArcanistLandEngine.php +++ b/src/land/engine/ArcanistLandEngine.php @@ -766,6 +766,7 @@ } final protected function printCommitSet(ArcanistLandCommitSet $set) { + $api = $this->getRepositoryAPI(); $revision_ref = $set->getRevisionRef(); echo tsprintf( @@ -775,7 +776,7 @@ foreach ($set->getCommits() as $commit) { $is_implicit = $commit->getIsImplicitCommit(); - $display_hash = $this->getDisplayHash($commit->getHash()); + $display_hash = $api->getDisplayHash($commit->getHash()); $display_summary = $commit->getDisplaySummary(); if ($is_implicit) { @@ -794,6 +795,7 @@ final protected function loadRevisionRefs(array $commit_map) { assert_instances_of($commit_map, 'ArcanistLandCommit'); + $api = $this->getRepositoryAPI(); $workflow = $this->getWorkflow(); $state_refs = array(); @@ -937,7 +939,7 @@ $symbols = $commit->getIndirectSymbols(); $raw_symbols = mpull($symbols, 'getSymbol'); $symbol_list = implode(', ', $raw_symbols); - $display_hash = $this->getDisplayHash($hash); + $display_hash = $api->getDisplayHash($hash); $revision_refs = $commit->getRelatedRevisionRefs(); @@ -979,15 +981,11 @@ // 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( $into_commit, array $symbols, array $commit_map) { + $api = $this->getRepositoryAPI(); $commit_count = count($commit_map); @@ -997,7 +995,7 @@ 'which are not already present in the state you are merging '. 'into ("%s"), so nothing can land.', $this->getDisplaySymbols($symbols), - $this->getDisplayHash($into_commit)); + $api->getDisplayHash($into_commit)); echo tsprintf( "\n%!\n%W\n\n", @@ -1029,7 +1027,7 @@ 'into ("%s"). All of these commits will land:', new PhutilNumber($commit_count), $this->getDisplaySymbols($symbols), - $this->getDisplayHash($into_commit)); + $api->getDisplayHash($into_commit)); } echo tsprintf( @@ -1054,7 +1052,7 @@ } else { echo tsprintf( " %s %s\n", - $this->getDisplayHash($commit->getHash()), + $api->getDisplayHash($commit->getHash()), $commit->getDisplaySummary()); } } @@ -1150,12 +1148,12 @@ '"%s". Use "arc diff" to create or update a revision with this '. 'commit, or "--revision" to force selection of a particular '. 'revision.', - $this->getDisplayHash($commit_hash))); + $api->getDisplayHash($commit_hash))); throw new PhutilArgumentUsageException( pht( 'Unable to determine revision for commit "%s".', - $this->getDisplayHash($commit_hash))); + $api->getDisplayHash($commit_hash))); } $revision_groups[$revision_ref->getPHID()][] = $commit; diff --git a/src/land/engine/ArcanistMercurialLandEngine.php b/src/land/engine/ArcanistMercurialLandEngine.php --- a/src/land/engine/ArcanistMercurialLandEngine.php +++ b/src/land/engine/ArcanistMercurialLandEngine.php @@ -61,13 +61,13 @@ } $commit = $api->getCanonicalRevisionName('.'); - $commit = $this->getDisplayHash($commit); + $commit = $api->getDisplayHash($commit); $log->writeStatus( pht('SOURCE'), pht( 'Landing the active commit, "%s".', - $this->getDisplayHash($commit))); + $api->getDisplayHash($commit))); return array($commit); } @@ -511,7 +511,7 @@ pht( 'Preparing merge into local target "%s", at commit "%s".', $local_ref, - $this->getDisplayHash($into_commit))); + $api->getDisplayHash($into_commit))); return $into_commit; } @@ -528,7 +528,7 @@ 'Preparing merge into "%s" from remote "%s", at commit "%s".', $target->getRef(), $target->getRemote(), - $this->getDisplayHash($commit))); + $api->getDisplayHash($commit))); return $commit; } @@ -874,7 +874,7 @@ 'bookmark', '--force', '--rev', - hgsprintf('%s', $this->getDisplayHash($new_position)), + hgsprintf('%s', $api->getDisplayHash($new_position)), '--', $bookmark_name, ); @@ -922,7 +922,7 @@ } else { $tail[] = '--force'; $tail[] = '--rev'; - $tail[] = hgsprintf('%s', $this->getDisplayHash($old_position)); + $tail[] = hgsprintf('%s', $api->getDisplayHash($old_position)); } $tail[] = '--'; diff --git a/src/repository/state/ArcanistGitLocalState.php b/src/repository/state/ArcanistGitLocalState.php --- a/src/repository/state/ArcanistGitLocalState.php +++ b/src/repository/state/ArcanistGitLocalState.php @@ -26,12 +26,12 @@ $ref = null; $where = pht( 'Saving local state (at detached commit "%s").', - $this->getDisplayHash($commit)); + $api->getDisplayHash($commit)); } else { $where = pht( 'Saving local state (on ref "%s" at commit "%s").', $ref, - $this->getDisplayHash($commit)); + $api->getDisplayHash($commit)); } $this->localRef = $ref; @@ -56,11 +56,11 @@ $where = pht( 'Restoring local state (to ref "%s" at commit "%s").', $ref, - $this->getDisplayHash($commit)); + $api->getDisplayHash($commit)); } else { $where = pht( 'Restoring local state (to detached commit "%s").', - $this->getDisplayHash($commit)); + $api->getDisplayHash($commit)); } $log->writeStatus(pht('LOAD STATE'), $where); @@ -84,6 +84,7 @@ } protected function newRestoreCommandsForDisplay() { + $api = $this->getRepositoryAPI(); $ref = $this->localRef; $commit = $this->localCommit; @@ -93,11 +94,11 @@ $commands[] = csprintf( 'git checkout -B %s %s --', $ref, - $this->getDisplayHash($commit)); + $api->getDisplayHash($commit)); } else { $commands[] = csprintf( 'git checkout %s --', - $this->getDisplayHash($commit)); + $api->getDisplayHash($commit)); } // NOTE: We run "submodule update" in the real restore workflow, but diff --git a/src/repository/state/ArcanistMercurialLocalState.php b/src/repository/state/ArcanistMercurialLocalState.php --- a/src/repository/state/ArcanistMercurialLocalState.php +++ b/src/repository/state/ArcanistMercurialLocalState.php @@ -22,7 +22,7 @@ pht('SAVE STATE'), pht( 'Saving local state (at "%s" on branch "%s").', - $this->getDisplayHash($this->localCommit), + $api->getDisplayHash($this->localCommit), $this->localBranch)); } @@ -34,7 +34,7 @@ pht('LOAD STATE'), pht( 'Restoring local state (at "%s" on branch "%s").', - $this->getDisplayHash($this->localCommit), + $api->getDisplayHash($this->localCommit), $this->localBranch)); $api->execxLocal('update -- %s', $this->localCommit); @@ -59,11 +59,12 @@ } protected function newRestoreCommandsForDisplay() { + $api = $this->getRepositoryAPI(); $commands = array(); $commands[] = csprintf( 'hg update -- %s', - $this->getDisplayHash($this->localCommit)); + $api->getDisplayHash($this->localCommit)); $commands[] = csprintf( 'hg branch --force -- %s', diff --git a/src/repository/state/ArcanistRepositoryLocalState.php b/src/repository/state/ArcanistRepositoryLocalState.php --- a/src/repository/state/ArcanistRepositoryLocalState.php +++ b/src/repository/state/ArcanistRepositoryLocalState.php @@ -256,8 +256,4 @@ echo tsprintf("\n"); } - final protected function getDisplayHash($hash) { - return substr($hash, 0, 12); - } - }