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; 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) protected function replaces(PackageInterface $source, PackageInterface $target)
{ {
foreach ($source->getReplaces() as $link) { foreach ($source->getReplaces() as $link) {
if ($link->getTarget() === $target->getName() && if ($link->getTarget() === $target->getName()
(null === $link->getConstraint() || // && (null === $link->getConstraint() ||
$link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) { // $link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) {
) {
return true; return true;
} }
} }

View File

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

View File

@ -1746,12 +1746,14 @@ class Solver
while (true) { while (true) {
$conflictRule = $this->propagate($level); if (1 === $level) {
if ($conflictRule !== null) { $conflictRule = $this->propagate($level);
if ($this->analyzeUnsolvable($conflictRule, $disableRules)) { if ($conflictRule !== null) {
continue; if ($this->analyzeUnsolvable($conflictRule, $disableRules)) {
} else { continue;
return; } else {
return;
}
} }
} }
@ -1987,7 +1989,11 @@ class Solver
return; 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 break; // trouble
} }
@ -1995,9 +2001,6 @@ class Solver
$n = -1; $n = -1;
} }
// $this->printDecisionMap();
// $this->printDecisionQueue();
// minimization step // minimization step
if (count($this->branches)) { if (count($this->branches)) {