From f626f55f410085582884e91b3eb33ebfe74290ae Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 15 Nov 2013 13:05:04 +0100 Subject: [PATCH 1/4] No need to create hg working copies just to parse tags/branches --- src/Composer/Repository/Vcs/HgDriver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 5de081cca..060a77e45 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -49,14 +49,14 @@ class HgDriver extends VcsDriver // update the repo if it is a valid hg repository if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) { - if (0 !== $this->process->execute('hg pull -u', $output, $this->repoDir)) { + if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) { $this->io->write('Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')'); } } else { // clean up directory and do a fresh clone into it $fs->removeDirectory($this->repoDir); - if (0 !== $this->process->execute(sprintf('hg clone %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)), $output, $cacheDir)) { + if (0 !== $this->process->execute(sprintf('hg clone --noupdate %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)), $output, $cacheDir)) { $output = $this->process->getErrorOutput(); if (0 !== $this->process->execute('hg --version', $ignoredOutput)) { From 9477e015bd89f02a007a42761b97c2c11b2078e1 Mon Sep 17 00:00:00 2001 From: Dimitrios Kanellopoulos Date: Sat, 16 Nov 2013 14:13:33 +0100 Subject: [PATCH 2/4] Use cache directory when downloading composer.phar Since there is a cache dir there is no need to populate the project directory with temp files. Plus the permissions on the project dir might not allow that. --- src/Composer/Command/SelfUpdateCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index d37598b04..86ecf1a8a 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -13,6 +13,7 @@ namespace Composer\Command; use Composer\Composer; +use Composer\Factory; use Composer\Util\RemoteFilesystem; use Composer\Downloader\FilesystemException; use Symfony\Component\Console\Input\InputInterface; @@ -42,8 +43,11 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { + $config = Factory::createConfig(); + $cacheDir = $config->get('cache-dir'); + $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; - $tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar').'-temp.phar'; + $tempFilename = $cacheDir . basename($localFilename, '.phar').'-temp.phar'; // check for permissions in local filesystem before start connection process if (!is_writable($tempDirectory = dirname($tempFilename))) { From 95a9ac880b88e4a25cf7b323d885734ed26a4b8a Mon Sep 17 00:00:00 2001 From: Dimitrios Kanellopoulos Date: Sat, 16 Nov 2013 18:52:44 +0100 Subject: [PATCH 3/4] Check if current dir is writable and if not try the cache dir from settings --- src/Composer/Command/SelfUpdateCommand.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 86ecf1a8a..e8c373197 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -47,11 +47,14 @@ EOT $cacheDir = $config->get('cache-dir'); $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; - $tempFilename = $cacheDir . basename($localFilename, '.phar').'-temp.phar'; + + // Check if current dir is writable and if not try the cache dir from settings + $tmpDir = is_writable(dirname($localFilename))? dirname($localFilename) . '/' : $cacheDir; + $tempFilename = $tmpDir . basename($localFilename, '.phar').'-temp.phar'; // check for permissions in local filesystem before start connection process - if (!is_writable($tempDirectory = dirname($tempFilename))) { - throw new FilesystemException('Composer update failed: the "'.$tempDirectory.'" directory used to download the temp file could not be written'); + if (!is_writable($tmpDir)) { + throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written'); } if (!is_writable($localFilename)) { From 81820beefc32428a6904d6a8703fc0ef881629cd Mon Sep 17 00:00:00 2001 From: Dimitrios Kanellopoulos Date: Sat, 16 Nov 2013 19:34:06 +0100 Subject: [PATCH 4/4] Cache path never ends with '/' --- src/Composer/Command/SelfUpdateCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index e8c373197..4074d8bad 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -49,8 +49,8 @@ EOT $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; // Check if current dir is writable and if not try the cache dir from settings - $tmpDir = is_writable(dirname($localFilename))? dirname($localFilename) . '/' : $cacheDir; - $tempFilename = $tmpDir . basename($localFilename, '.phar').'-temp.phar'; + $tmpDir = is_writable(dirname($localFilename))? dirname($localFilename) : $cacheDir; + $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar'; // check for permissions in local filesystem before start connection process if (!is_writable($tmpDir)) {