aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-14 17:17:00 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-14 17:17:00 +0100
commitc1f76e42cc55f10ec5dcfedb90783dd7182075f7 (patch)
tree5a7d8a7d440959f125c942f63a4e7899cb1d06b9
parentc62763e2ec713c778e4674cdeae2b46a4f702ead (diff)
downloadpaludis-c1f76e42cc55f10ec5dcfedb90783dd7182075f7.tar.gz
paludis-c1f76e42cc55f10ec5dcfedb90783dd7182075f7.tar.xz
Work with Resolutions rather than Resolvents
-rw-r--r--paludis/resolver/decider.cc61
-rw-r--r--paludis/resolver/decider.hh15
-rw-r--r--paludis/resolver/resolver_TEST_cycles.cc2
-rw-r--r--paludis/resolver/resolver_functions.hh2
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--paludis/resolver/resolver_test.hh2
-rw-r--r--paludis/resolver/sanitised_dependencies.cc40
-rw-r--r--paludis/resolver/sanitised_dependencies.hh6
-rw-r--r--src/clients/cave/resolve_common.cc2
9 files changed, 60 insertions, 72 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index b5c6350..db9bde2 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -575,20 +575,9 @@ Decider::_resolution_for_resolvent(const Resolvent & r, const bool create)
return *i;
}
-const std::tr1::shared_ptr<Resolution>
-Decider::resolution_for_resolvent(const Resolvent & r) const
-{
- ResolutionsByResolvent::ConstIterator i(_imp->resolutions_by_resolvent->find(r));
- if (_imp->resolutions_by_resolvent->end() == i)
- throw InternalError(PALUDIS_HERE, "resolver bug: expected resolution for "
- + stringify(r) + " to exist, but it doesn't");
-
- return *i;
-}
-
const std::tr1::shared_ptr<ConstraintSequence>
Decider::_make_constraints_from_target(
- const Resolvent & resolvent,
+ const std::tr1::shared_ptr<const Resolution> & resolution,
const PackageOrBlockDepSpec & spec,
const std::tr1::shared_ptr<const Reason> & reason) const
{
@@ -596,23 +585,25 @@ Decider::_make_constraints_from_target(
{
const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
- n::destination_type() = resolvent.destination_type(),
+ n::destination_type() = resolution->resolvent().destination_type(),
n::nothing_is_fine_too() = false,
n::reason() = reason,
n::spec() = spec,
n::untaken() = false,
- n::use_existing() = _imp->fns.get_use_existing_fn()(resolvent, *spec.if_package(), reason)
+ n::use_existing() = _imp->fns.get_use_existing_fn()(resolution, *spec.if_package(), reason)
))));
return result;
}
else if (spec.if_block())
- return _make_constraints_from_blocker(resolvent, *spec.if_block(), reason);
+ return _make_constraints_from_blocker(resolution, *spec.if_block(), reason);
else
throw InternalError(PALUDIS_HERE, "resolver bug: huh? it's not a block and it's not a package");
}
const std::tr1::shared_ptr<ConstraintSequence>
-Decider::_make_constraints_from_dependency(const Resolvent & resolvent, const SanitisedDependency & dep,
+Decider::_make_constraints_from_dependency(
+ const std::tr1::shared_ptr<const Resolution> & resolution,
+ const SanitisedDependency & dep,
const std::tr1::shared_ptr<const Reason> & reason,
const SpecInterest interest) const
{
@@ -620,25 +611,24 @@ Decider::_make_constraints_from_dependency(const Resolvent & resolvent, const Sa
{
const std::tr1::shared_ptr<ConstraintSequence> result(new ConstraintSequence);
result->push_back(make_shared_ptr(new Constraint(make_named_values<Constraint>(
- n::destination_type() = resolvent.destination_type(),
+ n::destination_type() = resolution->resolvent().destination_type(),
n::nothing_is_fine_too() = false,
n::reason() = reason,
n::spec() = *dep.spec().if_package(),
n::untaken() = si_untaken == interest,
- n::use_existing() = _imp->fns.get_use_existing_fn()(
- resolvent, *dep.spec().if_package(), reason)
+ n::use_existing() = _imp->fns.get_use_existing_fn()(resolution, *dep.spec().if_package(), reason)
))));
return result;
}
else if (dep.spec().if_block())
- return _make_constraints_from_blocker(resolvent, *dep.spec().if_block(), reason);
+ return _make_constraints_from_blocker(resolution, *dep.spec().if_block(), reason);
else
throw InternalError(PALUDIS_HERE, "resolver bug: huh? it's not a block and it's not a package");
}
const std::tr1::shared_ptr<ConstraintSequence>
Decider::_make_constraints_from_blocker(
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const BlockDepSpec & spec,
const std::tr1::shared_ptr<const Reason> & reason) const
{
@@ -986,7 +976,7 @@ Decider::_add_dependencies_if_necessary(
+ stringify(*package_id) + "':");
const std::tr1::shared_ptr<SanitisedDependencies> deps(new SanitisedDependencies);
- deps->populate(*this, our_resolution->resolvent(), package_id);
+ deps->populate(*this, our_resolution, package_id);
for (SanitisedDependencies::ConstIterator s(deps->begin()), s_end(deps->end()) ;
s != s_end ; ++s)
@@ -1030,8 +1020,7 @@ Decider::_add_dependencies_if_necessary(
r != r_end ; ++r)
{
const std::tr1::shared_ptr<Resolution> dep_resolution(_resolution_for_resolvent(*r, true));
- const std::tr1::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_dependency(
- our_resolution->resolvent(), *s, reason, interest));
+ const std::tr1::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_dependency(our_resolution, *s, reason, interest));
for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
c != c_end ; ++c)
@@ -1084,10 +1073,10 @@ namespace
}
std::pair<AnyChildScore, OperatorScore>
-Decider::find_any_score(const Resolvent & our_resolvent, const SanitisedDependency & dep) const
+Decider::find_any_score(const std::tr1::shared_ptr<const Resolution> & our_resolution, const SanitisedDependency & dep) const
{
Context context("When working out whether we'd like '" + stringify(dep.spec()) + "' because of '"
- + stringify(our_resolvent) + "':");
+ + stringify(our_resolution->resolvent()) + "':");
if (dep.spec().if_block())
throw InternalError(PALUDIS_HERE, "unimplemented: blockers inside || blocks are horrid");
@@ -1187,13 +1176,12 @@ Decider::find_any_score(const Resolvent & our_resolvent, const SanitisedDependen
return std::make_pair(acs_wrong_options_installed, operator_bias);
}
- const std::tr1::shared_ptr<const PackageID> id(resolution_for_resolvent(
- our_resolvent)->decision()->accept_returning<std::tr1::shared_ptr<const PackageID> >(
- ChosenIDVisitor()));
+ const std::tr1::shared_ptr<const PackageID> id(
+ our_resolution->decision()->accept_returning<std::tr1::shared_ptr<const PackageID> >(ChosenIDVisitor()));
if (! id)
throw InternalError(PALUDIS_HERE, "resolver bug: why don't we have an id?");
- const std::tr1::shared_ptr<DependencyReason> reason(new DependencyReason(id, our_resolvent, dep, _already_met(dep)));
+ const std::tr1::shared_ptr<DependencyReason> reason(new DependencyReason(id, our_resolution->resolvent(), dep, _already_met(dep)));
const std::tr1::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(spec, reason));
/* next: will already be installing */
@@ -1214,7 +1202,7 @@ Decider::find_any_score(const Resolvent & our_resolvent, const SanitisedDependen
{
const std::tr1::shared_ptr<Resolution> resolution(_create_resolution_for_resolvent(*r));
const std::tr1::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_dependency(
- our_resolvent, dep, reason, si_take));
+ our_resolution, dep, reason, si_take));
for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
c != c_end ; ++c)
resolution->constraints()->add(*c);
@@ -1566,7 +1554,7 @@ Decider::_make_unsuitable_candidate(
{
return make_named_values<UnsuitableCandidate>(
n::package_id() = id,
- n::unmet_constraints() = _get_unmatching_constraints(resolution->resolvent(), id, existing)
+ n::unmet_constraints() = _get_unmatching_constraints(resolution, id, existing)
);
}
@@ -1668,11 +1656,10 @@ Decider::_find_id_for_from(
const std::tr1::shared_ptr<const Constraints>
Decider::_get_unmatching_constraints(
- const Resolvent & resolvent,
+ const std::tr1::shared_ptr<const Resolution> & resolution,
const std::tr1::shared_ptr<const PackageID> & id,
const bool existing) const
{
- const std::tr1::shared_ptr<const Resolution> resolution(resolution_for_resolvent(resolvent));
const std::tr1::shared_ptr<Constraints> result(new Constraints);
for (Constraints::ConstIterator c(resolution->constraints()->begin()),
@@ -1686,7 +1673,7 @@ Decider::_get_unmatching_constraints(
bool is_transient(id->behaviours_key() && id->behaviours_key()->value()->end() !=
id->behaviours_key()->value()->find("transient"));
decision.reset(new ExistingNoChangeDecision(
- resolvent,
+ resolution->resolvent(),
id,
true,
true,
@@ -1696,7 +1683,7 @@ Decider::_get_unmatching_constraints(
}
else
decision.reset(new ChangesToMakeDecision(
- resolvent,
+ resolution->resolvent(),
id,
false,
last_ct,
@@ -1756,7 +1743,7 @@ Decider::add_target_with_reason(const PackageOrBlockDepSpec & spec, const std::t
+ stringify(*r) + "':");
const std::tr1::shared_ptr<Resolution> dep_resolution(_resolution_for_resolvent(*r, true));
- const std::tr1::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_target(*r, spec, reason));
+ const std::tr1::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_target(dep_resolution, spec, reason));
for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
c != c_end ; ++c)
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 273535c..5e2630b 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -74,17 +74,19 @@ namespace paludis
const std::tr1::shared_ptr<const Reason> & reason) const;
const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_from_target(
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const PackageOrBlockDepSpec &,
const std::tr1::shared_ptr<const Reason> &) const;
const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_from_dependency(
- const Resolvent &, const SanitisedDependency &,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const SanitisedDependency &,
const std::tr1::shared_ptr<const Reason> &,
const SpecInterest) const;
const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_from_blocker(
- const Resolvent & resolvent, const BlockDepSpec & dep,
+ const std::tr1::shared_ptr<const Resolution> &,
+ const BlockDepSpec & dep,
const std::tr1::shared_ptr<const Reason> & reason) const;
const std::tr1::shared_ptr<ConstraintSequence> _make_constraints_for_dependent(
@@ -176,7 +178,7 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSequence> &) const;
const std::tr1::shared_ptr<const Constraints> _get_unmatching_constraints(
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const PackageID> &,
const bool existing) const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -220,12 +222,11 @@ namespace paludis
void add_target_with_reason(const PackageOrBlockDepSpec &, const std::tr1::shared_ptr<const Reason> &);
- std::pair<AnyChildScore, OperatorScore> find_any_score(const Resolvent &, const SanitisedDependency &) const;
+ std::pair<AnyChildScore, OperatorScore> find_any_score(
+ const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency &) const;
const std::tr1::shared_ptr<const RewrittenSpec> rewrite_if_special(const PackageOrBlockDepSpec &,
const std::tr1::shared_ptr<const Resolvent> & maybe_from) const;
-
- const std::tr1::shared_ptr<Resolution> resolution_for_resolvent(const Resolvent &) const;
};
}
}
diff --git a/paludis/resolver/resolver_TEST_cycles.cc b/paludis/resolver/resolver_TEST_cycles.cc
index 7770777..a1df690 100644
--- a/paludis/resolver/resolver_TEST_cycles.cc
+++ b/paludis/resolver/resolver_TEST_cycles.cc
@@ -65,7 +65,7 @@ namespace
UseExisting
use_existing_if_same(
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const PackageDepSpec &,
const std::tr1::shared_ptr<const Reason> &)
{
diff --git a/paludis/resolver/resolver_functions.hh b/paludis/resolver/resolver_functions.hh
index b435ece..8ccc281 100644
--- a/paludis/resolver/resolver_functions.hh
+++ b/paludis/resolver/resolver_functions.hh
@@ -103,7 +103,7 @@ namespace paludis
)> GetResolventsForFunction;
typedef std::tr1::function<UseExisting (
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const PackageDepSpec &,
const std::tr1::shared_ptr<const Reason> &
)> GetUseExistingFunction;
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 0ad7543..b2ce300 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -227,7 +227,7 @@ paludis::resolver::resolver_test::interest_in_spec_fn(
UseExisting
paludis::resolver::resolver_test::get_use_existing_fn(
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const PackageDepSpec &,
const std::tr1::shared_ptr<const Reason> &)
{
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index ee12d61..54b093c 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -79,7 +79,7 @@ namespace paludis
bool is_just_suggestion(const SanitisedDependency & dep);
UseExisting get_use_existing_fn(
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const PackageDepSpec &,
const std::tr1::shared_ptr<const Reason> &);
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index c525f52..4cb4aca 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -19,7 +19,7 @@
#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/resolver/resolver.hh>
-#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/spec_rewriter.hh>
#include <paludis/resolver/decider.hh>
#include <paludis/util/make_named_values.hh>
@@ -108,7 +108,7 @@ namespace
struct AnyDepSpecChildHandler
{
const Decider & decider;
- const Resolvent our_resolvent;
+ const std::tr1::shared_ptr<const Resolution> our_resolution;
const std::tr1::function<SanitisedDependency (const PackageOrBlockDepSpec &)> parent_make_sanitised;
bool super_complicated, nested;
@@ -118,10 +118,10 @@ namespace
bool seen_any;
- AnyDepSpecChildHandler(const Decider & r, const Resolvent & q,
+ AnyDepSpecChildHandler(const Decider & r, const std::tr1::shared_ptr<const Resolution> & q,
const std::tr1::function<SanitisedDependency (const PackageOrBlockDepSpec &)> & f) :
decider(r),
- our_resolvent(q),
+ our_resolution(q),
parent_make_sanitised(f),
super_complicated(false),
nested(false),
@@ -135,7 +135,7 @@ namespace
seen_any = true;
const std::tr1::shared_ptr<const RewrittenSpec> if_rewritten(decider.rewrite_if_special(spec,
- make_shared_copy(our_resolvent)));
+ make_shared_copy(our_resolution->resolvent())));
if (if_rewritten)
if_rewritten->as_spec_tree()->root()->accept(*this);
else
@@ -210,7 +210,7 @@ namespace
void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node)
{
- AnyDepSpecChildHandler h(decider, our_resolvent, parent_make_sanitised);
+ AnyDepSpecChildHandler h(decider, our_resolution, parent_make_sanitised);
std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(h));
std::list<SanitisedDependency> l;
h.commit(
@@ -271,7 +271,7 @@ namespace
h != h_end ; ++h)
{
std::pair<AnyChildScore, OperatorScore> score(
- decider.find_any_score(our_resolvent, make_sanitised(PackageOrBlockDepSpec(*h))));
+ decider.find_any_score(our_resolution, make_sanitised(PackageOrBlockDepSpec(*h))));
if (score < worst_score)
worst_score = score;
}
@@ -295,7 +295,7 @@ namespace
struct Finder
{
const Decider & decider;
- const Resolvent our_resolvent;
+ const std::tr1::shared_ptr<const Resolution> our_resolution;
SanitisedDependencies & sanitised_dependencies;
const std::string raw_name;
const std::string human_name;
@@ -304,14 +304,14 @@ namespace
Finder(
const Decider & r,
- const Resolvent & q,
+ const std::tr1::shared_ptr<const Resolution> & q,
SanitisedDependencies & s,
const std::tr1::shared_ptr<const DependenciesLabelSequence> & l,
const std::string & rn,
const std::string & hn,
const std::string & a) :
decider(r),
- our_resolvent(q),
+ our_resolution(q),
sanitised_dependencies(s),
raw_name(rn),
human_name(hn),
@@ -324,7 +324,7 @@ namespace
void add(const SanitisedDependency & dep)
{
const std::tr1::shared_ptr<const RewrittenSpec> if_rewritten(decider.rewrite_if_special(dep.spec(),
- make_shared_copy(our_resolvent)));
+ make_shared_copy(our_resolution->resolvent())));
if (if_rewritten)
if_rewritten->as_spec_tree()->root()->accept(*this);
else
@@ -386,7 +386,7 @@ namespace
original_specs_as_string = "|| (" + v.result + " )";
}
- AnyDepSpecChildHandler h(decider, our_resolvent, std::tr1::bind(&Finder::make_sanitised, this, std::tr1::placeholders::_1));
+ AnyDepSpecChildHandler h(decider, our_resolution, std::tr1::bind(&Finder::make_sanitised, this, std::tr1::placeholders::_1));
std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(h));
h.commit(
std::tr1::bind(&Finder::make_sanitised, this, std::tr1::placeholders::_1),
@@ -435,14 +435,14 @@ SanitisedDependencies::~SanitisedDependencies()
void
SanitisedDependencies::_populate_one(
const Decider & decider,
- const Resolvent & resolvent,
+ const std::tr1::shared_ptr<const Resolution> & resolution,
const std::tr1::shared_ptr<const PackageID> & id,
const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > (PackageID::* const pmf) () const
)
{
Context context("When finding dependencies for '" + stringify(*id) + "' from key '" + ((*id).*pmf)()->raw_name() + "':");
- Finder f(decider, resolvent, *this, ((*id).*pmf)()->initial_labels(), ((*id).*pmf)()->raw_name(),
+ Finder f(decider, resolution, *this, ((*id).*pmf)()->initial_labels(), ((*id).*pmf)()->raw_name(),
((*id).*pmf)()->human_name(), "");
((*id).*pmf)()->value()->root()->accept(f);
}
@@ -450,23 +450,23 @@ SanitisedDependencies::_populate_one(
void
SanitisedDependencies::populate(
const Decider & decider,
- const Resolvent & resolvent,
+ const std::tr1::shared_ptr<const Resolution> & resolution,
const std::tr1::shared_ptr<const PackageID> & id)
{
Context context("When finding dependencies for '" + stringify(*id) + "':");
if (id->dependencies_key())
- _populate_one(decider, resolvent, id, &PackageID::dependencies_key);
+ _populate_one(decider, resolution, id, &PackageID::dependencies_key);
else
{
if (id->build_dependencies_key())
- _populate_one(decider, resolvent, id, &PackageID::build_dependencies_key);
+ _populate_one(decider, resolution, id, &PackageID::build_dependencies_key);
if (id->run_dependencies_key())
- _populate_one(decider, resolvent, id, &PackageID::run_dependencies_key);
+ _populate_one(decider, resolution, id, &PackageID::run_dependencies_key);
if (id->post_dependencies_key())
- _populate_one(decider, resolvent, id, &PackageID::post_dependencies_key);
+ _populate_one(decider, resolution, id, &PackageID::post_dependencies_key);
if (id->suggested_dependencies_key())
- _populate_one(decider, resolvent, id, &PackageID::suggested_dependencies_key);
+ _populate_one(decider, resolution, id, &PackageID::suggested_dependencies_key);
}
}
diff --git a/paludis/resolver/sanitised_dependencies.hh b/paludis/resolver/sanitised_dependencies.hh
index c57b0c3..062202d 100644
--- a/paludis/resolver/sanitised_dependencies.hh
+++ b/paludis/resolver/sanitised_dependencies.hh
@@ -22,7 +22,7 @@
#include <paludis/resolver/sanitised_dependencies-fwd.hh>
#include <paludis/resolver/decider-fwd.hh>
-#include <paludis/resolver/resolvent-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
#include <paludis/resolver/package_or_block_dep_spec.hh>
#include <paludis/util/named_value.hh>
#include <paludis/dep_label-fwd.hh>
@@ -67,7 +67,7 @@ namespace paludis
private:
void _populate_one(
const Decider &,
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const PackageID> &,
const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > (PackageID::* const) () const
);
@@ -78,7 +78,7 @@ namespace paludis
void populate(
const Decider &,
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const PackageID> &);
void add(const SanitisedDependency & d);
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 794c103..e528aed 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -486,7 +486,7 @@ namespace
const ResolveCommandLineResolutionOptions & resolution_options,
const PackageDepSpecList & without,
const PackageDepSpecList & with,
- const Resolvent &,
+ const std::tr1::shared_ptr<const Resolution> &,
const PackageDepSpec & spec,
const std::tr1::shared_ptr<const Reason> & reason)
{