aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-09 11:43:33 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-09 11:43:33 +0000
commit98c46ad28de04f94998f2247e85a6f5807b5db52 (patch)
tree67a12b1def7aac42c02e3f7b4d30d8e0788e4443
parentac5673f3d7d185bff48d1b4cabb146f6d4182a86 (diff)
downloadpaludis-98c46ad28de04f94998f2247e85a6f5807b5db52.tar.gz
paludis-98c46ad28de04f94998f2247e85a6f5807b5db52.tar.xz
Don't score unmet but taken || ( ) children highly
Fixes: ticket:1080
-rw-r--r--paludis/resolver/decider.cc48
-rw-r--r--paludis/resolver/decider.hh6
-rw-r--r--paludis/resolver/resolver_TEST_any.cc93
-rwxr-xr-xpaludis/resolver/resolver_TEST_any_setup.sh66
4 files changed, 199 insertions, 14 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 6c37c1a..4838690 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -593,6 +593,26 @@ Decider::_make_constraints_from_target(
throw InternalError(PALUDIS_HERE, "resolver bug: huh? it's not a block and it's not a package");
}
+const std::shared_ptr<Constraint>
+Decider::_make_constraint_from_package_dependency(
+ const std::shared_ptr<const Resolution> & resolution,
+ const SanitisedDependency & dep,
+ const std::shared_ptr<const Reason> & reason,
+ const SpecInterest interest) const
+{
+ auto existing(_imp->fns.get_use_existing_nothing_fn()(resolution, *dep.spec().if_package(), reason));
+ return std::make_shared<Constraint>(make_named_values<Constraint>(
+ n::destination_type() = resolution->resolvent().destination_type(),
+ n::force_unable() = false,
+ n::from_id() = dep.from_id(),
+ n::nothing_is_fine_too() = existing.second,
+ n::reason() = reason,
+ n::spec() = *dep.spec().if_package(),
+ n::untaken() = si_untaken == interest,
+ n::use_existing() = existing.first
+ ));
+}
+
const std::shared_ptr<ConstraintSequence>
Decider::_make_constraints_from_dependency(
const std::shared_ptr<const Resolution> & resolution,
@@ -602,19 +622,8 @@ Decider::_make_constraints_from_dependency(
{
if (dep.spec().if_package())
{
- auto existing(_imp->fns.get_use_existing_nothing_fn()(resolution, *dep.spec().if_package(), reason));
-
const std::shared_ptr<ConstraintSequence> result(std::make_shared<ConstraintSequence>());
- result->push_back(std::make_shared<Constraint>(make_named_values<Constraint>(
- n::destination_type() = resolution->resolvent().destination_type(),
- n::force_unable() = false,
- n::from_id() = dep.from_id(),
- n::nothing_is_fine_too() = existing.second,
- n::reason() = reason,
- n::spec() = *dep.spec().if_package(),
- n::untaken() = si_untaken == interest,
- n::use_existing() = existing.first
- )));
+ result->push_back(_make_constraint_from_package_dependency(resolution, dep, reason, interest));
return result;
}
else if (dep.spec().if_block())
@@ -1350,8 +1359,21 @@ Decider::find_any_score(
for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
r != r_end ; ++r)
{
+ bool any(false), any_bad(false);
ResolutionsByResolvent::ConstIterator i(_imp->resolutions_by_resolvent->find(*r));
- if (i != _imp->resolutions_by_resolvent->end())
+ if (i != _imp->resolutions_by_resolvent->end() && (*i)->decision())
+ {
+ auto constraint(_make_constraint_from_package_dependency(our_resolution, dep, reason, si_take));
+ if (_check_constraint(constraint, (*i)->decision()))
+ any = true;
+ else
+ {
+ any_bad = false;
+ break;
+ }
+ }
+
+ if (any && ! any_bad)
return std::make_pair(acs_will_be_installing, operator_bias);
}
}
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 7b93a66..3b2bd4c 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -95,6 +95,12 @@ namespace paludis
const std::shared_ptr<const Reason> &,
const SpecInterest) const;
+ const std::shared_ptr<Constraint> _make_constraint_from_package_dependency(
+ const std::shared_ptr<const Resolution> &,
+ const SanitisedDependency &,
+ const std::shared_ptr<const Reason> &,
+ const SpecInterest) const;
+
const std::shared_ptr<ConstraintSequence> _make_constraints_from_blocker(
const std::shared_ptr<const Resolution> &,
const BlockDepSpec & dep,
diff --git a/paludis/resolver/resolver_TEST_any.cc b/paludis/resolver/resolver_TEST_any.cc
index 60ba1d1..c08ef49 100644
--- a/paludis/resolver/resolver_TEST_any.cc
+++ b/paludis/resolver/resolver_TEST_any.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
* Copyright (c) 2009 David Leverton
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -228,5 +228,96 @@ namespace test_cases
test_empty_preferences_it(indeterminate, true), test_empty_preferences_ii(indeterminate, indeterminate),
test_empty_preferences_if(indeterminate, false), test_empty_preferences_ft(false, true),
test_empty_preferences_fi(false, indeterminate), test_empty_preferences_ff(false, false);
+
+ struct TestSelfUseFirst : ResolverAnyTestCase
+ {
+ TestSelfUseFirst() :
+ ResolverAnyTestCase("self use first")
+ {
+ }
+
+ void run()
+ {
+ std::shared_ptr<const Resolved> resolved(get_resolved("self-use-first/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-first/dep"))
+ .change(QualifiedPackageName("self-use-first/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+ }
+ } test_self_use_first;
+
+ struct TestSelfUseSecond : ResolverAnyTestCase
+ {
+ TestSelfUseSecond() :
+ ResolverAnyTestCase("self use second")
+ {
+ }
+
+ void run()
+ {
+ std::shared_ptr<const Resolved> resolved(get_resolved("self-use-second/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-second/dep"))
+ .change(QualifiedPackageName("self-use-second/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+ }
+ } test_self_use_second;
+
+ struct TestSelfUseNeither : ResolverAnyTestCase
+ {
+ TestSelfUseNeither() :
+ ResolverAnyTestCase("self use neither")
+ {
+ }
+
+ void run()
+ {
+ std::shared_ptr<const Resolved> resolved(get_resolved("self-use-neither/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-neither/dep"))
+ .change(QualifiedPackageName("self-use-neither/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-neither/dep"))
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+ }
+ } test_self_use_neither;
}
diff --git a/paludis/resolver/resolver_TEST_any_setup.sh b/paludis/resolver/resolver_TEST_any_setup.sh
index d27a14b..1f56d53 100755
--- a/paludis/resolver/resolver_TEST_any_setup.sh
+++ b/paludis/resolver/resolver_TEST_any_setup.sh
@@ -68,5 +68,71 @@ PLATFORMS="test"
SLOT="0"
END
+# self-use-first
+echo 'self-use-first' >> metadata/categories.conf
+
+mkdir -p 'packages/self-use-first/target'
+cat <<END > packages/self-use-first/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="
+ self-use-first/dep
+ "
+END
+
+mkdir -p 'packages/self-use-first/dep'
+cat <<END > packages/self-use-first/dep/dep-1.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+MYOPTIONS="enabled disabled"
+DEPENDENCIES="run: || ( self-use-first/dep[enabled] self-use-first/dep[disabled] )"
+END
+
+# self-use-second
+echo 'self-use-second' >> metadata/categories.conf
+
+mkdir -p 'packages/self-use-second/target'
+cat <<END > packages/self-use-second/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="
+ self-use-second/dep
+ "
+END
+
+mkdir -p 'packages/self-use-second/dep'
+cat <<END > packages/self-use-second/dep/dep-1.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+MYOPTIONS="enabled disabled"
+DEPENDENCIES="run: || ( self-use-second/dep[disabled] self-use-second/dep[enabled] )"
+END
+
+# self-use-neither
+echo 'self-use-neither' >> metadata/categories.conf
+
+mkdir -p 'packages/self-use-neither/target'
+cat <<END > packages/self-use-neither/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="
+ self-use-neither/dep
+ "
+END
+
+mkdir -p 'packages/self-use-neither/dep'
+cat <<END > packages/self-use-neither/dep/dep-1.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+MYOPTIONS="disabled disabled2"
+DEPENDENCIES="run: || ( self-use-neither/dep[disabled] self-use-neither/dep[disabled2] )"
+END
+
cd ..