/** * Parse the Xml result from Subversion * * @param string $output * @param array $arguments * @return array */ public function parseListOutput($output, array $arguments = array()) { if (!isset($arguments['--xml']) || false === $arguments['--xml']) { // non xml results are not supported return $output; } $head = $this->getClient()->getHead(); $sxml = simplexml_load_string($output); $retval = array(); foreach ($sxml->xpath('//entry') as $item) { $filename = (string) $item->name; $kind = (string) $item->attributes()->kind; $revision = (string) $item->commit->attributes()->revision; $date = (string) $item->commit->date; $author = (string) $item->commit->author; $commit = new Commit($revision, new \DateTime($date), $author); $file = new VcsFileInfo($filename, $head, $kind); $file->setCommit($commit); $retval[] = $file; } return $retval; }
/** * (non-PHPdoc) * @see Webcreate\Vcs.VcsInterface::ls() */ public function ls($path) { if (!$this->hasCheckout) { $this->checkout(); } if ($path == '/') { $path = ''; } if (false === file_exists($this->cwd . '/' . $path)) { throw new NotFoundException(sprintf('The path \'%s\' is not found in %s', $path, $this->cwd)); } $finder = new Finder(); $files = $finder->in($this->cwd . '/' . $path)->exclude(".git")->ignoreDotFiles(false)->depth('== 0'); $filelist = array(); $entries = array(); foreach ($files as $file) { $log = $this->log(($path ? $path . '/' : '') . $file->getRelativePathname(), null, 1); $commit = reset($log); $kind = $file->isDir() ? VcsFileInfo::DIR : VcsFileInfo::FILE; $file = new VcsFileInfo($file->getFilename(), $this->getHead(), $kind); $file->setCommit($commit); $entries[] = $file; } return $entries; }