/**
  * List the directory at a given version
  *
  * @param   string  $directory      The path ot the directory
  * @param   string  $ref            The version ref
  * @return  array
  * @throws  \RuntimeException
  */
 public function listDirectory($directory = '.', $ref = 'HEAD')
 {
     $directory = FileSystem::normalizeDirectorySeparator($directory);
     $directory = rtrim($directory, '/') . '/';
     $args = array('--xml', '--revision' => $ref, $this->resolveLocalPath($directory));
     /** @var $result CallResult */
     $result = $this->getSvn()->{'list'}($this->getRepositoryPath(), $args);
     $result->assertSuccess(sprintf('Cannot list directory "%s" at "%s" from "%s"', $directory, $ref, $this->getRepositoryPath()));
     $xml = simplexml_load_string($result->getStdOut());
     if (!$xml) {
         throw new \RuntimeException(sprintf('Cannot read list XML for "%s" at "%s" from "%s"', $directory, $ref, $this->getRepositoryPath()));
     }
     $list = array();
     foreach ($xml->xpath('/lists/list/entry') as $item) {
         $list[] = (string) $item->name;
     }
     return $list;
 }
 /**
  * List the directory at a given version
  *
  * @param   string  $directory      The path ot the directory
  * @param   string  $ref            The version ref
  * @return  array
  */
 public function listDirectory($directory = '.', $ref = 'HEAD')
 {
     $directory = FileSystem::normalizeDirectorySeparator($directory);
     $directory = $this->resolveLocalPath(rtrim($directory, '/') . '/');
     $path = $this->getRepositoryPath();
     /** @var $result CallResult */
     $result = $this->getGit()->{'ls-tree'}($path, array('--name-only', '--full-name', '-z', '-r', $ref, $directory));
     $result->assertSuccess(sprintf('Cannot list directory "%s" at "%s" from "%s"', $directory, $ref, $this->getRepositoryPath()));
     $output = $result->getStdOut();
     $listing = array_map(function ($f) use($directory) {
         return str_replace($directory, '', trim($f));
     }, explode("", $output));
     return $listing;
 }
 /**
  * Resolves a path relative to the repository into an absolute path
  *
  * @param   string|array  $path     A local path (or an array of paths)
  * @return  string|array            Either a single path or an array of paths is returned
  */
 public function resolveFullPath($path)
 {
     if (is_array($path)) {
         $paths = array();
         foreach ($path as $p) {
             $paths[] = $this->resolveFullPath($p);
         }
         return $paths;
     } else {
         if (strpos($path, $this->getRepositoryPath()) === 0) {
             return $path;
         }
         $path = FileSystem::normalizeDirectorySeparator($path);
         $path = ltrim($path, '/');
         return $this->getRepositoryPath() . '/' . $path;
     }
 }