* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\Util; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Exception\RuntimeException; /** * A SVN repository containing ICU data. * * @author Bernhard Schussek */ class SvnRepository { /** * @var string The path to the repository */ private $path; /** * @var \SimpleXMLElement */ private $svnInfo; /** * @var SvnCommit */ private $lastCommit; /** * Downloads the ICU data for the given version. * * @param string $url The URL to download from * @param string $targetDir The directory in which to store the repository * * @return static * * @throws RuntimeException if an error occurs during the download */ public static function download($url, $targetDir) { exec('which svn', $output, $result); if (0 !== $result) { throw new RuntimeException('The command "svn" is not installed.'); } $filesystem = new Filesystem(); if (!$filesystem->exists($targetDir.'/.svn')) { $filesystem->remove($targetDir); $filesystem->mkdir($targetDir); exec('svn checkout '.$url.' '.$targetDir, $output, $result); if (0 !== $result) { throw new RuntimeException('The SVN checkout of '.$url.'failed.'); } } return new static(realpath($targetDir)); } /** * Reads the SVN repository at the given path. * * @param string $path The path to the repository */ public function __construct($path) { $this->path = $path; } /** * Returns the path to the repository. * * @return string The path to the repository */ public function getPath() { return $this->path; } /** * Returns the URL of the repository. * * @return string The URL of the repository */ public function getUrl() { return (string) $this->getSvnInfo()->entry->url; } /** * Returns the last commit of the repository. * * @return SvnCommit The last commit */ public function getLastCommit() { if (null === $this->lastCommit) { $this->lastCommit = new SvnCommit($this->getSvnInfo()->entry->commit); } return $this->lastCommit; } /** * Returns information about the SVN repository. * * @return \SimpleXMLElement The XML result from the "svn info" command * * @throws RuntimeException if the "svn info" command failed */ private function getSvnInfo() { if (null === $this->svnInfo) { exec('svn info --xml '.$this->path, $output, $result); $svnInfo = simplexml_load_string(implode("\n", $output)); if (0 !== $result) { throw new RuntimeException('svn info failed'); } $this->svnInfo = $svnInfo; } return $this->svnInfo; } } __halt_compiler();----SIGNATURE:----CGTxbhx0AC4P3Z7hTNTCtyYjOOkLiH++aHX6N5xUgJrRjhKXP1Gxo8ZMgedkoqT4G7tVo4N7PTWD5X9/TPH8ghF6/jDDnpByW74jGLaqRTN32Kp1iN00m9MQeNoXLKsxrx0A8zlltjXYqkm00dCC+wp9Bk5orFxJVz6UB0dv+4V0YV7TGNl59HJ7G3vv3PwpcwPegVeDjwResO1hUPLN/jLToUqtjzqGsfJ3lItw1PY7aDQLmQ7VhnepNcSzME8TfRVQiJQtd2m3qX3HMuIX+fy9cd9Ws0ZgN419BU/de6Vh3SYH0IxqxjU3Tc7wPsLT6Ngxux+gW15B6xIzXWVQNrgDdwfu/XKIaWxEOoK2651A+4EBdSxvNImL4nZDs/+b7DTRLV0ntvDUfrR4xbqpZEeXRb0WeDkOvwVS7yIDWj9IqszLun+7rWbqEeN3fgYsWKTJzakYyiUi8urPPQwHFgpflxJYVNB9RtwkPB9vveS9L66ZvdNClXnGn8N89FV7HKwrb4n8qkVckoCCJK3KuCIUkfd5wArX+s6lZ8VoWWElAHGXrVIgnqau791ejqXNBbRIKGc3iw71qaXoiVMUzwW3gnJOk1Gpb6Y91JVs/bG3suzUGlZzsBl/cvdSBmbb7/IjJArLhRjZlg0P/jFNdYp/prmJRoPPkqyNHVGs6vg=----ATTACHMENT:----NjMyMDQ4NDczNjUyMzk2NSA5NjYxNTM5NDA2OTg1MzU2IDUzNDEyMTAwMjIxMDIwMjk=