Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Arcanist] move scratch directory into the vcs metadata directory

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
  • Loading branch information...
commit 1100e8768a9cbb2caa1ddb2545b119e4b5b86344 1 parent 6d98ac0
@dschleimer dschleimer authored
View
1  .gitignore
@@ -3,4 +3,3 @@
/src/.phutil_module_cache
/docs/
/.divinercache/
-/.arc/
View
6 src/repository/api/ArcanistGitAPI.php
@@ -53,6 +53,10 @@ public function getSourceControlSystemName() {
return 'git';
}
+ public function getMetadataPath() {
+ return $this->getPath('.git');
+ }
+
public function getHasCommits() {
return !$this->repositoryHasNoCommits;
}
@@ -192,7 +196,7 @@ public function getRelativeCommit() {
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'.";
}
}
View
4 src/repository/api/ArcanistMercurialAPI.php
@@ -58,6 +58,10 @@ public function getSourceControlSystemName() {
return 'hg';
}
+ public function getMetadataPath() {
+ return $this->getPath('.hg');
+ }
+
public function getSourceControlBaseRevision() {
return $this->getCanonicalRevisionName($this->getRelativeCommit());
}
View
28 src/repository/api/ArcanistRepositoryAPI.php
@@ -175,6 +175,7 @@ private static function discoverGitBaseDirectory($root) {
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 @@ public function getReadableScratchFilePath($path) {
* @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);
}
}
View
4 src/repository/api/ArcanistSubversionAPI.php
@@ -36,6 +36,10 @@ public function getSourceControlSystemName() {
return 'svn';
}
+ public function getMetadataPath() {
+ return $this->getPath('.svn');
+ }
+
protected function buildLocalFuture(array $argv) {
$argv[0] = 'svn '.$argv[0];
Please sign in to comment.
Something went wrong with that request. Please try again.