diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index 7206e311..8a32378b 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -233,6 +233,13 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { } public function getBranchName() { + $info = $this->getSVNInfo('/'); + $repo_root = idx($info, 'Repository Root'); + $repo_root_length = strlen($repo_root); + $url = idx($info, 'URL'); + if (substr($url, 0, $repo_root_length) == $repo_root) { + return substr($url, $repo_root_length); + } return 'svn'; } @@ -329,6 +336,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { '/^(Last Changed Date): (.+) \(.+\)$/m', '/^(Copied From URL): (\S+)$/m', '/^(Copied From Rev): (\d+)$/m', + '/^(Repository Root): (\S+)$/m', '/^(Repository UUID): (\S+)$/m', '/^(Node Kind): (\S+)$/m', ); diff --git a/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php b/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php index d3c89f1f..13c82203 100644 --- a/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php +++ b/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php @@ -2,24 +2,44 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase { - public function testStateParsing() { - $dir = dirname(__FILE__).'/state/'; - - $tests = Filesystem::listDirectory($dir, $include_hidden = false); - foreach ($tests as $test) { - $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test); - - $fixture_path = $fixture->getPath(); - $working_copy = ArcanistWorkingCopyIdentity::newFromPath($fixture_path); - - $api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity( - $working_copy); - $api->setBaseCommitArgumentRules('arc:this'); - - $this->assertCorrectState($test, $api); + public function testGitStateParsing() { + if (Filesystem::binaryExists('git')) { + $this->parseState('git_basic.git.tgz'); + } else { + $this->assertSkipped('Git is not installed'); } } + public function testHgStateParsing() { + if (Filesystem::binaryExists('hg')) { + $this->parseState('hg_basic.hg.tgz'); + } else { + $this->assertSkipped('Mercurial is not installed'); + } + } + + public function testSvnStateParsing() { + if (Filesystem::binaryExists('svn')) { + $this->parseState('svn_basic.svn.tgz'); + } else { + $this->assertSkipped('Subversion is not installed'); + } + } + + private function parseState($test) { + $dir = dirname(__FILE__) . '/state/'; + $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test); + + $fixture_path = $fixture->getPath(); + $working_copy = ArcanistWorkingCopyIdentity::newFromPath($fixture_path); + + $api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity( + $working_copy); + $api->setBaseCommitArgumentRules('arc:this'); + + $this->assertCorrectState($test, $api); + } + private function assertCorrectState($test, ArcanistRepositoryAPI $api) { $f_mod = ArcanistRepositoryAPI::FLAG_MODIFIED; $f_add = ArcanistRepositoryAPI::FLAG_ADDED; diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index 45243ac9..e54ad9ce 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -320,8 +320,8 @@ EOTEXT "Commit this revision anyway?"; } - $revision_source = idx($revision, 'sourcePath'); - $current_source = $repository_api->getPath(); + $revision_source = idx($revision, 'branch'); + $current_source = $repository_api->getSourceControlPath(); if ($revision_source != $current_source) { $confirm[] = "Revision 'D{$revision_id}: {$revision_title}' was generated from ".