diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index aaab2392..f69354af 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -25,7 +25,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { private $status; private $relativeCommit = null; - private $relativeExplanation = '???'; private $repositoryHasNoCommits = false; const SEARCH_LENGTH_FOR_PARENT_REVISIONS = 16; @@ -158,9 +157,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $this->relativeCommit = self::GIT_MAGIC_ROOT_COMMIT; if ($this->repositoryHasNoCommits) { - $this->relativeExplanation = "the repository has no commits."; + $this->setBaseCommitExplanation( + "the repository has no commits."); } else { - $this->relativeExplanation = "the repository has only one commit."; + $this->setBaseCommitExplanation( + "the repository has only one commit."); } return $this->relativeCommit; @@ -172,10 +173,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if ($working_copy) { $default_relative = $working_copy->getConfig( 'git.default-relative-commit'); - $this->relativeExplanation = + $this->setBaseCommitExplanation( "it is the merge-base of '{$default_relative}' and HEAD, as ". "specified in 'git.default-relative-commit' in '.arcconfig'. This ". - "setting overrides other settings."; + "setting overrides other settings."); } if (!$default_relative) { @@ -184,9 +185,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if (!$err) { $default_relative = trim($upstream); - $this->relativeExplanation = + $this->setBaseCommitExplanation( "it is the merge-base of '{$default_relative}' (the Git upstream ". - "of the current branch) HEAD."; + "of the current branch) HEAD."); } } @@ -194,9 +195,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $default_relative = $this->readScratchFile('default-relative-commit'); $default_relative = trim($default_relative); if ($default_relative) { - $this->relativeExplanation = + $this->setBaseCommitExplanation( "it is the merge-base of '{$default_relative}' and HEAD, as ". - "specified in '.git/arc/default-relative-commit'."; + "specified in '.git/arc/default-relative-commit'."); } } @@ -247,9 +248,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { // Don't perform this write until we've verified that the object is a // valid commit name. $this->writeScratchFile('default-relative-commit', $default_relative); - $this->relativeExplanation = + $this->setBaseCommitExplanation( "it is the merge-base of '{$default_relative}' and HEAD, as you ". - "just specified."; + "just specified."); } list($merge_base) = $this->execxLocal( @@ -716,8 +717,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $base = reset($argv); if ($base == ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT) { $merge_base = $base; - $this->relativeExplanation = - "you explicitly specified the empty tree."; + $this->setBaseCommitExplanation( + "you explicitly specified the empty tree."); } else { list($err, $merge_base) = $this->execManualLocal( 'merge-base %s HEAD', @@ -726,9 +727,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { throw new ArcanistUsageException( "Unable to find any git commit named '{$base}' in this repository."); } - $this->relativeExplanation = + $this->setBaseCommitExplanation( "it is the merge-base of '{$base}' and HEAD, as you explicitly ". - "specified."; + "specified."); } $this->setRelativeCommit(trim($merge_base)); } @@ -841,10 +842,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $this->execxLocal('pull'); } - public function getRelativeExplanation() { - return $this->relativeExplanation; - } - public function getCommitSummary($commit) { if ($commit == self::GIT_MAGIC_ROOT_COMMIT) { return '(The Empty Tree)'; diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 03d9fa19..ea82a930 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -26,7 +26,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { private $status; private $base; private $relativeCommit; - private $relativeExplanation; private $workingCopyRevision; private $localCommitInfo; private $includeDirectoryStateInDiffs; @@ -113,9 +112,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { if (!$logs) { - $this->relativeExplanation = + $this->setBaseCommitExplanation( "you have no outgoing commits, so arc assumes you intend to submit ". - "uncommitted changes in the working copy."; + "uncommitted changes in the working copy."); // In Mercurial, we support operations against uncommitted changes. $this->setRelativeCommit($this->getWorkingCopyRevision()); return $this->relativeCommit; @@ -158,12 +157,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { } if ($against == 'null') { - $this->relativeExplanation = - "this is a new repository (all changes are outgoing)."; + $this->setBaseCommitExplanation( + "this is a new repository (all changes are outgoing)."); } else { - $this->relativeExplanation = + $this->setBaseCommitExplanation( "it is the first commit reachable from the working copy state ". - "which is not outgoing."; + "which is not outgoing."); } $this->setRelativeCommit($against); @@ -444,7 +443,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { throw new ArcanistUsageException("Specify only one commit."); } - $this->relativeExplanation = "you explicitly specified it."; + $this->setBaseCommitExplanation("you explicitly specified it."); // This does the "hg id" call we need to normalize/validate the revision // identifier. @@ -595,10 +594,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $this->localCommitInfo = null; } - public function getRelativeExplanation() { - return $this->relativeExplanation; - } - public function getCommitSummary($commit) { if ($commit == 'null') { return '(The Empty Void)'; diff --git a/src/repository/api/ArcanistRepositoryAPI.php b/src/repository/api/ArcanistRepositoryAPI.php index a049c9ad..59547a16 100644 --- a/src/repository/api/ArcanistRepositoryAPI.php +++ b/src/repository/api/ArcanistRepositoryAPI.php @@ -42,6 +42,7 @@ abstract class ArcanistRepositoryAPI { protected $path; protected $diffLinesOfContext = 0x7FFF; + private $baseCommitExplanation = '???'; private $workingCopyIdentity; abstract public function getSourceControlSystemName(); @@ -201,8 +202,13 @@ abstract class ArcanistRepositoryAPI { throw new ArcanistCapabilityNotSupportedException($this); } - public function getRelativeExplanation() { - throw new ArcanistCapabilityNotSupportedException($this); + public function getBaseCommitExplanation() { + return $this->baseCommitExplanation; + } + + public function setBaseCommitExplanation($explanation) { + $this->baseCommitExplanation = $explanation; + return $this; } public function getCommitSummary($commit) { diff --git a/src/workflow/ArcanistWhichWorkflow.php b/src/workflow/ArcanistWhichWorkflow.php index beaec473..79429119 100644 --- a/src/workflow/ArcanistWhichWorkflow.php +++ b/src/workflow/ArcanistWhichWorkflow.php @@ -96,7 +96,7 @@ EOTEXT $commits = ' (No commits.)'; } - $explanation = $repository_api->getRelativeExplanation(); + $explanation = $repository_api->getBaseCommitExplanation(); $relative_summary = $repository_api->getCommitSummary($relative); $relative = substr($relative, 0, 16);