Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

Jordi Boggiano 12 gadi atpakaļ
vecāks
revīzija
e188f69a0f

+ 2 - 0
src/Composer/Command/RequireCommand.php

@@ -36,6 +36,7 @@ class RequireCommand extends InitCommand
                 new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Required package with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"'),
                 new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
                 new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
+                new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
                 new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'),
             ))
             ->setHelp(<<<EOT
@@ -98,6 +99,7 @@ EOT
         $install
             ->setVerbose($input->getOption('verbose'))
             ->setPreferSource($input->getOption('prefer-source'))
+            ->setPreferDist($input->getOption('prefer-dist'))
             ->setDevMode($input->getOption('dev'))
             ->setUpdate(true)
             ->setUpdateWhitelist($requirements);

+ 10 - 1
src/Composer/Repository/Vcs/HgDriver.php

@@ -162,6 +162,7 @@ class HgDriver extends VcsDriver
     {
         if (null === $this->branches) {
             $branches = array();
+            $bookmarks = array();
 
             $this->process->execute('hg branches', $output, $this->repoDir);
             foreach ($this->process->splitLines($output) as $branch) {
@@ -170,7 +171,15 @@ class HgDriver extends VcsDriver
                 }
             }
 
-            $this->branches = $branches;
+            $this->process->execute('hg bookmarks', $output, $this->repoDir);
+            foreach ($this->process->splitLines($output) as $branch) {
+                if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
+                    $bookmarks[$match[1]] = $match[2];
+                }
+            }
+
+            // Branches will have preference over bookmarks
+            $this->branches = array_merge($bookmarks, $branches);
         }
 
         return $this->branches;