1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00

[Arcanist] fix scratch dir for svn >= 1.7

Summary:
svn 1.7 got rid of the per-direcotry .svn dirs in favor of a single
.svn directory under the root of the working copy.  Unfortunately, we
relied on ther being a .svn directory at the same level as .arcconfig,
which may or may not be at the root of the working copy.  We now walk
up the directory tree until we find a .svn directory that we can use
for scratch files.

Test Plan:
[16:27:52 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ ls -la .arcconfig .svn ../../../.svn/arc/config
ls: .svn: No such file or directory
ls: ../../../.svn/arc/config: No such file or directory
-rw-r--r-- 1 dschleimer users 239 Jun 25 16:15 .arcconfig

[16:27:54 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ ~/devtools/arcanist/bin/arc set-config --local foo bar
Set key 'foo' = 'bar' in local config.

[16:29:40 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ ls -la .arcconfig .svn ../../../.svn/arc/config
ls: .svn: No such file or directory
-rw-r--r-- 1 dschleimer users 239 Jun 25 16:15 .arcconfig
-rw-r--r-- 1 dschleimer users  20 Jun 25 16:29 ../../../.svn/arc/config

[16:29:43 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21298 $ cat ../../../.svn/arc/config
{
  "foo" : "bar"
}

[16:29:48 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/data/admin/facebook/scripts/db
db  21299 $ ~/devtools/arcanist/bin/arc get-config foo
(global) foo =
(local) foo = bar

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1411

Differential Revision: https://secure.phabricator.com/D2856
This commit is contained in:
dschleimer 2012-06-25 17:13:29 -07:00
parent 82d05fee9f
commit acf5350221
2 changed files with 43 additions and 8 deletions

View file

@ -37,7 +37,20 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
} }
public function getMetadataPath() { public function getMetadataPath() {
return $this->getPath('.svn'); static $svn_dir = null;
if ($svn_dir === null) {
// from svn 1.7, subversion keeps a single .svn directly under
// the working copy root. However, we allow .arcconfigs that
// aren't at the working copy root.
foreach (Filesystem::walkToRoot($this->getPath()) as $parent) {
$possible_svn_dir = Filesystem::resolvePath('.svn', $parent);
if (Filesystem::pathExists($possible_svn_dir)) {
$svn_dir = $possible_svn_dir;
break;
}
}
}
return $svn_dir;
} }
protected function buildLocalFuture(array $argv) { protected function buildLocalFuture(array $argv) {

View file

@ -105,15 +105,37 @@ final class ArcanistWorkingCopyIdentity {
'.hg', '.hg',
'.svn', '.svn',
); );
$found_meta_dir = false;
foreach ($vc_dirs as $dir) { foreach ($vc_dirs as $dir) {
$local_path = Filesystem::resolvePath( $meta_path = Filesystem::resolvePath(
$dir.'/arc/config', $dir,
$this->projectRoot); $this->projectRoot);
if (Filesystem::pathExists($local_path)) { if (Filesystem::pathExists($meta_path)) {
$file = Filesystem::readFile($local_path); $found_meta_dir = true;
if ($file) { $local_path = Filesystem::resolvePath(
$this->localConfig = json_decode($file, true); 'arc/config',
break; $meta_path);
if (Filesystem::pathExists($local_path)) {
$file = Filesystem::readFile($local_path);
if ($file) {
$this->localConfig = json_decode($file, true);
}
}
break;
}
}
if (!$found_meta_dir) {
// Try for a single higher-level .svn directory as used by svn 1.7+
foreach (Filesystem::walkToRoot($this->projectRoot) as $parent_path) {
$local_path = Filesystem::resolvePath(
'.svn/arc/config',
$parent_path);
if (Filesystem::pathExists($local_path)) {
$file = Filesystem::readFile($local_path);
if ($file) {
$this->localConfig = json_decode($file, true);
}
} }
} }
} }