aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-22 15:39:21 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-22 15:39:21 +0100
commit269e7b76d8405035de7721b72b9b4e717f2ca1ac (patch)
tree00fbed2d42b5608ea0754be7afe4eac21bd7ad50
parent40845fb53a27153b35f8be419050d04b51f1c24b (diff)
downloadpaludis-269e7b76d8405035de7721b72b9b4e717f2ca1ac.tar.gz
paludis-269e7b76d8405035de7721b72b9b4e717f2ca1ac.tar.xz
WasUsedByReason
-rw-r--r--paludis/resolver/constraint.cc5
-rw-r--r--paludis/resolver/orderer.cc4
-rw-r--r--paludis/resolver/reason-fwd.hh1
-rw-r--r--paludis/resolver/reason.cc47
-rw-r--r--paludis/resolver/reason.hh17
-rw-r--r--src/clients/cave/cmd_display_resolution.cc6
-rw-r--r--src/clients/cave/cmd_resolve_dump.cc6
-rw-r--r--src/clients/cave/resolve_common.cc26
8 files changed, 111 insertions, 1 deletions
diff --git a/paludis/resolver/constraint.cc b/paludis/resolver/constraint.cc
index cb47b9f..055cddd 100644
--- a/paludis/resolver/constraint.cc
+++ b/paludis/resolver/constraint.cc
@@ -173,6 +173,11 @@ namespace
{
return make_null_shared_ptr();
}
+
+ const std::tr1::shared_ptr<const PackageID> visit(const WasUsedByReason &) const
+ {
+ return make_null_shared_ptr();
+ }
};
}
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 861b22a..0c0c518 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -310,6 +310,10 @@ namespace
void visit(const TargetReason &)
{
}
+
+ void visit(const WasUsedByReason &)
+ {
+ }
};
bool no_build_dependencies(
diff --git a/paludis/resolver/reason-fwd.hh b/paludis/resolver/reason-fwd.hh
index 4fa50d7..4b64a74 100644
--- a/paludis/resolver/reason-fwd.hh
+++ b/paludis/resolver/reason-fwd.hh
@@ -32,6 +32,7 @@ namespace paludis
struct PresetReason;
struct SetReason;
struct DependentReason;
+ struct WasUsedByReason;
}
}
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index 8902404..3969bf5 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -146,6 +146,43 @@ DependentReason::serialise(Serialiser & s) const
namespace paludis
{
template <>
+ struct Implementation<WasUsedByReason>
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> ids_being_removed;
+
+ Implementation(const std::tr1::shared_ptr<const PackageIDSequence> & i) :
+ ids_being_removed(i)
+ {
+ }
+ };
+}
+
+WasUsedByReason::WasUsedByReason(const std::tr1::shared_ptr<const PackageIDSequence> & i) :
+ PrivateImplementationPattern<WasUsedByReason>(new Implementation<WasUsedByReason>(i))
+{
+}
+
+WasUsedByReason::~WasUsedByReason()
+{
+}
+
+const std::tr1::shared_ptr<const PackageIDSequence>
+WasUsedByReason::ids_being_removed() const
+{
+ return _imp->ids_being_removed;
+}
+
+void
+WasUsedByReason::serialise(Serialiser & s) const
+{
+ s.object("WasUsedByReason")
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "ids_being_removed", ids_being_removed())
+ ;
+}
+
+namespace paludis
+{
+ template <>
struct Implementation<PresetReason>
{
const std::string explanation;
@@ -276,6 +313,15 @@ Reason::deserialise(Deserialisation & d)
const std::tr1::shared_ptr<const PackageID> id_being_removed(v.member<std::tr1::shared_ptr<const PackageID> >("id_being_removed"));
return make_shared_ptr(new DependentReason(id_being_removed));
}
+ else if (d.class_name() == "WasUsedByReason")
+ {
+ Deserialisator v(d, "WasUsedByReason");
+ Deserialisator vv(*v.find_remove_member("ids_being_removed"), "c");
+ std::tr1::shared_ptr<PackageIDSequence> ids_being_removed(new PackageIDSequence);
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ ids_being_removed->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ return make_shared_ptr(new WasUsedByReason(ids_being_removed));
+ }
else
throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
}
@@ -284,4 +330,5 @@ template class PrivateImplementationPattern<DependencyReason>;
template class PrivateImplementationPattern<DependentReason>;
template class PrivateImplementationPattern<SetReason>;
template class PrivateImplementationPattern<PresetReason>;
+template class PrivateImplementationPattern<WasUsedByReason>;
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 8144e76..b7620d7 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -37,7 +37,7 @@ namespace paludis
{
class Reason :
public virtual DeclareAbstractAcceptMethods<Reason, MakeTypeList<
- TargetReason, DependencyReason, DependentReason, PresetReason, SetReason>::Type>
+ TargetReason, DependencyReason, DependentReason, WasUsedByReason, PresetReason, SetReason>::Type>
{
public:
virtual ~Reason() = 0;
@@ -92,6 +92,20 @@ namespace paludis
virtual void serialise(Serialiser &) const;
};
+ class WasUsedByReason :
+ private PrivateImplementationPattern<WasUsedByReason>,
+ public Reason,
+ public ImplementAcceptMethods<Reason, WasUsedByReason>
+ {
+ public:
+ WasUsedByReason(const std::tr1::shared_ptr<const PackageIDSequence> & ids);
+ ~WasUsedByReason();
+
+ const std::tr1::shared_ptr<const PackageIDSequence> ids_being_removed() const;
+
+ virtual void serialise(Serialiser &) const;
+ };
+
class PresetReason :
private PrivateImplementationPattern<PresetReason>,
public Reason,
@@ -129,6 +143,7 @@ namespace paludis
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
extern template class PrivateImplementationPattern<resolver::DependencyReason>;
extern template class PrivateImplementationPattern<resolver::DependentReason>;
+ extern template class PrivateImplementationPattern<resolver::WasUsedByReason>;
extern template class PrivateImplementationPattern<resolver::SetReason>;
#endif
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index f7ef2b5..63257ae 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -204,6 +204,12 @@ namespace
return std::make_pair("dependent upon " + stringify(*r.id_being_removed()), true);
}
+ std::pair<std::string, bool> visit(const WasUsedByReason & r) const
+ {
+ return std::make_pair("was used by " + join(indirect_iterator(r.ids_being_removed()->begin()),
+ indirect_iterator(r.ids_being_removed()->end()), ", "), true);
+ }
+
std::pair<std::string, bool> visit(const TargetReason &) const
{
return std::make_pair("target", true);
diff --git a/src/clients/cave/cmd_resolve_dump.cc b/src/clients/cave/cmd_resolve_dump.cc
index e914c03..9a697bc 100644
--- a/src/clients/cave/cmd_resolve_dump.cc
+++ b/src/clients/cave/cmd_resolve_dump.cc
@@ -164,6 +164,12 @@ namespace
str = "Dependent(" + stringify(*r.id_being_removed()) + ")";
}
+ void visit(const WasUsedByReason & r)
+ {
+ str = "WasUsedBy(" + join(indirect_iterator(r.ids_being_removed()->begin()),
+ indirect_iterator(r.ids_being_removed()->end()), ", ") + ")";
+ }
+
void visit(const DependencyReason & r)
{
std::stringstream s;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 166f3a2..093d0c2 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -290,6 +290,11 @@ namespace
return DestinationTypes() + dt_install_to_slash;
}
+ DestinationTypes visit(const WasUsedByReason &) const
+ {
+ return DestinationTypes() + dt_install_to_slash;
+ }
+
DestinationTypes visit(const DependencyReason &) const
{
return DestinationTypes() + dt_install_to_slash;
@@ -437,6 +442,11 @@ namespace
return ue_if_possible;
}
+ UseExisting visit(const WasUsedByReason &) const
+ {
+ return ue_if_possible;
+ }
+
UseExisting visit(const PresetReason &) const
{
return ue_if_possible;
@@ -637,6 +647,11 @@ namespace
return false;
}
+ bool visit(const WasUsedByReason &) const
+ {
+ return false;
+ }
+
bool visit(const PresetReason &) const
{
return false;
@@ -1010,6 +1025,11 @@ namespace
return false;
}
+ bool visit(const WasUsedByReason &) const
+ {
+ return true;
+ }
+
bool visit(const SetReason & r) const
{
return r.reason_for_set()->accept_returning<bool>(*this);
@@ -1445,6 +1465,12 @@ namespace
stringify(*r.sanitised_dependency().spec().if_package()) : stringify(*r.sanitised_dependency().spec().if_block()));
}
+ const std::string visit(const WasUsedByReason & r) const
+ {
+ return "from was used by " + join(indirect_iterator(r.ids_being_removed()->begin()),
+ indirect_iterator(r.ids_being_removed()->end()), ", ");
+ }
+
const std::string visit(const DependentReason & r) const
{
return "from dependent " + stringify(*r.id_being_removed());