|
@@ -14,6 +14,7 @@ namespace Composer\Downloader;
|
|
|
|
|
|
use Composer\Package\PackageInterface;
|
|
|
use Composer\Util\ProcessExecutor;
|
|
|
+use Composer\Util\Hg as HgUtils;
|
|
|
|
|
|
/**
|
|
|
* @author Per Bernhardt <plb@webfactory.de>
|
|
@@ -25,16 +26,15 @@ class HgDownloader extends VcsDownloader
|
|
|
*/
|
|
|
public function doDownload(PackageInterface $package, $path, $url)
|
|
|
{
|
|
|
- // Ensure we are allowed to use this URL by config
|
|
|
- $this->config->prohibitUrlByConfig($url, $this->io);
|
|
|
+ $hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
|
|
+
|
|
|
+ $cloneCommand = function($url) use ($path) {
|
|
|
+ return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
|
|
|
+ };
|
|
|
+
|
|
|
+ $hgUtils->runCommand($cloneCommand, $url, $path);
|
|
|
|
|
|
- $url = ProcessExecutor::escape($url);
|
|
|
$ref = ProcessExecutor::escape($package->getSourceReference());
|
|
|
- $this->io->writeError("Cloning ".$package->getSourceReference());
|
|
|
- $command = sprintf('hg clone %s %s', $url, ProcessExecutor::escape($path));
|
|
|
- if (0 !== $this->process->execute($command, $ignoredOutput)) {
|
|
|
- throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
|
|
- }
|
|
|
$command = sprintf('hg up %s', $ref);
|
|
|
if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
|
|
|
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
|
@@ -46,21 +46,20 @@ class HgDownloader extends VcsDownloader
|
|
|
*/
|
|
|
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
|
|
|
{
|
|
|
- // Ensure we are allowed to use this URL by config
|
|
|
- $this->config->prohibitUrlByConfig($url, $this->io);
|
|
|
+ $hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
|
|
|
|
|
- $url = ProcessExecutor::escape($url);
|
|
|
- $ref = ProcessExecutor::escape($target->getSourceReference());
|
|
|
+ $ref = $target->getSourceReference();
|
|
|
$this->io->writeError(" Updating to ".$target->getSourceReference());
|
|
|
|
|
|
if (!$this->hasMetadataRepository($path)) {
|
|
|
throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
|
|
|
}
|
|
|
|
|
|
- $command = sprintf('hg pull %s && hg up %s', $url, $ref);
|
|
|
- if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
|
|
|
- throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
|
|
- }
|
|
|
+ $command = function($url) use ($ref) {
|
|
|
+ return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
|
|
|
+ };
|
|
|
+
|
|
|
+ $hgUtils->runCommand($command, $url, $path);
|
|
|
}
|
|
|
|
|
|
/**
|