private function verifySubversionRoot(PhabricatorRepository $repository)
 {
     list($xml) = $repository->execxRemoteCommand('info --xml %s', $repository->getSubversionPathURI());
     $xml = phutil_utf8ize($xml);
     $xml = new SimpleXMLElement($xml);
     $remote_root = (string) $xml->entry[0]->repository[0]->root[0];
     $expect_root = $repository->getSubversionPathURI();
     $normal_type_svn = PhabricatorRepositoryURINormalizer::TYPE_SVN;
     $remote_normal = id(new PhabricatorRepositoryURINormalizer($normal_type_svn, $remote_root))->getNormalizedPath();
     $expect_normal = id(new PhabricatorRepositoryURINormalizer($normal_type_svn, $expect_root))->getNormalizedPath();
     if ($remote_normal != $expect_normal) {
         throw new Exception(pht('Repository "%s" does not have a correctly configured remote URI. ' . 'The remote URI for a Subversion repository MUST point at the ' . 'repository root. The root for this repository is "%s", but the ' . 'configured URI is "%s". To resolve this error, set the remote URI ' . 'to point at the repository root. If you want to import only part ' . 'of a Subversion repository, use the "Import Only" option.', $repository->getDisplayName(), $remote_root, $expect_root));
     }
 }
 protected function executeCreate(PhabricatorRepository $repository, $local_path)
 {
     $repository->execxRemoteCommand('clone --origin origin %s %s', $repository->getRemoteURI(), rtrim($local_path, '/'));
 }
 /**
  * @task hg
  */
 private function executeHgCreate(PhabricatorRepository $repository, $path)
 {
     $repository->execxRemoteCommand('clone %s %s', $repository->getRemoteURI(), rtrim($path, '/'));
 }
 private function getSVNLogXMLObject(PhabricatorRepository $repository, $uri, $revision)
 {
     list($xml) = $repository->execxRemoteCommand('log --xml --verbose --limit 1 %s@%d', $uri, $revision);
     // Subversion may send us back commit messages which won't parse because
     // they have non UTF-8 garbage in them. Slam them into valid UTF-8.
     $xml = phutil_utf8ize($xml);
     return new SimpleXMLElement($xml);
 }
 private function lookupRecursiveFileList(PhabricatorRepository $repository, array $info)
 {
     $path = $info['rawPath'];
     $rev = $info['rawCommit'];
     $path = $this->encodeSVNPath($path);
     $hashkey = md5($repository->getDetail('remote-uri') . $path . '@' . $rev);
     // This method is quite horrible. The underlying challenge is that some
     // commits in the Facebook repository are enormous, taking multiple hours
     // to 'ls -R' out of the repository and producing XML files >1GB in size.
     // If we try to SimpleXML them, the object exhausts available memory on a
     // 64G machine. Instead, cache the XML output and then parse it line by line
     // to limit space requirements.
     $cache_loc = sys_get_temp_dir() . '/diffusion.' . $hashkey . '.svnls';
     if (!Filesystem::pathExists($cache_loc)) {
         $tmp = new TempFile();
         $repository->execxRemoteCommand('--xml ls -R %s%s@%d > %s', $repository->getDetail('remote-uri'), $path, $rev, $tmp);
         execx('mv %s %s', $tmp, $cache_loc);
     }
     $map = $this->parseRecursiveListFileData($cache_loc);
     Filesystem::remove($cache_loc);
     return $map;
 }