]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Move "relativeExplanation" to ArcanistRepositoryAPI with getters/setters
authorepriestley <git@epriestley.com>
Thu, 14 Jun 2012 19:02:41 +0000 (12:02 -0700)
committerepriestley <git@epriestley.com>
Thu, 14 Jun 2012 19:02:41 +0000 (12:02 -0700)
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

src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/workflow/ArcanistWhichWorkflow.php

index aaab2392e1facd63c7a00022945742ca5ab5a456..f69354af7f0c21d2814bb85bb3fb375defb76b50 100644 (file)
@@ -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)';
index 03d9fa195d495ce94a3e16ed7f83741136925c76..ea82a930109c7d5825499fc11d478a2da9d1710e 100644 (file)
@@ -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)';
index a049c9adb4844641864a1f894eabecfdf59dac58..59547a16d52da6cf7da52fcad152e05fe23a3d73 100644 (file)
@@ -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) {
index beaec47304a55c6bd352d9f2bd625acf11855e91..79429119eb022c78cec53d0e0169bfe5df536136 100644 (file)
@@ -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);