]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow configuration of a weak per-project default relative commit
authorepriestley <git@epriestley.com>
Tue, 3 Apr 2012 23:06:43 +0000 (16:06 -0700)
committerepriestley <git@epriestley.com>
Tue, 3 Apr 2012 23:06:43 +0000 (16:06 -0700)
Summary: Allows you to set a default in .arcconfig. This default is overriden by any .arc/ setting.

Test Plan: Ran "arc diff" with a .arcconfig setting but no .arc/ setting, got a diff against the specified relative commit.

Reviewers: nh, btrahan

Reviewed By: nh

CC: aran
Differential Revision: https://secure.phabricator.com/D2093

src/repository/api/base/ArcanistRepositoryAPI.php
src/repository/api/git/ArcanistGitAPI.php

index 1b5c7d2346a6e88103599bf084a95e2b49f09029..f40dab4ae65cd3af23a0347d0f943b306f0a3a94 100644 (file)
@@ -42,6 +42,7 @@ abstract class ArcanistRepositoryAPI {
 
   protected $path;
   protected $diffLinesOfContext = 0x7FFF;
+  private $workingCopyIdentity;
 
   abstract public function getSourceControlSystemName();
 
@@ -54,6 +55,10 @@ abstract class ArcanistRepositoryAPI {
     return $this;
   }
 
+  public function getWorkingCopyIdentity() {
+    return $this->workingCopyIdentity;
+  }
+
   public static function newAPIFromWorkingCopyIdentity(
     ArcanistWorkingCopyIdentity $working_copy) {
 
@@ -68,11 +73,15 @@ abstract class ArcanistRepositoryAPI {
     // check if we're in an svn working copy
     list($err) = exec_manual('svn info');
     if (!$err) {
-      return newv('ArcanistSubversionAPI', array($root));
+      $api = newv('ArcanistSubversionAPI', array($root));
+      $api->workingCopyIdentity = $working_copy;
+      return $api;
     }
 
     if (Filesystem::pathExists($root.'/.hg')) {
-      return newv('ArcanistMercurialAPI', array($root));
+      $api = newv('ArcanistMercurialAPI', array($root));
+      $api->workingCopyIdentity = $working_copy;
+      return $api;
     }
 
     $git_root = self::discoverGitBaseDirectory($root);
@@ -83,7 +92,9 @@ abstract class ArcanistRepositoryAPI {
           "is '{$git_root}'. Move '.arcconfig' file to the working copy root.");
       }
 
-      return newv('ArcanistGitAPI', array($root));
+      $api = newv('ArcanistGitAPI', array($root));
+      $api->workingCopyIdentity = $working_copy;
+      return $api;
     }
 
     throw new ArcanistUsageException(
index 9f1bbe502652d8c96ec9728ad76b47ff3c209043..9a0ca790fadae556e45e629fd7a0825de62c73b6 100644 (file)
@@ -130,6 +130,15 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
 
       $default_relative = $this->readScratchFile('default-relative-commit');
       $do_write = false;
+
+      if (!$default_relative) {
+        $working_copy = $this->getWorkingCopyIdentity();
+        if ($working_copy) {
+          $default_relative = $working_copy->getConfig(
+            'git.default-relative-commit');
+        }
+      }
+
       if (!$default_relative) {
 
         // TODO: Remove the history lesson soon.