}
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';
}
'/^(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',
);
final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase {
- public function testStateParsing() {
- $dir = dirname(__FILE__).'/state/';
+ public function testGitStateParsing() {
+ if (Filesystem::binaryExists('git')) {
+ $this->parseState('git_basic.git.tgz');
+ } else {
+ $this->assertSkipped('Git is not installed');
+ }
+ }
- $tests = Filesystem::listDirectory($dir, $include_hidden = false);
- foreach ($tests as $test) {
- $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test);
+ public function testHgStateParsing() {
+ if (Filesystem::binaryExists('hg')) {
+ $this->parseState('hg_basic.hg.tgz');
+ } else {
+ $this->assertSkipped('Mercurial is not installed');
+ }
+ }
- $fixture_path = $fixture->getPath();
- $working_copy = ArcanistWorkingCopyIdentity::newFromPath($fixture_path);
+ public function testSvnStateParsing() {
+ if (Filesystem::binaryExists('svn')) {
+ $this->parseState('svn_basic.svn.tgz');
+ } else {
+ $this->assertSkipped('Subversion is not installed');
+ }
+ }
- $api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
- $working_copy);
- $api->setBaseCommitArgumentRules('arc:this');
+ private function parseState($test) {
+ $dir = dirname(__FILE__) . '/state/';
+ $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test);
- $this->assertCorrectState($test, $api);
- }
+ $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) {
"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 ".