aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paludis/resolver/decider.cc125
-rw-r--r--paludis/resolver/decision-fwd.hh3
-rw-r--r--paludis/resolver/decision.cc56
-rw-r--r--paludis/resolver/decision.hh21
-rw-r--r--paludis/resolver/orderer.cc5
-rw-r--r--paludis/resolver/resolver_test.cc10
-rw-r--r--src/clients/cave/cmd_display_resolution.cc11
-rw-r--r--src/clients/cave/cmd_resolve_dump.cc7
-rw-r--r--src/clients/cave/resolve_common.cc15
9 files changed, 218 insertions, 35 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 1dfeb25..9b062f7 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -159,6 +159,10 @@ namespace
{
}
+ void visit(RemoveDecision &)
+ {
+ }
+
void visit(ExistingNoChangeDecision &)
{
}
@@ -388,26 +392,57 @@ Decider::_apply_resolution_constraint(
namespace
{
- struct ChosenIDVisitor
+ struct CheckConstraintVisitor
{
- const std::tr1::shared_ptr<const PackageID> visit(const ChangesToMakeDecision & decision) const
+ const Environment * const env;
+ const Constraint constraint;
+
+ CheckConstraintVisitor(const Environment * const e, const Constraint & c) :
+ env(e),
+ constraint(c)
{
- return decision.origin_id();
}
- const std::tr1::shared_ptr<const PackageID> visit(const ExistingNoChangeDecision & decision) const
+ bool ok(const std::tr1::shared_ptr<const PackageID> & chosen_id) const
{
- return decision.existing_id();
+ if (constraint.spec().if_package())
+ {
+ if (! match_package(*env, *constraint.spec().if_package(), *chosen_id, MatchPackageOptions()))
+ return false;
+ }
+ else
+ {
+ if (match_package(*env, constraint.spec().if_block()->blocking(),
+ *chosen_id, MatchPackageOptions()))
+ return false;
+ }
+
+ return true;
}
- const std::tr1::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
+ bool visit(const ChangesToMakeDecision & decision) const
{
- return make_null_shared_ptr();
+ return ok(decision.origin_id());
}
- const std::tr1::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
+ bool visit(const ExistingNoChangeDecision & decision) const
{
- return make_null_shared_ptr();
+ return ok(decision.existing_id());
+ }
+
+ bool visit(const NothingNoChangeDecision &) const
+ {
+ return constraint.nothing_is_fine_too();
+ }
+
+ bool visit(const UnableToMakeDecision &) const
+ {
+ return constraint.nothing_is_fine_too();
+ }
+
+ bool visit(const RemoveDecision &) const
+ {
+ return constraint.nothing_is_fine_too();
}
};
@@ -464,6 +499,11 @@ namespace
{
return true;
}
+
+ bool visit(const RemoveDecision &) const
+ {
+ return true;
+ }
};
}
@@ -472,28 +512,8 @@ Decider::_check_constraint(const Resolvent &,
const std::tr1::shared_ptr<const Constraint> & constraint,
const std::tr1::shared_ptr<const Decision> & decision) const
{
- const std::tr1::shared_ptr<const PackageID> chosen_id(decision->accept_returning<
- std::tr1::shared_ptr<const PackageID> >(ChosenIDVisitor()));
-
- if (chosen_id)
- {
- if (constraint->spec().if_package())
- {
- if (! match_package(*_imp->env, *constraint->spec().if_package(), *chosen_id, MatchPackageOptions()))
- return false;
- }
- else
- {
- if (match_package(*_imp->env, constraint->spec().if_block()->blocking(),
- *chosen_id, MatchPackageOptions()))
- return false;
- }
- }
- else
- {
- if (! constraint->nothing_is_fine_too())
- return false;
- }
+ if (! decision->accept_returning<bool>(CheckConstraintVisitor(_imp->env, *constraint)))
+ return false;
if (! decision->accept_returning<bool>(CheckUseExistingVisitor(constraint)))
return false;
@@ -531,6 +551,11 @@ namespace
/* going from nothing to something is fine */
}
+ void visit(const RemoveDecision &) const
+ {
+ restart();
+ }
+
void visit(const UnableToMakeDecision &) const
{
restart();
@@ -639,6 +664,11 @@ namespace
return make_null_shared_ptr();
}
+ const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
const std::tr1::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
{
return make_null_shared_ptr();
@@ -733,6 +763,37 @@ Decider::_initial_constraints_for(const Resolvent & r) const
return _imp->fns.get_initial_constraints_for_fn()(r);
}
+namespace
+{
+ struct ChosenIDVisitor
+ {
+ const std::tr1::shared_ptr<const PackageID> visit(const ChangesToMakeDecision & decision) const
+ {
+ return decision.origin_id();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const ExistingNoChangeDecision & decision) const
+ {
+ return decision.existing_id();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
+ const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+ };
+}
+
std::pair<AnyChildScore, OperatorScore>
Decider::find_any_score(const Resolvent & our_resolvent, const SanitisedDependency & dep) const
{
diff --git a/paludis/resolver/decision-fwd.hh b/paludis/resolver/decision-fwd.hh
index c1e49b6..0d118df 100644
--- a/paludis/resolver/decision-fwd.hh
+++ b/paludis/resolver/decision-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -33,6 +33,7 @@ namespace paludis
class ExistingNoChangeDecision;
class ChangesToMakeDecision;
class UnableToMakeDecision;
+ class RemoveDecision;
}
}
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index c27a7cf..5c9a7c4 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -68,6 +68,10 @@ Decision::deserialise(Deserialisation & d)
{
return UnableToMakeDecision::deserialise(d);
}
+ else if (d.class_name() == "RemoveDecision")
+ {
+ return RemoveDecision::deserialise(d);
+ }
else
throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
}
@@ -100,6 +104,16 @@ UnableToMakeDecision::deserialise(Deserialisation & d)
));
}
+const std::tr1::shared_ptr<RemoveDecision>
+RemoveDecision::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "RemoveDecision");
+
+ return make_shared_ptr(new RemoveDecision(
+ v.member<bool>("taken")
+ ));
+}
+
namespace paludis
{
template <>
@@ -355,8 +369,50 @@ UnableToMakeDecision::serialise(Serialiser & s) const
;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<RemoveDecision>
+ {
+ const bool taken;
+
+ Implementation(const bool t) :
+ taken(t)
+ {
+ }
+ };
+}
+
+RemoveDecision::RemoveDecision(const bool t) :
+ PrivateImplementationPattern<RemoveDecision>(new Implementation<RemoveDecision>(t))
+{
+}
+
+#ifdef PALUDIS_HAVE_DEFAULT_DELETED
+RemoveDecision::~RemoveDecision() = default;
+#else
+RemoveDecision::~RemoveDecision()
+{
+}
+#endif
+
+bool
+RemoveDecision::taken() const
+{
+ return _imp->taken;
+}
+
+void
+RemoveDecision::serialise(Serialiser & s) const
+{
+ s.object("RemoveDecision")
+ .member(SerialiserFlags<>(), "taken", taken())
+ ;
+}
+
template class PrivateImplementationPattern<NothingNoChangeDecision>;
template class PrivateImplementationPattern<ExistingNoChangeDecision>;
template class PrivateImplementationPattern<ChangesToMakeDecision>;
template class PrivateImplementationPattern<UnableToMakeDecision>;
+template class PrivateImplementationPattern<RemoveDecision>;
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index 026aace..12fb6f1 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -35,7 +35,8 @@ namespace paludis
{
class PALUDIS_VISIBLE Decision :
public virtual DeclareAbstractAcceptMethods<Decision, MakeTypeList<
- NothingNoChangeDecision, ExistingNoChangeDecision, ChangesToMakeDecision, UnableToMakeDecision>::Type>
+ NothingNoChangeDecision, ExistingNoChangeDecision, ChangesToMakeDecision,
+ RemoveDecision, UnableToMakeDecision>::Type>
{
public:
virtual ~Decision() = 0;
@@ -123,6 +124,23 @@ namespace paludis
Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class PALUDIS_VISIBLE RemoveDecision :
+ public Decision,
+ public ImplementAcceptMethods<Decision, RemoveDecision>,
+ private PrivateImplementationPattern<RemoveDecision>
+ {
+ public:
+ RemoveDecision(const bool taken);
+ ~RemoveDecision();
+
+ virtual bool taken() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void serialise(Serialiser &) const;
+
+ static const std::tr1::shared_ptr<RemoveDecision> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
class PALUDIS_VISIBLE UnableToMakeDecision :
public Decision,
public ImplementAcceptMethods<Decision, UnableToMakeDecision>,
@@ -151,6 +169,7 @@ namespace paludis
extern template class PrivateImplementationPattern<resolver::ExistingNoChangeDecision>;
extern template class PrivateImplementationPattern<resolver::ChangesToMakeDecision>;
extern template class PrivateImplementationPattern<resolver::UnableToMakeDecision>;
+ extern template class PrivateImplementationPattern<resolver::RemoveDecision>;
#endif
}
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index a51411a..56fce24 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -229,6 +229,11 @@ namespace
lists->untaken_error_job_ids()->push_back(error_job->id());
}
}
+
+ void visit(const RemoveDecision &) PALUDIS_ATTRIBUTE((noreturn))
+ {
+ throw InternalError(PALUDIS_HERE, "remove decision");
+ }
};
}
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 72b45f5..04633e0 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -349,6 +349,11 @@ namespace
return decision.existing_id();
}
+ const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
const std::tr1::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
{
return make_null_shared_ptr();
@@ -367,6 +372,11 @@ namespace
return "unable_to_make_decision";
}
+ const std::string visit(const RemoveDecision &) const
+ {
+ return "remove_decision";
+ }
+
const std::string visit(const NothingNoChangeDecision &) const
{
return "nothing_no_change";
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index a8c5dc3..c64f01b 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -183,6 +183,11 @@ namespace
return make_null_shared_ptr();
}
+ const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
const std::tr1::shared_ptr<const PackageID> visit(const NothingNoChangeDecision &) const
{
return make_null_shared_ptr();
@@ -276,6 +281,12 @@ namespace
cout << " Use existing ID " << *d.existing_id() << endl;
}
+ void visit(const RemoveDecision &) const
+ {
+ cout << " The decision made was:" << endl;
+ cout << " Remove existing IDs" << endl;
+ }
+
void visit(const NothingNoChangeDecision &) const
{
cout << " The decision made was:" << endl;
diff --git a/src/clients/cave/cmd_resolve_dump.cc b/src/clients/cave/cmd_resolve_dump.cc
index fe8f0c3..66482e7 100644
--- a/src/clients/cave/cmd_resolve_dump.cc
+++ b/src/clients/cave/cmd_resolve_dump.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -77,6 +77,11 @@ namespace
return "UnableToMakeDecision(taken: " + stringify(d.taken()) + ")";
}
+ const std::string visit(const RemoveDecision & d) const
+ {
+ return "RemoveDecision(taken: " + stringify(d.taken()) + ")";
+ }
+
const std::string visit(const NothingNoChangeDecision & d) const
{
return "NothingNoChangeDecision(taken: " + stringify(d.taken()) + ")";
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 133dc41..c2a25b8 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -760,6 +760,11 @@ namespace
throw InternalError(PALUDIS_HERE, "UnableToMakeDecision shouldn't have deps");
}
+ bool visit(const RemoveDecision &) const PALUDIS_ATTRIBUTE((noreturn))
+ {
+ throw InternalError(PALUDIS_HERE, "RemoveDecision shouldn't have deps");
+ }
+
bool visit(const ChangesToMakeDecision &) const
{
if (is_enabled_dep(dep))
@@ -1059,6 +1064,11 @@ namespace
return make_null_shared_ptr();
}
+ const std::tr1::shared_ptr<const PackageID> visit(const RemoveDecision &) const
+ {
+ return make_null_shared_ptr();
+ }
+
const std::tr1::shared_ptr<const PackageID> visit(const UnableToMakeDecision &) const
{
return make_null_shared_ptr();
@@ -1067,6 +1077,11 @@ namespace
struct KindNameVisitor
{
+ const std::string visit(const RemoveDecision &) const
+ {
+ return "remove_decision";
+ }
+
const std::string visit(const UnableToMakeDecision &) const
{
return "unable_to_make_decision";