]> khamidou — GitHub mirrors - arcanist.git/commitdiff
[Arcanist] move scratch directory into the vcs metadata directory
authordschleimer <dschleimer@fb.com>
Tue, 12 Jun 2012 19:39:15 +0000 (12:39 -0700)
committerdschleimer <dschleimer@fb.com>
Tue, 12 Jun 2012 19:39:15 +0000 (12:39 -0700)
Summary:
Using .arc as the scratch and per-repository configuration directory
has some unfortunate consequenses in the real world.  Among other
things, people forget to .gitignore it so it gets checked in.

Test Plan:
the only thing that seems to use this is the relative commit setting
for git.  This diff consists of 2 commits, one for the .gitignore and
one for everything else.

Comment out the portion of my .git/config that defines the upstream
for the branch.  Run arc diff --only with HEAD^ in
.arc/default-relative-commit.  See that .gitignore is not included in
the resultant diff, that .arc no longer exists, and that .git/arc
exists and has HEAD^ in .git/arc/default-relative-commit.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T1233

Differential Revision: https://secure.phabricator.com/D2725

.gitignore
src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/repository/api/ArcanistSubversionAPI.php

index 8e146282c516789364c1e13354de4cc10ff6c50f..6707f606ab252e8aae154081216d67c2cec8dc0f 100644 (file)
@@ -3,4 +3,3 @@
 /src/.phutil_module_cache
 /docs/
 /.divinercache/
-/.arc/
index 21a5ffc7a3c16e16de0be995283fe55c177c76b2..aaab2392e1facd63c7a00022945742ca5ab5a456 100644 (file)
@@ -53,6 +53,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
     return 'git';
   }
 
+  public function getMetadataPath() {
+    return $this->getPath('.git');
+  }
+
   public function getHasCommits() {
     return !$this->repositoryHasNoCommits;
   }
@@ -192,7 +196,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
         if ($default_relative) {
           $this->relativeExplanation =
             "it is the merge-base of '{$default_relative}' and HEAD, as ".
-            "specified in '.arc/default-relative-commit'.";
+            "specified in '.git/arc/default-relative-commit'.";
         }
       }
 
index fa5c74c60cd0c28389bc30b4a2fa1a57fbe4a2bf..03d9fa195d495ce94a3e16ed7f83741136925c76 100644 (file)
@@ -58,6 +58,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
     return 'hg';
   }
 
+  public function getMetadataPath() {
+    return $this->getPath('.hg');
+  }
+
   public function getSourceControlBaseRevision() {
     return $this->getCanonicalRevisionName($this->getRelativeCommit());
   }
index 9440c89e2655539c4eb0cad05810aa42f4b46412..a049c9adb4844641864a1f894eabecfdf59dac58 100644 (file)
@@ -175,6 +175,7 @@ abstract class ArcanistRepositoryAPI {
   abstract public function supportsRelativeLocalCommits();
   abstract public function getWorkingCopyRevision();
   abstract public function updateWorkingCopy();
+  abstract public function getMetadataPath();
   abstract public function loadWorkingCopyDifferentialRevisions(
     ConduitClient $conduit,
     array $query);
@@ -353,7 +354,32 @@ abstract class ArcanistRepositoryAPI {
    * @task scratch
    */
   public function getScratchFilePath($path) {
-    return $this->getPath('.arc/'.$path);
+    $new_scratch_path  = Filesystem::resolvePath(
+      'arc',
+      $this->getMetadataPath());
+
+    static $checked = false;
+    if (!$checked) {
+      $checked = true;
+      $old_scratch_path = $this->getPath('.arc');
+      // we only want to do the migration once
+      // unfortunately, people have checked in .arc directories which
+      // means that the old one may get recreated after we delete it
+      if (Filesystem::pathExists($old_scratch_path) &&
+          !Filesystem::pathExists($new_scratch_path)) {
+        Filesystem::createDirectory($new_scratch_path);
+        $existing_files = Filesystem::listDirectory($old_scratch_path, true);
+        foreach ($existing_files as $file) {
+          $new_path = Filesystem::resolvePath($file, $new_scratch_path);
+          $old_path = Filesystem::resolvePath($file, $old_scratch_path);
+          Filesystem::writeFile(
+            $new_path,
+            Filesystem::readFile($old_path));
+        }
+        Filesystem::remove($old_scratch_path);
+      }
+    }
+    return Filesystem::resolvePath($path, $new_scratch_path);
   }
 
 }
index ee27665a290adf857f0d1af3cab9b803fa7c935a..0c165a621d8b2f30cbb9118d0cfb20e7337f4b05 100644 (file)
@@ -36,6 +36,10 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
     return 'svn';
   }
 
+  public function getMetadataPath() {
+    return $this->getPath('.svn');
+  }
+
   protected function buildLocalFuture(array $argv) {
 
     $argv[0] = 'svn '.$argv[0];