Fix refactoring bugs
parent
4fe80d7abb
commit
5623f3e69c
|
@ -12,8 +12,11 @@ use Composer\Console\Application as ComposerApplication;
|
||||||
|
|
||||||
// initialize repository manager
|
// initialize repository manager
|
||||||
$rm = new Repository\RepositoryManager();
|
$rm = new Repository\RepositoryManager();
|
||||||
$rm->setLocalRepository(new Repository\FilesystemRepository('.composer/installed.json'));
|
$localRepository = new Repository\WrapperRepository(array(
|
||||||
$rm->setRepository('Platform', new Repository\PlatformRepository());
|
new Repository\ArrayRepository('.composer/installed.json'),
|
||||||
|
new Repository\PlatformRepository(),
|
||||||
|
));
|
||||||
|
$rm->setLocalRepository($localRepository);
|
||||||
$rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
|
$rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
|
||||||
|
|
||||||
// initialize download manager
|
// initialize download manager
|
||||||
|
@ -24,7 +27,7 @@ $dm->setDownloader('git', new Downloader\GitDownloader());
|
||||||
|
|
||||||
// initialize installation manager
|
// initialize installation manager
|
||||||
$im = new Installer\InstallationManager();
|
$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
|
// load package
|
||||||
$loader = new Package\Loader\JsonLoader();
|
$loader = new Package\Loader\JsonLoader();
|
||||||
|
|
|
@ -63,13 +63,14 @@ EOT
|
||||||
|
|
||||||
// creating repository pool
|
// creating repository pool
|
||||||
$pool = new Pool;
|
$pool = new Pool;
|
||||||
|
$pool->addRepository($composer->getRepositoryManager()->getLocalRepository());
|
||||||
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
|
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
|
||||||
$pool->addRepository($repository);
|
$pool->addRepository($repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating requirements request
|
// creating requirements request
|
||||||
$request = new Request($pool);
|
$request = new Request($pool);
|
||||||
foreach ($this->getPackage()->getRequires() as $link) {
|
foreach ($composer->getPackage()->getRequires() as $link) {
|
||||||
$request->install($link->getTarget(), $link->getConstraint());
|
$request->install($link->getTarget(), $link->getConstraint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ class Solver
|
||||||
protected $watches = array();
|
protected $watches = array();
|
||||||
protected $removeWatches = array();
|
protected $removeWatches = array();
|
||||||
protected $decisionMap;
|
protected $decisionMap;
|
||||||
|
protected $installedPackageMap;
|
||||||
|
|
||||||
protected $packageToUpdateRule = array();
|
protected $packageToUpdateRule = array();
|
||||||
protected $packageToFeatureRule = array();
|
protected $packageToFeatureRule = array();
|
||||||
|
@ -252,7 +253,7 @@ class Solver
|
||||||
$this->addedMap[$package->getId()] = true;
|
$this->addedMap[$package->getId()] = true;
|
||||||
|
|
||||||
$dontFix = 0;
|
$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;
|
$dontFix = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +272,7 @@ class Solver
|
||||||
if ($dontFix) {
|
if ($dontFix) {
|
||||||
$foundInstalled = false;
|
$foundInstalled = false;
|
||||||
foreach ($possibleRequires as $require) {
|
foreach ($possibleRequires as $require) {
|
||||||
if ($this->installed === $require->getRepository()) {
|
if (isset($this->installedPackageMap[$require->getId()])) {
|
||||||
$foundInstalled = true;
|
$foundInstalled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +295,7 @@ class Solver
|
||||||
$possibleConflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
$possibleConflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
||||||
|
|
||||||
foreach ($possibleConflicts as $conflict) {
|
foreach ($possibleConflicts as $conflict) {
|
||||||
if ($dontFix && $this->installed === $conflict->getRepository()) {
|
if ($dontFix && isset($this->installedPackageMap[$conflict->getId()])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +310,7 @@ class Solver
|
||||||
/** @TODO: if ($this->noInstalledObsoletes) */
|
/** @TODO: if ($this->noInstalledObsoletes) */
|
||||||
if (true) {
|
if (true) {
|
||||||
$noObsoletes = isset($this->noObsoletes[$package->getId()]);
|
$noObsoletes = isset($this->noObsoletes[$package->getId()]);
|
||||||
$isInstalled = ($this->installed === $package->getRepository());
|
$isInstalled = (isset($this->installedPackageMap[$package->getId()]));
|
||||||
|
|
||||||
foreach ($package->getReplaces() as $link) {
|
foreach ($package->getReplaces() as $link) {
|
||||||
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
$obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
|
||||||
|
@ -758,7 +759,7 @@ class Solver
|
||||||
switch ($job['cmd']) {
|
switch ($job['cmd']) {
|
||||||
case 'install':
|
case 'install':
|
||||||
foreach ($job['packages'] as $package) {
|
foreach ($job['packages'] as $package) {
|
||||||
if ($this->installed === $package->getRepository()) {
|
if (isset($this->installedPackageMap[$package->getId()])) {
|
||||||
$disableQueue[] = array('type' => 'update', 'package' => $package);
|
$disableQueue[] = array('type' => 'update', 'package' => $package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +872,7 @@ class Solver
|
||||||
|
|
||||||
case 'remove':
|
case 'remove':
|
||||||
foreach ($job['packages'] as $package) {
|
foreach ($job['packages'] as $package) {
|
||||||
if ($this->installed === $package->getRepository()) {
|
if (isset($this->installedPackageMap[$package->getId()])) {
|
||||||
$disableQueue[] = array('type' => 'update', 'package' => $package);
|
$disableQueue[] = array('type' => 'update', 'package' => $package);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,6 +934,10 @@ class Solver
|
||||||
{
|
{
|
||||||
$this->jobs = $request->getJobs();
|
$this->jobs = $request->getJobs();
|
||||||
$installedPackages = $this->installed->getPackages();
|
$installedPackages = $this->installed->getPackages();
|
||||||
|
$this->installedPackageMap = array();
|
||||||
|
foreach ($installedPackages as $package) {
|
||||||
|
$this->installedPackageMap[$package->getId()] = $package;
|
||||||
|
}
|
||||||
|
|
||||||
$this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1);
|
$this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1);
|
||||||
|
|
||||||
|
@ -954,12 +959,12 @@ class Solver
|
||||||
foreach ($job['packages'] as $package) {
|
foreach ($job['packages'] as $package) {
|
||||||
switch ($job['cmd']) {
|
switch ($job['cmd']) {
|
||||||
case 'fix':
|
case 'fix':
|
||||||
if ($this->installed === $package->getRepository()) {
|
if (isset($this->installedPackageMap[$package->getId()])) {
|
||||||
$this->fixMap[$package->getId()] = true;
|
$this->fixMap[$package->getId()] = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
if ($this->installed === $package->getRepository()) {
|
if (isset($this->installedPackageMap[$package->getId()])) {
|
||||||
$this->updateMap[$package->getId()] = true;
|
$this->updateMap[$package->getId()] = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1039,7 +1044,7 @@ class Solver
|
||||||
break;
|
break;
|
||||||
case 'lock':
|
case 'lock':
|
||||||
foreach ($job['packages'] as $package) {
|
foreach ($job['packages'] as $package) {
|
||||||
if ($this->installed === $package->getRepository()) {
|
if (isset($this->installedPackageMap[$package->getId()])) {
|
||||||
$rule = $this->createInstallRule($package, self::RULE_JOB_LOCK);
|
$rule = $this->createInstallRule($package, self::RULE_JOB_LOCK);
|
||||||
} else {
|
} else {
|
||||||
$rule = $this->createRemoveRule($package, self::RULE_JOB_LOCK);
|
$rule = $this->createRemoveRule($package, self::RULE_JOB_LOCK);
|
||||||
|
@ -1083,7 +1088,7 @@ class Solver
|
||||||
$package = $literal->getPackage();
|
$package = $literal->getPackage();
|
||||||
|
|
||||||
// !wanted & installed
|
// !wanted & installed
|
||||||
if (!$literal->isWanted() && $this->installed === $package->getRepository()) {
|
if (!$literal->isWanted() && isset($this->installedPackageMap[$package->getId()])) {
|
||||||
$updateRule = $this->packageToUpdateRule[$package->getId()];
|
$updateRule = $this->packageToUpdateRule[$package->getId()];
|
||||||
|
|
||||||
foreach ($updateRule->getLiterals() as $updateLiteral) {
|
foreach ($updateRule->getLiterals() as $updateLiteral) {
|
||||||
|
@ -1098,7 +1103,7 @@ class Solver
|
||||||
$package = $literal->getPackage();
|
$package = $literal->getPackage();
|
||||||
|
|
||||||
// wanted & installed || !wanted & !installed
|
// wanted & installed || !wanted & !installed
|
||||||
if ($literal->isWanted() == ($this->installed === $package->getRepository())) {
|
if ($literal->isWanted() == (isset($this->installedPackageMap[$package->getId()]))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,5 @@ class ArrayLoader
|
||||||
if (!isset($config['version'])) {
|
if (!isset($config['version'])) {
|
||||||
throw new \UnexpectedValueException('version is required for package');
|
throw new \UnexpectedValueException('version is required for package');
|
||||||
}
|
}
|
||||||
if (!isset($config['type'])) {
|
|
||||||
throw new \UnexpectedValueException('type is required for package');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue