1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +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 'outgoing':
case 'bookmark': case 'bookmark':
case 'amended': case 'amended':
case 'this':
return $this->api->resolveBaseCommitRule($rule, $source); return $this->api->resolveBaseCommitRule($rule, $source);
default: default:
$matches = null; $matches = null;

View file

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

View file

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

View file

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

View file

@ -322,21 +322,6 @@ abstract class ArcanistRepositoryAPI {
return $this->getWorkingCopyRevision(); 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) { public function getChangedFiles($since_commit) {
throw new ArcanistCapabilityNotSupportedException($this); throw new ArcanistCapabilityNotSupportedException($this);
} }

View file

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

View file

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

View file

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

View file

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