public function testSVNURINormalizer()
 {
     $cases = array('file:///path/to/repo' => 'path/to/repo', 'file:///path/to/repo/' => 'path/to/repo');
     $type_svn = PhabricatorRepositoryURINormalizer::TYPE_SVN;
     foreach ($cases as $input => $expect) {
         $normal = new PhabricatorRepositoryURINormalizer($type_svn, $input);
         $this->assertEqual($expect, $normal->getNormalizedPath(), pht('Normalized SVN path for "%s".', $input));
     }
 }
 public function getNormalizedPath()
 {
     $uri = (string) $this->getCloneURIObject();
     switch ($this->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
             $normalized_uri = new PhabricatorRepositoryURINormalizer(PhabricatorRepositoryURINormalizer::TYPE_GIT, $uri);
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             $normalized_uri = new PhabricatorRepositoryURINormalizer(PhabricatorRepositoryURINormalizer::TYPE_SVN, $uri);
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
             $normalized_uri = new PhabricatorRepositoryURINormalizer(PhabricatorRepositoryURINormalizer::TYPE_MERCURIAL, $uri);
             break;
         default:
             throw new Exception(pht('Unrecognized version control system.'));
     }
     return $normalized_uri->getNormalizedPath();
 }
 public function getNormalizedURI()
 {
     $vcs = $this->getRepository()->getVersionControlSystem();
     $map = array(PhabricatorRepositoryType::REPOSITORY_TYPE_GIT => PhabricatorRepositoryURINormalizer::TYPE_GIT, PhabricatorRepositoryType::REPOSITORY_TYPE_SVN => PhabricatorRepositoryURINormalizer::TYPE_SVN, PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL => PhabricatorRepositoryURINormalizer::TYPE_MERCURIAL);
     $type = $map[$vcs];
     $display = (string) $this->getDisplayURI();
     $normal_uri = new PhabricatorRepositoryURINormalizer($type, $display);
     return $normal_uri->getNormalizedURI();
 }
 private function getNormalizedURIs()
 {
     $normalized_uris = array();
     // Since we don't know which type of repository this URI is in the general
     // case, just generate all the normalizations. We could refine this in some
     // cases: if the query specifies VCS types, or the URI is a git-style URI
     // or an `svn+ssh` URI, we could deduce how to normalize it. However, this
     // would be more complicated and it's not clear if it matters in practice.
     $types = PhabricatorRepositoryURINormalizer::getAllURITypes();
     foreach ($this->uris as $uri) {
         foreach ($types as $type) {
             $normalized_uri = new PhabricatorRepositoryURINormalizer($type, $uri);
             $normalized_uris[] = $normalized_uri->getNormalizedURI();
         }
     }
     return array_unique($normalized_uris);
 }