1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-23 14:00:55 +01:00

Remove ArcanistRepositoryAPI::setDefaultBaseCommit()

Summary:
This method is used in three cases:

  # For unit tests, to set the range to 'HEAD^' or '.^' in an agnostic way.
  # For "amend", to set the range to the commit to be amended (also 'HEAD^' or '.^').
  # For "patch" and "upgrade" so we don't fail just because there's an invalid "base" rule somewhere in the config when doing clean-working-copy tests.

For cases (1) and (2), introduce an "arc:this" rule to mean "the current commit". For case (3), remove the call; it is no longer necessary to check the commit range in order to do tests for the working copy state after D4095.

Test Plan: Ran unit tests, "arc upgrade", "arc patch", "arc amend".

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4096
This commit is contained in:
epriestley 2012-12-17 12:53:38 -08:00
parent 0e27dbfd17
commit 2ae0cb797d
9 changed files with 20 additions and 43 deletions

View file

@ -151,6 +151,7 @@ final class ArcanistBaseCommitParser {
case 'outgoing':
case 'bookmark':
case 'amended':
case 'this':
return $this->api->resolveBaseCommitRule($rule, $source);
default:
$matches = null;

View file

@ -58,8 +58,12 @@ final class ArcanistBundleTestCase extends ArcanistTestCase {
list($commit_hash, $tree_hash, $subject) = explode(' ', $commit, 3);
execx('git reset --hard %s --', $commit_hash);
$repository_api = new ArcanistGitAPI($fixture->getPath());
$repository_api->setDefaultBaseCommit();
$fixture_path = $fixture->getPath();
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($fixture_path);
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
$working_copy);
$repository_api->setBaseCommitArgumentRules('arc:this');
$diff = $repository_api->getFullGitDiff();
$parser = new ArcanistDiffParser();

View file

@ -715,11 +715,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return true;
}
public function setDefaultBaseCommit() {
$this->setRelativeCommit('HEAD^');
return $this;
}
public function hasLocalCommit($commit) {
try {
if (!$this->getCanonicalRevisionName($commit)) {
@ -987,6 +982,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return $upstream_merge_base;
}
break;
case 'this':
$this->setBaseCommitExplanation(
"you specified '{$rule}' in your {$source} 'base' ".
"configuration.");
return 'HEAD^';
}
default:
return null;

View file

@ -442,11 +442,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
return true;
}
public function setDefaultBaseCommit() {
$this->setRelativeCommit('.^');
return $this;
}
public function hasLocalCommit($commit) {
try {
$this->getCanonicalRevisionName($commit);
@ -734,6 +729,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
"your {$source} 'base' configuration");
return trim($bookmark_base);
}
break;
case 'this':
$this->setBaseCommitExplanation(
"you specified '{$rule}' in your {$source} 'base' ".
"configuration.");
return '.^';
}
break;
default:

View file

@ -322,21 +322,6 @@ abstract class ArcanistRepositoryAPI {
return $this->getWorkingCopyRevision();
}
/**
* Set the base commit to a reasonable default value so that working copy
* status checks can do something meaningful and won't invoke configured
* 'base' rules.
*
* This is primarily useful for workflows which do not operate on commit
* ranges but need to verify the working copy is not dirty, like "amend",
* "upgrade" and "patch".
*
* @return this
*/
public function setDefaultBaseCommit() {
throw new ArcanistCapabilityNotSupportedException($this);
}
public function getChangedFiles($since_commit) {
throw new ArcanistCapabilityNotSupportedException($this);
}

View file

@ -14,10 +14,7 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase {
$api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
$working_copy);
if ($api->supportsRelativeLocalCommits()) {
$api->setDefaultBaseCommit();
}
$api->setBaseCommitArgumentRules('arc:this');
$this->assertCorrectState($test, $api);
}

View file

@ -90,10 +90,7 @@ EOTEXT
$revision_id = $this->normalizeRevisionID($this->getArgument('revision'));
}
if ($repository_api->supportsRelativeLocalCommits()) {
$repository_api->setDefaultBaseCommit();
}
$repository_api->setBaseCommitArgumentRules('arc:this');
$in_working_copy = $repository_api->loadWorkingCopyDifferentialRevisions(
$this->getConduit(),
array(

View file

@ -853,10 +853,6 @@ EOTEXT
private function sanityCheck(ArcanistBundle $bundle) {
$repository_api = $this->getRepositoryAPI();
if ($repository_api->supportsRelativeLocalCommits()) {
$repository_api->setDefaultBaseCommit();
}
// Require clean working copy
$this->requireCleanWorkingCopy();

View file

@ -50,10 +50,6 @@ EOTEXT
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
$working_copy);
if ($repository_api->supportsRelativeLocalCommits()) {
$repository_api->setDefaultBaseCommit();
}
$this->setRepositoryAPI($repository_api);
// Require no local changes.