From 3de8d66a82581d9056e02cf365f48ca876435495 Mon Sep 17 00:00:00 2001 From: till Date: Thu, 22 Mar 2012 17:19:10 +0100 Subject: [PATCH] * refactor SvnDownloader to use new Util Class * now supports auth all over * svn command generation is proxied through one place * still needs the 'interactive' settings and an execute method --- src/Composer/Downloader/SvnDownloader.php | 46 ++++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index 28d3e2101..5a47a755d 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -14,22 +14,32 @@ namespace Composer\Downloader; use Composer\Package\PackageInterface; use Composer\Util\ProcessExecutor; +use Composer\Util\Svn as SvnUtil; /** * @author Ben Bieker */ class SvnDownloader extends VcsDownloader { + /** + * @var \Composer\Util\Svn $util + */ + protected $util; + /** * {@inheritDoc} */ public function doDownload(PackageInterface $package, $path) { - $url = escapeshellarg($package->getSourceUrl()); - $ref = escapeshellarg($package->getSourceReference()); - $path = escapeshellarg($path); + $url = $package->getSourceUrl(); + $ref = $package->getSourceReference(); + + $util = $this->getUtil($url); + + $command = $util->getCommand("svn co", sprintf("%s/%s", $url, $ref), $path); + $this->io->write(" Checking out ".$package->getSourceReference()); - $this->process->execute(sprintf('svn co %s/%s %s', $url, $ref, $path)); + $this->process->execute($command); } /** @@ -37,11 +47,14 @@ class SvnDownloader extends VcsDownloader */ public function doUpdate(PackageInterface $initial, PackageInterface $target, $path) { - $ref = escapeshellarg($target->getSourceReference()); - $path = escapeshellarg($path); - $url = escapeshellarg($target->getSourceUrl()); - $this->io->write(" Checking out ".$target->getSourceReference()); - $this->process->execute(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref)); + $url = $target->getSourceUrl(); + $ref = $target->getSourceReference(); + + $util = $this->getUtil($url); + $command = $util->getCommand("svn switch", sprintf("%s/%s", $url, $ref)); + + $this->io->write(" Checking out " . $ref); + $this->process->execute(sprintf('cd %s && %s', $path, $command)); } /** @@ -54,4 +67,17 @@ class SvnDownloader extends VcsDownloader throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes'); } } -} \ No newline at end of file + + /** + * This is heavy - recreating Util often. + * + * @param string $url + * + * @return \Composer\Util\Svn + */ + protected function getUtil($url) + { + $util = new SvnUtil($url, $this->io); + return $util; + } +}