aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-06 21:45:00 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-06 21:45:18 +0100
commit44dd3df4741f11942e580036f6589054ac42d551 (patch)
tree9597f1cb83fc94c861d308186444b306174adad7
parent8939f5a4b07bd4f1fe044d4bb7b6a48c7c76097c (diff)
downloadpaludis-44dd3df4741f11942e580036f6589054ac42d551.tar.gz
paludis-44dd3df4741f11942e580036f6589054ac42d551.tar.xz
Don't make internals stringifiable
-rw-r--r--paludis/resolver/arrow-fwd.hh3
-rw-r--r--paludis/resolver/arrow.cc10
-rw-r--r--paludis/resolver/constraint-fwd.hh3
-rw-r--r--paludis/resolver/constraint.cc16
-rw-r--r--paludis/resolver/decision-fwd.hh3
-rw-r--r--paludis/resolver/decision.cc29
-rw-r--r--paludis/resolver/destinations-fwd.hh4
-rw-r--r--paludis/resolver/destinations.cc27
-rw-r--r--paludis/resolver/reason-fwd.hh3
-rw-r--r--paludis/resolver/reason.cc31
-rw-r--r--paludis/resolver/reason.hh9
-rw-r--r--paludis/resolver/resolution-fwd.hh3
-rw-r--r--paludis/resolver/resolution.cc15
-rw-r--r--paludis/resolver/resolver.cc45
-rw-r--r--paludis/resolver/sanitised_dependencies-fwd.hh1
-rw-r--r--paludis/resolver/sanitised_dependencies.cc25
-rw-r--r--paludis/resolver/suggest_restart.cc3
-rw-r--r--src/clients/cave/cmd_display_resolution.cc3
-rw-r--r--src/clients/cave/cmd_resolve.cc11
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.cc8
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.hh8
-rw-r--r--src/clients/cave/cmd_resolve_dump.cc243
22 files changed, 274 insertions, 229 deletions
diff --git a/paludis/resolver/arrow-fwd.hh b/paludis/resolver/arrow-fwd.hh
index e36f55d..f3a79e3 100644
--- a/paludis/resolver/arrow-fwd.hh
+++ b/paludis/resolver/arrow-fwd.hh
@@ -23,7 +23,6 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/sequence-fwd.hh>
#include <tr1/memory>
-#include <iosfwd>
namespace paludis
{
@@ -32,8 +31,6 @@ namespace paludis
struct Arrow;
typedef Sequence<std::tr1::shared_ptr<Arrow> > ArrowSequence;
-
- std::ostream & operator<< (std::ostream & s, const Arrow &) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/arrow.cc b/paludis/resolver/arrow.cc
index d8f58ab..56c36c6 100644
--- a/paludis/resolver/arrow.cc
+++ b/paludis/resolver/arrow.cc
@@ -26,16 +26,6 @@
using namespace paludis;
using namespace paludis::resolver;
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Arrow & a)
-{
- s << "Arrow(-> " << a.to_qpn_s();
- if (0 != a.ignorable_pass())
- s << ", ignorable pass " << a.ignorable_pass();
- s << ")";
- return s;
-}
-
void
Arrow::serialise(Serialiser & s) const
{
diff --git a/paludis/resolver/constraint-fwd.hh b/paludis/resolver/constraint-fwd.hh
index e9943e9..74c607c 100644
--- a/paludis/resolver/constraint-fwd.hh
+++ b/paludis/resolver/constraint-fwd.hh
@@ -23,7 +23,6 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/sequence-fwd.hh>
#include <tr1/memory>
-#include <iosfwd>
namespace paludis
{
@@ -31,8 +30,6 @@ namespace paludis
{
struct Constraint;
struct Constraints;
-
- std::ostream & operator<< (std::ostream & s, const Constraint & c) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/constraint.cc b/paludis/resolver/constraint.cc
index 4f261f0..e1458d7 100644
--- a/paludis/resolver/constraint.cc
+++ b/paludis/resolver/constraint.cc
@@ -31,22 +31,6 @@
using namespace paludis;
using namespace paludis::resolver;
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Constraint & c)
-{
- std::stringstream ss;
- ss << "Constraint(spec: " << c.spec();
- if (c.nothing_is_fine_too())
- ss << "; nothing is fine too";
- ss
- << "; use_installed: " << stringify(c.use_installed())
- << "; reason: " << (c.reason() ? stringify(*c.reason()) : "none")
- << ")";
- s << ss.str();
-
- return s;
-}
-
namespace paludis
{
template <>
diff --git a/paludis/resolver/decision-fwd.hh b/paludis/resolver/decision-fwd.hh
index a17c564..d18f247 100644
--- a/paludis/resolver/decision-fwd.hh
+++ b/paludis/resolver/decision-fwd.hh
@@ -21,15 +21,12 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_DECISION_FWD_HH 1
#include <paludis/util/attributes.hh>
-#include <iosfwd>
namespace paludis
{
namespace resolver
{
struct Decision;
-
- std::ostream & operator<< (std::ostream & s, const Decision & d) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index e00ed96..87b47d3 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -25,35 +25,6 @@
using namespace paludis;
using namespace paludis::resolver;
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Decision & d)
-{
- std::stringstream ss;
-
- ss << "Decision(";
-
- if (d.if_package_id())
- ss << *d.if_package_id();
- else
- ss << "(nothing)";
-
- if (d.is_best())
- ss << ", is best";
- if (d.is_installed())
- ss << ", is installed";
- if (d.is_nothing())
- ss << ", is nothing";
- if (d.is_same())
- ss << ", is same";
- if (d.is_same_version())
- ss << ", is same version";
-
- ss << ")";
-
- s << ss.str();
- return s;
-}
-
void
Decision::serialise(Serialiser & s) const
{
diff --git a/paludis/resolver/destinations-fwd.hh b/paludis/resolver/destinations-fwd.hh
index 9424462..5c472f9 100644
--- a/paludis/resolver/destinations-fwd.hh
+++ b/paludis/resolver/destinations-fwd.hh
@@ -21,7 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESTINATIONS_FWD_HH 1
#include <paludis/util/attributes.hh>
-#include <iosfwd>
namespace paludis
{
@@ -29,9 +28,6 @@ namespace paludis
{
struct Destination;
struct Destinations;
-
- std::ostream & operator<< (std::ostream &, const Destination &) PALUDIS_VISIBLE;
- std::ostream & operator<< (std::ostream &, const Destinations &) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/destinations.cc b/paludis/resolver/destinations.cc
index 26c086a..62b4423 100644
--- a/paludis/resolver/destinations.cc
+++ b/paludis/resolver/destinations.cc
@@ -31,33 +31,6 @@
using namespace paludis;
using namespace paludis::resolver;
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Destination & d)
-{
- std::stringstream ss;
- ss << "Destination(" << d.repository();
- if (! d.replacing()->empty())
- ss << " replacing " << join(indirect_iterator(d.replacing()->begin()),
- indirect_iterator(d.replacing()->end()), ", ");
- ss << ")";
-
- s << ss.str();
- return s;
-}
-
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Destinations & d)
-{
- std::stringstream ss;
- ss << "Destinations(";
- if (d.slash())
- ss << "slash: " << *d.slash();
- ss << ")";
-
- s << ss.str();
- return s;
-}
-
void
Destinations::serialise(Serialiser & s) const
{
diff --git a/paludis/resolver/reason-fwd.hh b/paludis/resolver/reason-fwd.hh
index 245f2e3..14d0ae2 100644
--- a/paludis/resolver/reason-fwd.hh
+++ b/paludis/resolver/reason-fwd.hh
@@ -21,7 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_REASON_FWD_HH 1
#include <paludis/util/attributes.hh>
-#include <iosfwd>
namespace paludis
{
@@ -32,8 +31,6 @@ namespace paludis
struct TargetReason;
struct PresetReason;
struct SetReason;
-
- std::ostream & operator<< (std::ostream & s, const Reason &) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index 382e6e1..6bd93d3 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -27,23 +27,10 @@
using namespace paludis;
using namespace paludis::resolver;
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Reason & r)
-{
- s << r.as_string();
- return s;
-}
-
Reason::~Reason()
{
}
-std::string
-TargetReason::as_string() const
-{
- return "Target()";
-}
-
void
TargetReason::serialise(Serialiser & s) const
{
@@ -89,12 +76,6 @@ DependencyReason::sanitised_dependency() const
return _imp->dep;
}
-std::string
-DependencyReason::as_string() const
-{
- return "Dependency(package: " + stringify(*_imp->from_id) + " dep: " + stringify(_imp->dep) + ")";
-}
-
void
DependencyReason::serialise(Serialiser & s) const
{
@@ -104,12 +85,6 @@ DependencyReason::serialise(Serialiser & s) const
;
}
-std::string
-PresetReason::as_string() const
-{
- return "Preset()";
-}
-
void
PresetReason::serialise(Serialiser & s) const
{
@@ -154,12 +129,6 @@ SetReason::reason_for_set() const
return _imp->reason_for_set;
}
-std::string
-SetReason::as_string() const
-{
- return "Set(set: " + stringify(_imp->set_name) + " because: " + stringify(*_imp->reason_for_set) + ")";
-}
-
void
SetReason::serialise(Serialiser & s) const
{
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 3b0b2ee..b6d0f8c 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -41,7 +41,6 @@ namespace paludis
{
public:
virtual ~Reason() = 0;
- virtual std::string as_string() const = 0;
virtual void serialise(Serialiser &) const = 0;
@@ -54,8 +53,6 @@ namespace paludis
public ImplementAcceptMethods<Reason, TargetReason>
{
public:
- virtual std::string as_string() const;
-
virtual void serialise(Serialiser &) const;
};
@@ -74,8 +71,6 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> from_id() const;
const SanitisedDependency & sanitised_dependency() const;
- virtual std::string as_string() const;
-
virtual void serialise(Serialiser &) const;
};
@@ -84,8 +79,6 @@ namespace paludis
public ImplementAcceptMethods<Reason, PresetReason>
{
public:
- virtual std::string as_string() const;
-
virtual void serialise(Serialiser &) const;
};
@@ -101,8 +94,6 @@ namespace paludis
const SetName set_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const Reason> reason_for_set() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string as_string() const;
-
virtual void serialise(Serialiser &) const;
};
}
diff --git a/paludis/resolver/resolution-fwd.hh b/paludis/resolver/resolution-fwd.hh
index 2167158..020d513 100644
--- a/paludis/resolver/resolution-fwd.hh
+++ b/paludis/resolver/resolution-fwd.hh
@@ -22,15 +22,12 @@
#include <paludis/util/attributes.hh>
#include <paludis/resolver/serialise-fwd.hh>
-#include <iosfwd>
namespace paludis
{
namespace resolver
{
struct Resolution;
-
- std::ostream & operator<< (std::ostream & s, const Resolution & r) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/resolution.cc b/paludis/resolver/resolution.cc
index 419ccd5..14aa889 100644
--- a/paludis/resolver/resolution.cc
+++ b/paludis/resolver/resolution.cc
@@ -34,21 +34,6 @@
using namespace paludis;
using namespace paludis::resolver;
-std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const Resolution & r)
-{
- std::stringstream ss;
- ss << "Resolution("
- << "constraints: " << join(indirect_iterator(r.constraints()->begin()), indirect_iterator(r.constraints()->end()), ", ")
- << "; decision: " << (r.decision() ? stringify(*r.decision()) : "none")
- << "; arrows: " << join(indirect_iterator(r.arrows()->begin()), indirect_iterator(r.arrows()->end()), ", ")
- << "; already_ordered: " << stringify(r.already_ordered()) << ")"
- << "; destinations: " << (r.destinations() ? stringify(*r.destinations()) : "unknown")
- << ")";
- s << ss.str();
- return s;
-}
-
void
Resolution::serialise(Serialiser & s) const
{
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 0f42e4d..88e6329 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -196,7 +196,8 @@ Resolver::_make_slash_destination_for(const QPN_S & qpn_s,
}
if (! repo)
- throw InternalError(PALUDIS_HERE, "no valid destination for " + stringify(*resolution));
+ throw InternalError(PALUDIS_HERE, "no valid destination for " +
+ stringify(*resolution->decision()->if_package_id()));
return make_shared_ptr(new Destination(make_named_values<Destination>(
value_for<n::replacing>(_find_replacing(resolution->decision()->if_package_id(), repo)),
@@ -257,7 +258,8 @@ Resolver::_same_slot(const std::tr1::shared_ptr<const PackageID> & a,
void
Resolver::add_target_with_reason(const PackageDepSpec & spec, const std::tr1::shared_ptr<const Reason> & reason)
{
- Context context("When adding target '" + stringify(spec) + "' with reason '" + stringify(*reason) + "':");
+ Context context("When adding target '" + stringify(spec) + "':");
+
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
const std::tr1::shared_ptr<const QPN_S_Sequence> qpn_s_s(_imp->fns.get_qpn_s_s_for_fn()(spec, reason));
@@ -479,11 +481,17 @@ Resolver::_made_wrong_decision(const QPN_S & qpn_s,
/* we've not already locked this to something. yes! */
_suggest_restart_with(qpn_s, resolution, constraint, decision);
}
- else
+ else if (decision->if_package_id())
{
/* we can restart if we've selected the same or a newer version
* than before. but we don't support that yet. */
- throw InternalError(PALUDIS_HERE, "should have selected " + stringify(*decision));
+ throw InternalError(PALUDIS_HERE, "should have selected " + stringify(*decision->if_package_id()));
+ }
+ else
+ {
+ /* probably possible if we can fix a block either by upgrading or
+ * removing, and we're later forced to remove */
+ throw InternalError(PALUDIS_HERE, "should have selected nothing");
}
}
else
@@ -522,8 +530,7 @@ Resolver::_make_constraint_for_preloading(
void
Resolver::_decide(const QPN_S & qpn_s, const std::tr1::shared_ptr<Resolution> & resolution)
{
- Context context("When deciding upon an origin ID to use for '" + stringify(qpn_s) + "' with '"
- + stringify(*resolution) + "':");
+ Context context("When deciding upon an origin ID to use for '" + stringify(qpn_s) + "':");
std::tr1::shared_ptr<Decision> decision(_try_to_find_decision_for(qpn_s, resolution));
if (decision)
@@ -535,12 +542,12 @@ Resolver::_decide(const QPN_S & qpn_s, const std::tr1::shared_ptr<Resolution> &
void
Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<Resolution> & our_resolution)
{
- Context context("When adding dependencies for '" + stringify(our_qpn_s) + "' with '"
- + stringify(*our_resolution) + "':");
-
if (! our_resolution->decision()->if_package_id())
throw InternalError(PALUDIS_HERE, "not decided. shouldn't happen.");
+ Context context("When adding dependencies for '" + stringify(our_qpn_s) + "' with '"
+ + stringify(*our_resolution->decision()->if_package_id()) + "':");
+
const std::tr1::shared_ptr<SanitisedDependencies> deps(new SanitisedDependencies);
deps->populate(*this, our_resolution->decision()->if_package_id());
our_resolution->sanitised_dependencies() = deps;
@@ -548,7 +555,7 @@ Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<
for (SanitisedDependencies::ConstIterator s(deps->begin()), s_end(deps->end()) ;
s != s_end ; ++s)
{
- Context context_2("When handling dependency '" + stringify(*s) + "':");
+ Context context_2("When handling dependency '" + stringify(s->spec()) + "':");
if (! _care_about_dependency_spec(our_qpn_s, our_resolution, *s))
continue;
@@ -567,7 +574,8 @@ Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<
{
if (our_resolution->decision()->is_installed())
Log::get_instance()->message("resolver.cannot_find_installed_dep", ll_warning, lc_context)
- << "Installed package '" << *our_resolution->decision() << "' dependency '" << *s << " cannot be met";
+ << "Installed package '" << *our_resolution->decision()->if_package_id()
+ << "' dependency '" << s->spec() << "' cannot be met";
else
throw InternalError(PALUDIS_HERE, "not implemented: no slot for " + stringify(s->spec()));
}
@@ -592,7 +600,7 @@ Resolver::_care_about_dependency_spec(const QPN_S & qpn_s,
if (dep.spec().if_block()->blocked_spec()->package_ptr()->category() == CategoryNamePart("virtual"))
{
Log::get_instance()->message("resolver.virtual_haxx", ll_warning, lc_context)
- << "Ignoring " << dep << " from " << qpn_s << " for now";
+ << "Ignoring " << dep.spec() << " from " << qpn_s << " for now";
return false;
}
@@ -839,7 +847,8 @@ Resolver::_unable_to_order_more() const
if (i->second->already_ordered())
continue;
- std::cout << " * " << *i->second->decision() << " because of cycle " << _find_cycle(i->first, true)
+ std::cout << " * " << *i->second->decision()->if_package_id() << " because of cycle "
+ << _find_cycle(i->first, true)
<< std::endl;
}
@@ -873,7 +882,7 @@ Resolver::end_resolutions_by_qpn_s() const
int
Resolver::find_any_score(const QPN_S & our_qpn_s, const SanitisedDependency & dep) const
{
- Context context("When working out whether we'd like '" + stringify(dep) + "' because of '"
+ Context context("When working out whether we'd like '" + stringify(dep.spec()) + "' because of '"
+ stringify(our_qpn_s) + "':");
if (dep.spec().if_block())
@@ -1041,13 +1050,7 @@ Resolver::_find_cycle(const QPN_S & start_qpn_s, const int ignorable_pass) const
}
if (! ok)
- throw InternalError(PALUDIS_HERE, "why did that happen? start is " + stringify(start_qpn_s)
- + ", current is " + stringify(current) + ", seen is { "
- + join(seen.begin(), seen.end(), ", ") + " }, result is "
- + result.str() + ", resolution->arrows is { "
- + join(indirect_iterator(resolution->arrows()->begin()),
- indirect_iterator(resolution->arrows()->end()), ", ") + "}"
- );
+ throw InternalError(PALUDIS_HERE, "why did that happen?");
}
return result.str();
diff --git a/paludis/resolver/sanitised_dependencies-fwd.hh b/paludis/resolver/sanitised_dependencies-fwd.hh
index 9ef1bb5..e04ec68 100644
--- a/paludis/resolver/sanitised_dependencies-fwd.hh
+++ b/paludis/resolver/sanitised_dependencies-fwd.hh
@@ -32,7 +32,6 @@ namespace paludis
struct PackageOrBlockDepSpec;
- std::ostream & operator<< (std::ostream & s, const SanitisedDependency & d) PALUDIS_VISIBLE;
std::ostream & operator<< (std::ostream & s, const PackageOrBlockDepSpec & d) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index 3c346da..35d3ffc 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -374,31 +374,6 @@ SanitisedDependencies::end() const
}
std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const SanitisedDependency & d)
-{
- std::stringstream ss;
- ss << "Dep(" << d.spec();
-
- if (! d.active_dependency_labels()->system_labels()->empty())
- ss << " system { " << join(indirect_iterator(d.active_dependency_labels()->system_labels()->begin()),
- indirect_iterator(d.active_dependency_labels()->system_labels()->end()), ", ") << " }";
- if (! d.active_dependency_labels()->type_labels()->empty())
- ss << " type { " << join(indirect_iterator(d.active_dependency_labels()->type_labels()->begin()),
- indirect_iterator(d.active_dependency_labels()->type_labels()->end()), ", ") << " }";
- if (! d.active_dependency_labels()->abi_labels()->empty())
- ss << " abi { " << join(indirect_iterator(d.active_dependency_labels()->abi_labels()->begin()),
- indirect_iterator(d.active_dependency_labels()->abi_labels()->end()), ", ") << " }";
- if (! d.active_dependency_labels()->suggest_labels()->empty())
- ss << " suggest { " << join(indirect_iterator(d.active_dependency_labels()->suggest_labels()->begin()),
- indirect_iterator(d.active_dependency_labels()->suggest_labels()->end()), ", ") << " }";
-
- ss << ")";
-
- s << ss.str();
- return s;
-}
-
-std::ostream &
paludis::resolver::operator<< (std::ostream & s, const PackageOrBlockDepSpec & d)
{
if (d.if_package())
diff --git a/paludis/resolver/suggest_restart.cc b/paludis/resolver/suggest_restart.cc
index b25437f..f147dae 100644
--- a/paludis/resolver/suggest_restart.cc
+++ b/paludis/resolver/suggest_restart.cc
@@ -19,6 +19,7 @@
#include <paludis/resolver/suggest_restart.hh>
#include <paludis/resolver/qpn_s.hh>
+#include <paludis/resolver/constraint.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
@@ -59,7 +60,7 @@ SuggestRestart::SuggestRestart(const QPN_S & q,
const std::tr1::shared_ptr<const Constraint> & nc
) throw () :
PrivateImplementationPattern<SuggestRestart>(new Implementation<SuggestRestart>(q, pd, pc, nd, nc)),
- Exception("Suggesting restart with " + stringify(*nc) + " for " + stringify(q))
+ Exception("Suggesting restart with " + stringify(nc->spec()) + " for " + stringify(q))
{
}
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index c2e4236..a721791 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -379,7 +379,8 @@ namespace
void visit(const DependencyReason & reason)
{
- std::cout << "of dependency " << reason.sanitised_dependency() << " from " << *reason.from_id();
+ std::cout << "of dependency " << reason.sanitised_dependency().spec()
+ << " from " << *reason.from_id();
}
void visit(const PresetReason &)
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index af0ea0b..571259b 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -679,20 +679,19 @@ ResolveCommand::run(
{
while (true)
{
+ DisplayCallback display_callback;
+ ScopedNotifierCallback display_callback_holder(env.get(),
+ NotifierCallbackFunction(std::tr1::cref(display_callback)));
+
try
{
- DisplayCallback display_callback;
- ScopedNotifierCallback display_callback_holder(env.get(),
- NotifierCallbackFunction(std::tr1::cref(display_callback)));
add_resolver_targets(env, resolver, cmdline);
resolver->resolve();
break;
}
catch (const SuggestRestart & e)
{
- std::cout << "Restarting: for '" << e.qpn_s() << "' we had chosen '" << *e.previous_decision()
- << "' but new constraint '" << *e.problematic_constraint() << "' means we now want '"
- << *e.new_decision() << "' instead" << std::endl;
+ display_callback(ResolverRestart());
initial_constraints.insert(std::make_pair(e.qpn_s(), make_initial_constraints_for(
env.get(), cmdline, e.qpn_s()))).first->second->add(
e.suggested_preset());
diff --git a/src/clients/cave/cmd_resolve_display_callback.cc b/src/clients/cave/cmd_resolve_display_callback.cc
index 6f00051..d1f7997 100644
--- a/src/clients/cave/cmd_resolve_display_callback.cc
+++ b/src/clients/cave/cmd_resolve_display_callback.cc
@@ -62,6 +62,14 @@ DisplayCallback::operator() (const NotifierCallbackEvent & event) const
}
void
+DisplayCallback::operator() (const ResolverRestart &) const
+{
+ Lock lock(_imp->mutex);
+ ++_imp->steps.insert(std::make_pair("restarts", 0)).first->second;
+ update();
+}
+
+void
DisplayCallback::visit(const NotifierCallbackGeneratingMetadataEvent & e) const
{
Lock lock(_imp->mutex);
diff --git a/src/clients/cave/cmd_resolve_display_callback.hh b/src/clients/cave/cmd_resolve_display_callback.hh
index bf5ab55..c443911 100644
--- a/src/clients/cave/cmd_resolve_display_callback.hh
+++ b/src/clients/cave/cmd_resolve_display_callback.hh
@@ -28,7 +28,11 @@ namespace paludis
{
namespace cave
{
- struct DisplayCallback :
+ struct ResolverRestart
+ {
+ };
+
+ class DisplayCallback :
private PrivateImplementationPattern<DisplayCallback>
{
private:
@@ -40,6 +44,8 @@ namespace paludis
void operator() (const NotifierCallbackEvent & event) const;
+ void operator() (const ResolverRestart &) const;
+
void visit(const NotifierCallbackGeneratingMetadataEvent &) const;
void visit(const NotifierCallbackResolverStepEvent &) const;
diff --git a/src/clients/cave/cmd_resolve_dump.cc b/src/clients/cave/cmd_resolve_dump.cc
index 951bde2..f016c70 100644
--- a/src/clients/cave/cmd_resolve_dump.cc
+++ b/src/clients/cave/cmd_resolve_dump.cc
@@ -22,15 +22,239 @@
#include <paludis/resolver/qpn_s.hh>
#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/destinations.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/arrow.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <iostream>
+#include <sstream>
using namespace paludis;
using namespace cave;
using namespace paludis::resolver;
+namespace
+{
+ std::ostream &
+ operator<< (std::ostream & s, const Decision & d)
+ {
+ std::stringstream ss;
+
+ ss << "Decision(";
+
+ if (d.if_package_id())
+ ss << *d.if_package_id();
+ else
+ ss << "(nothing)";
+
+ if (d.is_best())
+ ss << ", is best";
+ if (d.is_installed())
+ ss << ", is installed";
+ if (d.is_nothing())
+ ss << ", is nothing";
+ if (d.is_same())
+ ss << ", is same";
+ if (d.is_same_version())
+ ss << ", is same version";
+
+ ss << ")";
+
+ s << ss.str();
+ return s;
+ }
+
+ std::ostream &
+ operator<< (std::ostream & s, const Destination & d)
+ {
+ std::stringstream ss;
+ ss << "Destination(" << d.repository();
+ if (! d.replacing()->empty())
+ ss << " replacing " << join(indirect_iterator(d.replacing()->begin()),
+ indirect_iterator(d.replacing()->end()), ", ");
+ ss << ")";
+
+ s << ss.str();
+ return s;
+ }
+
+ std::ostream &
+ operator<< (std::ostream & s, const Destinations & d)
+ {
+ std::stringstream ss;
+ ss << "Destinations(";
+ if (d.slash())
+ ss << "slash: " << *d.slash();
+ ss << ")";
+
+ s << ss.str();
+ return s;
+ }
+
+ std::ostream &
+ operator<< (std::ostream & s, const SanitisedDependency & d)
+ {
+ std::stringstream ss;
+ ss << "Dep(" << d.spec();
+
+ if (! d.active_dependency_labels()->system_labels()->empty())
+ ss << " system { " << join(indirect_iterator(d.active_dependency_labels()->system_labels()->begin()),
+ indirect_iterator(d.active_dependency_labels()->system_labels()->end()), ", ") << " }";
+ if (! d.active_dependency_labels()->type_labels()->empty())
+ ss << " type { " << join(indirect_iterator(d.active_dependency_labels()->type_labels()->begin()),
+ indirect_iterator(d.active_dependency_labels()->type_labels()->end()), ", ") << " }";
+ if (! d.active_dependency_labels()->abi_labels()->empty())
+ ss << " abi { " << join(indirect_iterator(d.active_dependency_labels()->abi_labels()->begin()),
+ indirect_iterator(d.active_dependency_labels()->abi_labels()->end()), ", ") << " }";
+ if (! d.active_dependency_labels()->suggest_labels()->empty())
+ ss << " suggest { " << join(indirect_iterator(d.active_dependency_labels()->suggest_labels()->begin()),
+ indirect_iterator(d.active_dependency_labels()->suggest_labels()->end()), ", ") << " }";
+
+ ss << ")";
+
+ s << ss.str();
+ return s;
+ }
+
+ struct ReasonFinder
+ {
+ std::string str;
+
+ ReasonFinder() :
+ str("none")
+ {
+ }
+
+ void visit(const TargetReason &)
+ {
+ str = "Target";
+ }
+
+ void visit(const PresetReason &)
+ {
+ str = "Preset";
+ }
+
+ void visit(const SetReason & r)
+ {
+ ReasonFinder f;
+ if (r.reason_for_set())
+ r.reason_for_set()->accept(f);
+ str = "Set(" + stringify(r.set_name()) + " " + f.str + ")";
+ }
+
+ void visit(const DependencyReason & r)
+ {
+ std::stringstream s;
+ s << r.sanitised_dependency();
+ str = "Dependency(" + s.str() + ")";
+ }
+ };
+
+ std::ostream &
+ operator<< (std::ostream & s, const Constraint & c)
+ {
+ std::stringstream ss;
+ ss << "Constraint(spec: " << c.spec();
+ if (c.nothing_is_fine_too())
+ ss << "; nothing is fine too";
+ ss
+ << "; use_installed: " << stringify(c.use_installed())
+ << "; reason: ";
+
+ ReasonFinder r;
+ if (c.reason())
+ c.reason()->accept(r);
+ ss
+ << r.str << ")";
+ s << ss.str();
+
+ return s;
+ }
+
+ std::ostream &
+ operator<< (std::ostream & s, const Arrow & a)
+ {
+ s << "Arrow(-> " << a.to_qpn_s();
+ if (0 != a.ignorable_pass())
+ s << ", ignorable pass " << a.ignorable_pass();
+ s << ")";
+ return s;
+ }
+
+ std::string stringify_constraint(const Constraint & c)
+ {
+ std::stringstream s;
+ s << c;
+ return s.str();
+ }
+
+ std::string stringify_arrow(const Arrow & a)
+ {
+ std::stringstream s;
+ s << a;
+ return s.str();
+ }
+
+ std::ostream &
+ operator<< (std::ostream & s, const Resolution & r)
+ {
+ std::stringstream ss;
+ ss << "Resolution("
+ << "constraints: " << join(indirect_iterator(r.constraints()->begin()),
+ indirect_iterator(r.constraints()->end()), ", ", stringify_constraint)
+ << "; decision: ";
+ if (r.decision())
+ ss << *r.decision();
+ else
+ ss << "none";
+ ss
+ << "; arrows: " << join(indirect_iterator(r.arrows()->begin()),
+ indirect_iterator(r.arrows()->end()), ", ", stringify_arrow)
+ << "; already_ordered: " << stringify(r.already_ordered()) << ")"
+ << "; destinations: ";
+ if (r.destinations())
+ ss << *r.destinations();
+ else
+ ss << "unknown";
+ ss
+ << ")";
+ s << ss.str();
+ return s;
+ }
+
+ void dump(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<Resolver> & resolver,
+ const ResolveCommandLine & cmdline)
+ {
+ std::cout << "Dumping resolutions by QPN:S:" << std::endl << std::endl;
+
+ for (Resolver::ResolutionsByQPN_SConstIterator c(resolver->begin_resolutions_by_qpn_s()),
+ c_end(resolver->end_resolutions_by_qpn_s()) ;
+ c != c_end ; ++c)
+ {
+ std::cout << c->first << std::endl;
+ std::cout << " = " << *c->second << std::endl;
+ if (cmdline.resolution_options.a_dump_dependencies.specified() && c->second->sanitised_dependencies())
+ for (SanitisedDependencies::ConstIterator d(c->second->sanitised_dependencies()->begin()),
+ d_end(c->second->sanitised_dependencies()->end()) ;
+ d != d_end ; ++d)
+ std::cout << " -> " << *d << std::endl;
+ }
+
+ std::cout << std::endl;
+ }
+}
+
void
paludis::cave::dump_if_requested(
- const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<Resolver> & resolver,
const ResolveCommandLine & cmdline)
{
@@ -39,21 +263,6 @@ paludis::cave::dump_if_requested(
if (! cmdline.resolution_options.a_dump.specified())
return;
- std::cout << "Dumping resolutions by QPN:S:" << std::endl << std::endl;
-
- for (Resolver::ResolutionsByQPN_SConstIterator c(resolver->begin_resolutions_by_qpn_s()),
- c_end(resolver->end_resolutions_by_qpn_s()) ;
- c != c_end ; ++c)
- {
- std::cout << c->first << std::endl;
- std::cout << " = " << *c->second << std::endl;
- if (cmdline.resolution_options.a_dump_dependencies.specified() && c->second->sanitised_dependencies())
- for (SanitisedDependencies::ConstIterator d(c->second->sanitised_dependencies()->begin()),
- d_end(c->second->sanitised_dependencies()->end()) ;
- d != d_end ; ++d)
- std::cout << " -> " << *d << std::endl;
- }
-
- std::cout << std::endl;
+ dump(env, resolver, cmdline);
}