1
0
Fork 0

Merge pull request #118 from naderman/priority-replace-any-version

Replaced packages have higher priority even if wrong version is replaced
pull/123/head
Jordi Boggiano 2011-11-21 08:30:40 -08:00
commit d020f2701d
3 changed files with 29 additions and 15 deletions

View File

@ -148,12 +148,23 @@ class DefaultPolicy implements PolicyInterface
return ($this->getPriority($pool, $a) > $this->getPriority($pool, $b)) ? -1 : 1;
}
/**
* Checks if source replaces a package with the same name as target.
*
* Replace constraints are ignored. This method should only be used for
* prioritisation, not for actual constraint verification.
*
* @param PackageInterface $source
* @param PackageInterface $target
* @return bool
*/
protected function replaces(PackageInterface $source, PackageInterface $target)
{
foreach ($source->getReplaces() as $link) {
if ($link->getTarget() === $target->getName() &&
(null === $link->getConstraint() ||
$link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) {
if ($link->getTarget() === $target->getName()
// && (null === $link->getConstraint() ||
// $link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) {
) {
return true;
}
}

View File

@ -160,9 +160,9 @@ class RuleSet implements \IteratorAggregate, \Countable
foreach ($this->rules as $type => $rules) {
$string .= str_pad(self::$types[$type], 8, ' ') . ": ";
foreach ($rules as $rule) {
$string .= $rule;
$string .= $rule."\n";
}
$string .= "\n";
$string .= "\n\n";
}
return $string;

View File

@ -1746,12 +1746,14 @@ class Solver
while (true) {
$conflictRule = $this->propagate($level);
if ($conflictRule !== null) {
if ($this->analyzeUnsolvable($conflictRule, $disableRules)) {
continue;
} else {
return;
if (1 === $level) {
$conflictRule = $this->propagate($level);
if ($conflictRule !== null) {
if ($this->analyzeUnsolvable($conflictRule, $disableRules)) {
continue;
} else {
return;
}
}
}
@ -1987,7 +1989,11 @@ class Solver
return;
}
if ($level < $systemLevel || $level == 1) {
// open suse sat-solver uses this, but why is $level == 1 trouble?
// SYSTEMSOLVABLE related? we don't have that, so should work
//if ($level < $systemLevel || $level == 1) {
if ($level < $systemLevel) {
break; // trouble
}
@ -1995,9 +2001,6 @@ class Solver
$n = -1;
}
// $this->printDecisionMap();
// $this->printDecisionQueue();
// minimization step
if (count($this->branches)) {