From f74dafc08c68cc7f0daddf5998b0c38041dc6a43 Mon Sep 17 00:00:00 2001 From: Per Bernhardt Date: Fri, 9 Dec 2011 11:59:22 +0100 Subject: [PATCH 1/5] Fixed root identifier: Use global hash instead of local revision --- src/Composer/Repository/Vcs/HgDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 23a4ebebc..39f4994fd 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -55,7 +55,7 @@ class HgDriver implements VcsDriverInterface { $tmpDir = escapeshellarg($this->tmpDir); if (null === $this->rootIdentifier) { - exec(sprintf('cd %s && hg tip --template "{rev}:{node|short}" --color never', $tmpDir), $output); + exec(sprintf('cd %s && hg tip --template "{node}" --color never', $tmpDir), $output); $this->rootIdentifier = $output[0]; } From d78548cbf9a10db963677190bd6adb2a2c480a5c Mon Sep 17 00:00:00 2001 From: Per Bernhardt Date: Fri, 9 Dec 2011 12:01:15 +0100 Subject: [PATCH 2/5] Added mercurial's "default" branch as a valid dev version (same as master / trunk). --- src/Composer/Package/Version/VersionParser.php | 4 ++-- src/Composer/Repository/Vcs/HgBitbucketDriver.php | 1 - src/Composer/Repository/Vcs/HgDriver.php | 1 - src/Composer/Repository/Vcs/VcsDriverInterface.php | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 80fb45c3c..e5006d824 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -34,7 +34,7 @@ class VersionParser { $version = trim($version); - if (preg_match('{^(?:master|trunk)(?:[.-]?dev)?$}i', $version)) { + if (preg_match('{^(?:master|trunk|default)(?:[.-]?dev)?$}i', $version)) { return '9999999-dev'; } @@ -85,7 +85,7 @@ class VersionParser { $name = trim($name); - if (in_array($name, array('master', 'trunk'))) { + if (in_array($name, array('master', 'trunk', 'default'))) { return $this->normalize($name); } diff --git a/src/Composer/Repository/Vcs/HgBitbucketDriver.php b/src/Composer/Repository/Vcs/HgBitbucketDriver.php index 9c1c82b3b..515e90d36 100644 --- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/HgBitbucketDriver.php @@ -118,7 +118,6 @@ class HgBitbucketDriver implements VcsDriverInterface foreach ($tagsData as $tag => $data) { $this->tags[$tag] = $data['raw_node']; } - unset($this->tags['tip']); } return $this->tags; diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 39f4994fd..de9d51599 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -126,7 +126,6 @@ class HgDriver implements VcsDriverInterface preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $tag, $match); $tags[$match[1]] = $match[2]; } - unset($tags['tip']); $this->tags = $tags; } diff --git a/src/Composer/Repository/Vcs/VcsDriverInterface.php b/src/Composer/Repository/Vcs/VcsDriverInterface.php index b8e6d1269..124530905 100644 --- a/src/Composer/Repository/Vcs/VcsDriverInterface.php +++ b/src/Composer/Repository/Vcs/VcsDriverInterface.php @@ -21,7 +21,7 @@ interface VcsDriverInterface function getComposerInformation($identifier); /** - * Return the root identifier (trunk, master, ..) + * Return the root identifier (trunk, master, default/tip ..) * * @return string Identifier */ From 2fc49aa88b23649ef300647789212021606d93c8 Mon Sep 17 00:00:00 2001 From: Per Bernhardt Date: Mon, 12 Dec 2011 14:06:22 +0100 Subject: [PATCH 3/5] Stop hg from parsing project's repository information while installing dependencies from source (HgDownloader) or initializing a VcsRepository (HgDriver). --- src/Composer/Downloader/HgDownloader.php | 2 +- src/Composer/Repository/Vcs/HgDriver.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index ccd81d354..090129411 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -38,7 +38,7 @@ class HgDownloader implements DownloaderInterface $url = escapeshellarg($package->getSourceUrl()); $ref = escapeshellarg($package->getSourceReference()); - system(sprintf('hg clone %s %s && cd %2$s && hg up %s', $url, $path, $ref)); + system(sprintf('(hg clone %s %s 2> /dev/null) && cd %2$s && hg up %s', $url, $path, $ref)); } /** diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index de9d51599..cee85066b 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -41,7 +41,7 @@ class HgDriver implements VcsDriverInterface if (is_dir($this->tmpDir)) { exec(sprintf('cd %s && hg pull -u', $tmpDir), $output); } else { - exec(sprintf('hg clone %s %s', $url, $tmpDir), $output); + exec(sprintf('cd %s && hg clone %s %s', escapeshellarg(sys_get_temp_dir()), $url, $tmpDir), $output); } $this->getTags(); @@ -179,7 +179,7 @@ class HgDriver implements VcsDriverInterface return false; } - exec(sprintf('hg identify %s', escapeshellarg($url)), $ignored, $exit); + exec(sprintf('cd %s && hg identify %s', escapeshellarg(sys_get_temp_dir()), escapeshellarg($url)), $ignored, $exit); return $exit === 0; } } From 399a40601819528c331d3e5120198fd2740350d5 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 12 Dec 2011 16:21:38 +0100 Subject: [PATCH 4/5] Fixed notices for edge cases. --- src/Composer/Repository/Vcs/HgDriver.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index cee85066b..aea7ea9b1 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -121,11 +121,14 @@ class HgDriver implements VcsDriverInterface public function getTags() { if (null === $this->tags) { + $tags = array(); + exec(sprintf('cd %s && hg tags --color never', escapeshellarg($this->tmpDir)), $output); foreach ($output as $tag) { - preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $tag, $match); - $tags[$match[1]] = $match[2]; + if (preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) + $tags[$match[1]] = $match[2]; } + $this->tags = $tags; } @@ -142,8 +145,8 @@ class HgDriver implements VcsDriverInterface exec(sprintf('cd %s && hg branches --color never', escapeshellarg($this->tmpDir)), $output); foreach ($output as $branch) { - preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $branch, $match); - $branches[$match[1]] = $match[2]; + if (preg_match('(^([^\s]+)\s+\d+:(.*)$)', $branch, $match)) + $branches[$match[1]] = $match[2]; } $this->branches = $branches; From df5da58b8739317e5b8b6ebd1e800e40badde28d Mon Sep 17 00:00:00 2001 From: Per Bernhardt Date: Mon, 12 Dec 2011 17:06:11 +0100 Subject: [PATCH 5/5] Made HgDriver work on Ubuntu --- src/Composer/Repository/Vcs/HgDriver.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index aea7ea9b1..c6f64cced 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -55,7 +55,7 @@ class HgDriver implements VcsDriverInterface { $tmpDir = escapeshellarg($this->tmpDir); if (null === $this->rootIdentifier) { - exec(sprintf('cd %s && hg tip --template "{node}" --color never', $tmpDir), $output); + exec(sprintf('cd %s && hg tip --template "{node}"', $tmpDir), $output); $this->rootIdentifier = $output[0]; } @@ -94,7 +94,7 @@ class HgDriver implements VcsDriverInterface public function getComposerInformation($identifier) { if (!isset($this->infoCache[$identifier])) { - exec(sprintf('cd %s && hg cat --color never -r %s composer.json', escapeshellarg($this->tmpDir), escapeshellarg($identifier)), $output); + exec(sprintf('cd %s && hg cat -r %s composer.json', escapeshellarg($this->tmpDir), escapeshellarg($identifier)), $output); $composer = implode("\n", $output); unset($output); @@ -123,7 +123,7 @@ class HgDriver implements VcsDriverInterface if (null === $this->tags) { $tags = array(); - exec(sprintf('cd %s && hg tags --color never', escapeshellarg($this->tmpDir)), $output); + exec(sprintf('cd %s && hg tags', escapeshellarg($this->tmpDir)), $output); foreach ($output as $tag) { if (preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) $tags[$match[1]] = $match[2]; @@ -143,7 +143,7 @@ class HgDriver implements VcsDriverInterface if (null === $this->branches) { $branches = array(); - exec(sprintf('cd %s && hg branches --color never', escapeshellarg($this->tmpDir)), $output); + exec(sprintf('cd %s && hg branches', escapeshellarg($this->tmpDir)), $output); foreach ($output as $branch) { if (preg_match('(^([^\s]+)\s+\d+:(.*)$)', $branch, $match)) $branches[$match[1]] = $match[2];