Separate transaction generation from solving and properly identify updates
parent
f46aa495da
commit
0f6fb9b692
|
@ -1069,8 +1069,31 @@ class Solver
|
||||||
//findrecommendedsuggested(solv);
|
//findrecommendedsuggested(solv);
|
||||||
//solver_prepare_solutions(solv);
|
//solver_prepare_solutions(solv);
|
||||||
|
|
||||||
|
return $this->createTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createTransaction()
|
||||||
|
{
|
||||||
$transaction = array();
|
$transaction = array();
|
||||||
|
|
||||||
|
$installMeansUpdateMap = array();
|
||||||
|
$ignoreRemoveMap = array();
|
||||||
|
|
||||||
|
foreach ($this->decisionQueue as $i => $literal) {
|
||||||
|
$package = $literal->getPackage();
|
||||||
|
|
||||||
|
// !wanted & installed
|
||||||
|
if (!$literal->isWanted() && $this->installed === $package->getRepository()) {
|
||||||
|
$updateRule = $this->packageToUpdateRule[$package->getId()];
|
||||||
|
|
||||||
|
foreach ($updateRule->getLiterals() as $updateLiteral) {
|
||||||
|
if (!$updateLiteral->equals($literal)) {
|
||||||
|
$installMeansUpdateMap[$updateLiteral->getPackageId()] = $package;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->decisionQueue as $i => $literal) {
|
foreach ($this->decisionQueue as $i => $literal) {
|
||||||
$package = $literal->getPackage();
|
$package = $literal->getPackage();
|
||||||
|
|
||||||
|
@ -1079,11 +1102,34 @@ class Solver
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$transaction[] = array(
|
if ($literal->isWanted()) {
|
||||||
'job' => ($literal->isWanted()) ? 'install' : 'remove',
|
if (isset($installMeansUpdateMap[$literal->getPackageId()])) {
|
||||||
'package' => $package,
|
$source = $installMeansUpdateMap[$literal->getPackageId()];
|
||||||
'why' => $this->decisionQueueWhy[$i],
|
|
||||||
);
|
$transaction[] = array(
|
||||||
|
'job' => 'update',
|
||||||
|
'from' => $source,
|
||||||
|
'to' => $package,
|
||||||
|
'why' => $this->decisionQueueWhy[$i],
|
||||||
|
);
|
||||||
|
|
||||||
|
// avoid updates to one package from multiple origins
|
||||||
|
unset($installMeansUpdateMap[$literal->getPackageId()]);
|
||||||
|
$ignoreRemove[$source->getId()] = true;
|
||||||
|
} else {
|
||||||
|
$transaction[] = array(
|
||||||
|
'job' => 'install',
|
||||||
|
'package' => $package,
|
||||||
|
'why' => $this->decisionQueueWhy[$i],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (!isset($ignoreRemove[$package->getId()])) {
|
||||||
|
$transaction[] = array(
|
||||||
|
'job' => 'remove',
|
||||||
|
'package' => $package,
|
||||||
|
'why' => $this->decisionQueueWhy[$i],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_reverse($transaction);
|
return array_reverse($transaction);
|
||||||
|
|
|
@ -124,9 +124,7 @@ class SolverTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->request->update('A');
|
$this->request->update('A');
|
||||||
|
|
||||||
$this->checkSolverResult(array(
|
$this->checkSolverResult(array(
|
||||||
//array('job' => 'update', 'from' => $packageA, 'to' => $newPackageA),
|
array('job' => 'update', 'from' => $packageA, 'to' => $newPackageA),
|
||||||
array('job' => 'remove', 'package' => $packageA),
|
|
||||||
array('job' => 'install', 'package' => $newPackageA),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,8 +141,6 @@ class SolverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testSolverFull()
|
public function testSolverFull()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
|
||||||
|
|
||||||
$this->repoInstalled->addPackage($packageD = new MemoryPackage('D', '1.0'));
|
$this->repoInstalled->addPackage($packageD = new MemoryPackage('D', '1.0'));
|
||||||
$this->repoInstalled->addPackage($oldPackageC = new MemoryPackage('C', '1.0'));
|
$this->repoInstalled->addPackage($oldPackageC = new MemoryPackage('C', '1.0'));
|
||||||
|
|
||||||
|
@ -162,10 +158,10 @@ class SolverTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->request->remove('D');
|
$this->request->remove('D');
|
||||||
|
|
||||||
$this->checkSolverResult(array(
|
$this->checkSolverResult(array(
|
||||||
array('job' => 'install', 'package' => $packageB),
|
|
||||||
array('job' => 'install', 'package' => $packageA),
|
|
||||||
array('job' => 'remove', 'package' => $packageD),
|
|
||||||
array('job' => 'update', 'from' => $oldPackageC, 'to' => $packageC),
|
array('job' => 'update', 'from' => $oldPackageC, 'to' => $packageC),
|
||||||
|
array('job' => 'install', 'package' => $packageB),
|
||||||
|
array('job' => 'remove', 'package' => $packageD),
|
||||||
|
array('job' => 'install', 'package' => $packageA),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue