diff --git a/.gitignore b/.gitignore index 8e146282..6707f606 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ /src/.phutil_module_cache /docs/ /.divinercache/ -/.arc/ diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 21a5ffc7..aaab2392 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -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'."; } } diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index fa5c74c6..03d9fa19 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -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()); } diff --git a/src/repository/api/ArcanistRepositoryAPI.php b/src/repository/api/ArcanistRepositoryAPI.php index 9440c89e..a049c9ad 100644 --- a/src/repository/api/ArcanistRepositoryAPI.php +++ b/src/repository/api/ArcanistRepositoryAPI.php @@ -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); } } diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index ee27665a..0c165a62 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -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];