1
0
Fork 0

Fix refactoring bugs

pull/20/merge
Jordi Boggiano 2011-09-25 23:07:42 +02:00
parent 4fe80d7abb
commit 5623f3e69c
4 changed files with 24 additions and 18 deletions

View File

@ -12,8 +12,11 @@ use Composer\Console\Application as ComposerApplication;
// initialize repository manager
$rm = new Repository\RepositoryManager();
$rm->setLocalRepository(new Repository\FilesystemRepository('.composer/installed.json'));
$rm->setRepository('Platform', new Repository\PlatformRepository());
$localRepository = new Repository\WrapperRepository(array(
new Repository\ArrayRepository('.composer/installed.json'),
new Repository\PlatformRepository(),
));
$rm->setLocalRepository($localRepository);
$rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
// initialize download manager
@ -24,7 +27,7 @@ $dm->setDownloader('git', new Downloader\GitDownloader());
// initialize installation manager
$im = new Installer\InstallationManager();
$im->setInstaller('vendor', new Installer\LibraryInstaller('vendor', $dm, $rm->getLocalRepository()));
$im->setInstaller('library', new Installer\LibraryInstaller('vendor', $dm, $rm->getLocalRepository()));
// load package
$loader = new Package\Loader\JsonLoader();

View File

@ -63,13 +63,14 @@ EOT
// creating repository pool
$pool = new Pool;
$pool->addRepository($composer->getRepositoryManager()->getLocalRepository());
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
$pool->addRepository($repository);
}
// creating requirements request
$request = new Request($pool);
foreach ($this->getPackage()->getRequires() as $link) {
foreach ($composer->getPackage()->getRequires() as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}

View File

@ -50,6 +50,7 @@ class Solver
protected $watches = array();
protected $removeWatches = array();
protected $decisionMap;
protected $installedPackageMap;
protected $packageToUpdateRule = array();
protected $packageToFeatureRule = array();
@ -252,7 +253,7 @@ class Solver
$this->addedMap[$package->getId()] = true;
$dontFix = 0;
if ($this->installed === $package->getRepository() && !isset($this->fixMap[$package->getId()])) {
if (isset($this->installedPackageMap[$package->getId()]) && !isset($this->fixMap[$package->getId()])) {
$dontFix = 1;
}
@ -271,7 +272,7 @@ class Solver
if ($dontFix) {
$foundInstalled = false;
foreach ($possibleRequires as $require) {
if ($this->installed === $require->getRepository()) {
if (isset($this->installedPackageMap[$require->getId()])) {
$foundInstalled = true;
break;
}
@ -294,7 +295,7 @@ class Solver
$possibleConflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
foreach ($possibleConflicts as $conflict) {
if ($dontFix && $this->installed === $conflict->getRepository()) {
if ($dontFix && isset($this->installedPackageMap[$conflict->getId()])) {
continue;
}
@ -309,7 +310,7 @@ class Solver
/** @TODO: if ($this->noInstalledObsoletes) */
if (true) {
$noObsoletes = isset($this->noObsoletes[$package->getId()]);
$isInstalled = ($this->installed === $package->getRepository());
$isInstalled = (isset($this->installedPackageMap[$package->getId()]));
foreach ($package->getReplaces() as $link) {
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
@ -758,7 +759,7 @@ class Solver
switch ($job['cmd']) {
case 'install':
foreach ($job['packages'] as $package) {
if ($this->installed === $package->getRepository()) {
if (isset($this->installedPackageMap[$package->getId()])) {
$disableQueue[] = array('type' => 'update', 'package' => $package);
}
@ -871,7 +872,7 @@ class Solver
case 'remove':
foreach ($job['packages'] as $package) {
if ($this->installed === $package->getRepository()) {
if (isset($this->installedPackageMap[$package->getId()])) {
$disableQueue[] = array('type' => 'update', 'package' => $package);
}
}
@ -933,6 +934,10 @@ class Solver
{
$this->jobs = $request->getJobs();
$installedPackages = $this->installed->getPackages();
$this->installedPackageMap = array();
foreach ($installedPackages as $package) {
$this->installedPackageMap[$package->getId()] = $package;
}
$this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1);
@ -954,12 +959,12 @@ class Solver
foreach ($job['packages'] as $package) {
switch ($job['cmd']) {
case 'fix':
if ($this->installed === $package->getRepository()) {
if (isset($this->installedPackageMap[$package->getId()])) {
$this->fixMap[$package->getId()] = true;
}
break;
case 'update':
if ($this->installed === $package->getRepository()) {
if (isset($this->installedPackageMap[$package->getId()])) {
$this->updateMap[$package->getId()] = true;
}
break;
@ -1039,7 +1044,7 @@ class Solver
break;
case 'lock':
foreach ($job['packages'] as $package) {
if ($this->installed === $package->getRepository()) {
if (isset($this->installedPackageMap[$package->getId()])) {
$rule = $this->createInstallRule($package, self::RULE_JOB_LOCK);
} else {
$rule = $this->createRemoveRule($package, self::RULE_JOB_LOCK);
@ -1083,7 +1088,7 @@ class Solver
$package = $literal->getPackage();
// !wanted & installed
if (!$literal->isWanted() && $this->installed === $package->getRepository()) {
if (!$literal->isWanted() && isset($this->installedPackageMap[$package->getId()])) {
$updateRule = $this->packageToUpdateRule[$package->getId()];
foreach ($updateRule->getLiterals() as $updateLiteral) {
@ -1098,7 +1103,7 @@ class Solver
$package = $literal->getPackage();
// wanted & installed || !wanted & !installed
if ($literal->isWanted() == ($this->installed === $package->getRepository())) {
if ($literal->isWanted() == (isset($this->installedPackageMap[$package->getId()]))) {
continue;
}

View File

@ -110,8 +110,5 @@ class ArrayLoader
if (!isset($config['version'])) {
throw new \UnexpectedValueException('version is required for package');
}
if (!isset($config['type'])) {
throw new \UnexpectedValueException('type is required for package');
}
}
}