aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-08 10:50:24 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-08 10:50:24 +0000
commit1d29ccaf6eb8bb3d5b0fdb56fc8a7ec07db4edb0 (patch)
treea97671deddb17bad3a4891c387ebbed1b300ab68
parentd7d4c24743eb7ff29e357ebb8686e5b019dd23c9 (diff)
downloadpaludis-1d29ccaf6eb8bb3d5b0fdb56fc8a7ec07db4edb0.tar.gz
paludis-1d29ccaf6eb8bb3d5b0fdb56fc8a7ec07db4edb0.tar.xz
Track why we're dependent
-rw-r--r--paludis/resolver/decider.cc88
-rw-r--r--paludis/resolver/decider.hh2
2 files changed, 49 insertions, 41 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 6421858..84652b0 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -162,7 +162,9 @@ Decider::_resolve_dependents()
if (_allowed_to_break(*s))
continue;
- if (! _dependent(*s, changing.first, changing.second))
+ const std::tr1::shared_ptr<const PackageIDSequence> dependent_upon(_dependent_upon(
+ *s, changing.first, changing.second));
+ if (dependent_upon->empty())
continue;
if (_remove_if_dependent(*s))
@@ -219,6 +221,7 @@ namespace
const Environment * const env;
const std::tr1::shared_ptr<const PackageIDSequence> going_away;
const std::tr1::shared_ptr<const PackageIDSequence> newly_available;
+ const std::tr1::shared_ptr<PackageIDSequence> result;
DependentChecker(
const Environment * const e,
@@ -226,79 +229,84 @@ namespace
const std::tr1::shared_ptr<const PackageIDSequence> & n) :
env(e),
going_away(g),
- newly_available(n)
+ newly_available(n),
+ result(new PackageIDSequence)
{
}
- bool visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & s)
+ void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & s)
{
const std::tr1::shared_ptr<const SetSpecTree> set(env->set(s.spec()->name()));
- return set->root()->accept_returning<bool>(*this);
+ set->root()->accept(*this);
}
- bool visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & s)
+ void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & s)
{
- return
- (indirect_iterator(going_away->end()) != std::find_if(
- indirect_iterator(going_away->begin()), indirect_iterator(going_away->end()),
- std::tr1::bind(&match_package, std::tr1::cref(*env), std::tr1::cref(*s.spec()),
- std::tr1::placeholders::_1, MatchPackageOptions()))) &&
- (indirect_iterator(newly_available->end()) == std::find_if(
- indirect_iterator(newly_available->begin()), indirect_iterator(newly_available->end()),
- std::tr1::bind(&match_package, std::tr1::cref(*env), std::tr1::cref(*s.spec()),
- std::tr1::placeholders::_1, MatchPackageOptions())));
+ for (PackageIDSequence::ConstIterator g(going_away->begin()), g_end(going_away->end()) ;
+ g != g_end ; ++g)
+ {
+ if (! match_package(*env, *s.spec(), **g, MatchPackageOptions()))
+ continue;
+
+ if (indirect_iterator(newly_available->end()) == std::find_if(
+ indirect_iterator(newly_available->begin()), indirect_iterator(newly_available->end()),
+ std::tr1::bind(&match_package, std::tr1::cref(*env), std::tr1::cref(*s.spec()),
+ std::tr1::placeholders::_1, MatchPackageOptions())))
+ result->push_back(*g);
+ }
}
- bool visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &)
+ void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &)
{
- return false;
}
- bool visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & s)
+ void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & s)
{
if (s.spec()->condition_met())
- return indirect_iterator(s.end()) != std::find_if(
- indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor_returning<bool>(*this));
- return false;
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
+ accept_visitor(*this));
}
- bool visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & s)
+ void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & s)
{
- return indirect_iterator(s.end()) != std::find_if(
- indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor_returning<bool>(*this));
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
+ accept_visitor(*this));
}
- bool visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & s)
+ void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & s)
{
- return indirect_iterator(s.end()) != std::find_if(
- indirect_iterator(s.begin()), indirect_iterator(s.end()),
- accept_visitor_returning<bool>(*this));
+ std::for_each(indirect_iterator(s.begin()), indirect_iterator(s.end()),
+ accept_visitor(*this));
}
- bool visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &)
+ void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &)
{
- return false;
}
};
}
-bool
-Decider::_dependent(
+const std::tr1::shared_ptr<const PackageIDSequence>
+Decider::_dependent_upon(
const std::tr1::shared_ptr<const PackageID> & id,
const std::tr1::shared_ptr<const PackageIDSequence> & going_away,
const std::tr1::shared_ptr<const PackageIDSequence> & staying) const
{
- DependentChecker c(_imp->env, going_away, staying);;
+ DependentChecker c(_imp->env, going_away, staying);
if (id->dependencies_key())
- return id->dependencies_key()->value()->root()->accept_returning<bool>(c);
+ id->dependencies_key()->value()->root()->accept(c);
else
- return
- (id->build_dependencies_key() && id->build_dependencies_key()->value()->root()->accept_returning<bool>(c)) ||
- (id->run_dependencies_key() && id->run_dependencies_key()->value()->root()->accept_returning<bool>(c)) ||
- (id->post_dependencies_key() && id->post_dependencies_key()->value()->root()->accept_returning<bool>(c)) ||
- (id->suggested_dependencies_key() && id->suggested_dependencies_key()->value()->root()->accept_returning<bool>(c));
+ {
+ if (id->build_dependencies_key())
+ id->build_dependencies_key()->value()->root()->accept(c);
+ if (id->run_dependencies_key())
+ id->run_dependencies_key()->value()->root()->accept(c);
+ if (id->post_dependencies_key())
+ id->post_dependencies_key()->value()->root()->accept(c);
+ if (id->suggested_dependencies_key())
+ id->suggested_dependencies_key()->value()->root()->accept(c);
+ }
+
+ return c.result;
}
namespace
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 9e6918a..f844d7b 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -205,7 +205,7 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSequence> _collect_staying(
const std::tr1::shared_ptr<const PackageIDSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool _dependent(
+ const std::tr1::shared_ptr<const PackageIDSequence> _dependent_upon(
const std::tr1::shared_ptr<const PackageID> &,
const std::tr1::shared_ptr<const PackageIDSequence> &,
const std::tr1::shared_ptr<const PackageIDSequence> &) const PALUDIS_ATTRIBUTE((warn_unused_result));