mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Move "relativeExplanation" to ArcanistRepositoryAPI with getters/setters
Summary: We currently use the language "relative commit" or "relative local commit" to refer to the head of a commit range. I want to move toward callign this a "base commit", since I think that makes more sense. This moves us a small step in that direction. The DSL stuff in T1233 also needs access to this stuff, so move it up to the base. This is mostly a bite-sized piece of the change in that diff. Test Plan: Ran "arc which" in a couple of circumstances, read explanations. Reviewers: dschleimer, vrana Reviewed By: dschleimer CC: aran Maniphest Tasks: T1233 Differential Revision: https://secure.phabricator.com/D2747
This commit is contained in:
parent
0120d9b6e6
commit
c5b7afb344
4 changed files with 32 additions and 34 deletions
|
@ -25,7 +25,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
|
|
||||||
private $status;
|
private $status;
|
||||||
private $relativeCommit = null;
|
private $relativeCommit = null;
|
||||||
private $relativeExplanation = '???';
|
|
||||||
private $repositoryHasNoCommits = false;
|
private $repositoryHasNoCommits = false;
|
||||||
const SEARCH_LENGTH_FOR_PARENT_REVISIONS = 16;
|
const SEARCH_LENGTH_FOR_PARENT_REVISIONS = 16;
|
||||||
|
|
||||||
|
@ -158,9 +157,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
$this->relativeCommit = self::GIT_MAGIC_ROOT_COMMIT;
|
$this->relativeCommit = self::GIT_MAGIC_ROOT_COMMIT;
|
||||||
|
|
||||||
if ($this->repositoryHasNoCommits) {
|
if ($this->repositoryHasNoCommits) {
|
||||||
$this->relativeExplanation = "the repository has no commits.";
|
$this->setBaseCommitExplanation(
|
||||||
|
"the repository has no commits.");
|
||||||
} else {
|
} else {
|
||||||
$this->relativeExplanation = "the repository has only one commit.";
|
$this->setBaseCommitExplanation(
|
||||||
|
"the repository has only one commit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->relativeCommit;
|
return $this->relativeCommit;
|
||||||
|
@ -172,10 +173,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
if ($working_copy) {
|
if ($working_copy) {
|
||||||
$default_relative = $working_copy->getConfig(
|
$default_relative = $working_copy->getConfig(
|
||||||
'git.default-relative-commit');
|
'git.default-relative-commit');
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"it is the merge-base of '{$default_relative}' and HEAD, as ".
|
"it is the merge-base of '{$default_relative}' and HEAD, as ".
|
||||||
"specified in 'git.default-relative-commit' in '.arcconfig'. This ".
|
"specified in 'git.default-relative-commit' in '.arcconfig'. This ".
|
||||||
"setting overrides other settings.";
|
"setting overrides other settings.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$default_relative) {
|
if (!$default_relative) {
|
||||||
|
@ -184,9 +185,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
|
|
||||||
if (!$err) {
|
if (!$err) {
|
||||||
$default_relative = trim($upstream);
|
$default_relative = trim($upstream);
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"it is the merge-base of '{$default_relative}' (the Git upstream ".
|
"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 = $this->readScratchFile('default-relative-commit');
|
||||||
$default_relative = trim($default_relative);
|
$default_relative = trim($default_relative);
|
||||||
if ($default_relative) {
|
if ($default_relative) {
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"it is the merge-base of '{$default_relative}' and HEAD, as ".
|
"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
|
// Don't perform this write until we've verified that the object is a
|
||||||
// valid commit name.
|
// valid commit name.
|
||||||
$this->writeScratchFile('default-relative-commit', $default_relative);
|
$this->writeScratchFile('default-relative-commit', $default_relative);
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"it is the merge-base of '{$default_relative}' and HEAD, as you ".
|
"it is the merge-base of '{$default_relative}' and HEAD, as you ".
|
||||||
"just specified.";
|
"just specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
list($merge_base) = $this->execxLocal(
|
list($merge_base) = $this->execxLocal(
|
||||||
|
@ -716,8 +717,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
$base = reset($argv);
|
$base = reset($argv);
|
||||||
if ($base == ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT) {
|
if ($base == ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT) {
|
||||||
$merge_base = $base;
|
$merge_base = $base;
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"you explicitly specified the empty tree.";
|
"you explicitly specified the empty tree.");
|
||||||
} else {
|
} else {
|
||||||
list($err, $merge_base) = $this->execManualLocal(
|
list($err, $merge_base) = $this->execManualLocal(
|
||||||
'merge-base %s HEAD',
|
'merge-base %s HEAD',
|
||||||
|
@ -726,9 +727,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
"Unable to find any git commit named '{$base}' in this repository.");
|
"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 ".
|
"it is the merge-base of '{$base}' and HEAD, as you explicitly ".
|
||||||
"specified.";
|
"specified.");
|
||||||
}
|
}
|
||||||
$this->setRelativeCommit(trim($merge_base));
|
$this->setRelativeCommit(trim($merge_base));
|
||||||
}
|
}
|
||||||
|
@ -841,10 +842,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
$this->execxLocal('pull');
|
$this->execxLocal('pull');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRelativeExplanation() {
|
|
||||||
return $this->relativeExplanation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCommitSummary($commit) {
|
public function getCommitSummary($commit) {
|
||||||
if ($commit == self::GIT_MAGIC_ROOT_COMMIT) {
|
if ($commit == self::GIT_MAGIC_ROOT_COMMIT) {
|
||||||
return '(The Empty Tree)';
|
return '(The Empty Tree)';
|
||||||
|
|
|
@ -26,7 +26,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
private $status;
|
private $status;
|
||||||
private $base;
|
private $base;
|
||||||
private $relativeCommit;
|
private $relativeCommit;
|
||||||
private $relativeExplanation;
|
|
||||||
private $workingCopyRevision;
|
private $workingCopyRevision;
|
||||||
private $localCommitInfo;
|
private $localCommitInfo;
|
||||||
private $includeDirectoryStateInDiffs;
|
private $includeDirectoryStateInDiffs;
|
||||||
|
@ -113,9 +112,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
|
|
||||||
if (!$logs) {
|
if (!$logs) {
|
||||||
|
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"you have no outgoing commits, so arc assumes you intend to submit ".
|
"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.
|
// In Mercurial, we support operations against uncommitted changes.
|
||||||
$this->setRelativeCommit($this->getWorkingCopyRevision());
|
$this->setRelativeCommit($this->getWorkingCopyRevision());
|
||||||
return $this->relativeCommit;
|
return $this->relativeCommit;
|
||||||
|
@ -158,12 +157,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($against == 'null') {
|
if ($against == 'null') {
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"this is a new repository (all changes are outgoing).";
|
"this is a new repository (all changes are outgoing).");
|
||||||
} else {
|
} else {
|
||||||
$this->relativeExplanation =
|
$this->setBaseCommitExplanation(
|
||||||
"it is the first commit reachable from the working copy state ".
|
"it is the first commit reachable from the working copy state ".
|
||||||
"which is not outgoing.";
|
"which is not outgoing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setRelativeCommit($against);
|
$this->setRelativeCommit($against);
|
||||||
|
@ -444,7 +443,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
throw new ArcanistUsageException("Specify only one commit.");
|
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
|
// This does the "hg id" call we need to normalize/validate the revision
|
||||||
// identifier.
|
// identifier.
|
||||||
|
@ -595,10 +594,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
$this->localCommitInfo = null;
|
$this->localCommitInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRelativeExplanation() {
|
|
||||||
return $this->relativeExplanation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCommitSummary($commit) {
|
public function getCommitSummary($commit) {
|
||||||
if ($commit == 'null') {
|
if ($commit == 'null') {
|
||||||
return '(The Empty Void)';
|
return '(The Empty Void)';
|
||||||
|
|
|
@ -42,6 +42,7 @@ abstract class ArcanistRepositoryAPI {
|
||||||
|
|
||||||
protected $path;
|
protected $path;
|
||||||
protected $diffLinesOfContext = 0x7FFF;
|
protected $diffLinesOfContext = 0x7FFF;
|
||||||
|
private $baseCommitExplanation = '???';
|
||||||
private $workingCopyIdentity;
|
private $workingCopyIdentity;
|
||||||
|
|
||||||
abstract public function getSourceControlSystemName();
|
abstract public function getSourceControlSystemName();
|
||||||
|
@ -201,8 +202,13 @@ abstract class ArcanistRepositoryAPI {
|
||||||
throw new ArcanistCapabilityNotSupportedException($this);
|
throw new ArcanistCapabilityNotSupportedException($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRelativeExplanation() {
|
public function getBaseCommitExplanation() {
|
||||||
throw new ArcanistCapabilityNotSupportedException($this);
|
return $this->baseCommitExplanation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBaseCommitExplanation($explanation) {
|
||||||
|
$this->baseCommitExplanation = $explanation;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommitSummary($commit) {
|
public function getCommitSummary($commit) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ EOTEXT
|
||||||
$commits = ' (No commits.)';
|
$commits = ' (No commits.)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$explanation = $repository_api->getRelativeExplanation();
|
$explanation = $repository_api->getBaseCommitExplanation();
|
||||||
|
|
||||||
$relative_summary = $repository_api->getCommitSummary($relative);
|
$relative_summary = $repository_api->getCommitSummary($relative);
|
||||||
$relative = substr($relative, 0, 16);
|
$relative = substr($relative, 0, 16);
|
||||||
|
|
Loading…
Reference in a new issue