]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Remove ArcanistRepositoryAPI::setDefaultBaseCommit()
authorepriestley <git@epriestley.com>
Mon, 17 Dec 2012 20:53:38 +0000 (12:53 -0800)
committerepriestley <git@epriestley.com>
Mon, 17 Dec 2012 20:53:38 +0000 (12:53 -0800)
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

src/parser/ArcanistBaseCommitParser.php
src/parser/__tests__/ArcanistBundleTestCase.php
src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php
src/workflow/ArcanistAmendWorkflow.php
src/workflow/ArcanistPatchWorkflow.php
src/workflow/ArcanistUpgradeWorkflow.php

index 5d8a1fb9560351a1e5c9490002c5298625cab64c..215e9ee14589ed5c4f7252226b54f2b2859557e8 100644 (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;
index 747286f1eef21e73ddfb50384bfe605e69bbc541..0652e166a4d0b297bb8109197dce1ba8393b13d2 100644 (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();
index f3de626076c6984c6aae1344c43e2a29a5c39b15..87673012f45e58d854d16822b7f19f7303ff69f8 100644 (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;
index 50e28014655bfab1359bd9b82358e0eecfa56163..ecadd58d0c8f403cd09d16687d7a1eff6fb37f57 100644 (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:
index 9af523ab38522d8c423404aa4423f90b125addcb..c7a7e4055399bc2276e767b2ac3d16055b0ccecf 100644 (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);
   }
index e139d3d026c6084c33a14717999de615a17e7bc4..d3c89f1fc24f6aff4375a85c9206854d79af09fd 100644 (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);
     }
index 0aed0d221f7b8622e8ec61185fccda497cab6e2c..ceb504d696ecf1c7e97c2db3acbd87628751deca 100644 (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(
index e04a637722a159f7efc3a093abf32ce9df6698fa..d6b45646796f802f9c5e80e360553a4586e5a893 100644 (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();
 
index 348686cea543cb9573541827ed399e3f930dc73d..803fc0d2503f8b7a01a9ac7840139629f8b42547 100644 (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.