aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-23 21:25:43 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-23 21:25:43 +0000
commit346b0c20b762921d940a5e020801627880bf9873 (patch)
tree16c0cdc25e921cf20a1591f989fba249d0918c62
parent99903f001a205491afa6cd2238f968cebf643059 (diff)
downloadpaludis-346b0c20b762921d940a5e020801627880bf9873.tar.gz
paludis-346b0c20b762921d940a5e020801627880bf9873.tar.xz
Don't need NoChangeJob
-rw-r--r--paludis/resolver/decider.cc19
-rw-r--r--paludis/resolver/decider.hh1
-rw-r--r--paludis/resolver/job-fwd.hh1
-rw-r--r--paludis/resolver/job.cc62
-rw-r--r--paludis/resolver/job.hh22
-rw-r--r--paludis/resolver/jobs.cc35
-rw-r--r--paludis/resolver/orderer.cc51
-rw-r--r--paludis/resolver/orderer.hh2
-rw-r--r--paludis/resolver/reason.cc21
-rw-r--r--paludis/resolver/reason.hh4
-rw-r--r--src/clients/cave/cmd_display_resolution.cc6
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc9
12 files changed, 59 insertions, 174 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 744af6b..778f335 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -685,7 +685,7 @@ Decider::_add_dependencies_if_necessary(
continue;
const std::tr1::shared_ptr<DependencyReason> reason(new DependencyReason(
- package_id, our_resolvent, *s));
+ package_id, our_resolvent, *s, _already_met(*s)));
std::tr1::shared_ptr<const Resolvents> resolvents;
@@ -827,7 +827,7 @@ Decider::find_any_score(const Resolvent & our_resolvent, const SanitisedDependen
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));
+ const std::tr1::shared_ptr<DependencyReason> reason(new DependencyReason(id, our_resolvent, dep, _already_met(dep)));
const std::tr1::shared_ptr<const Resolvents> resolvents(_get_resolvents_for(spec, reason));
/* next: will already be installing */
@@ -1318,3 +1318,18 @@ Decider::resolve()
_resolve_destinations();
}
+bool
+Decider::_already_met(const SanitisedDependency & dep) const
+{
+ const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*_imp->env)[selection::BestVersionOnly(
+ generator::Matches(dep.spec().if_package() ?
+ *dep.spec().if_package() :
+ dep.spec().if_block()->blocking(),
+ MatchPackageOptions()) |
+ filter::InstalledAtRoot(FSEntry("/")))]);
+ if (installed_ids->empty())
+ return dep.spec().if_block();
+ else
+ return dep.spec().if_package();
+}
+
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 617e810..dc66346 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -167,6 +167,7 @@ namespace paludis
const std::tr1::shared_ptr<const Resolution> &,
const std::tr1::shared_ptr<const PackageID> &) const;
+ bool _already_met(const SanitisedDependency &) const PALUDIS_ATTRIBUTE((warn_unused_result));
public:
Decider(const Environment * const,
diff --git a/paludis/resolver/job-fwd.hh b/paludis/resolver/job-fwd.hh
index 74f4b6e..0f88e1b 100644
--- a/paludis/resolver/job-fwd.hh
+++ b/paludis/resolver/job-fwd.hh
@@ -29,7 +29,6 @@ namespace paludis
struct SimpleInstallJob;
struct PretendJob;
struct FetchJob;
- struct NoChangeJob;
struct UsableJob;
struct SyncPointJob;
struct UntakenInstallJob;
diff --git a/paludis/resolver/job.cc b/paludis/resolver/job.cc
index 6dbe120..935843e 100644
--- a/paludis/resolver/job.cc
+++ b/paludis/resolver/job.cc
@@ -34,19 +34,6 @@ using namespace paludis::resolver;
namespace paludis
{
template <>
- struct Implementation<NoChangeJob>
- {
- const std::tr1::shared_ptr<const Resolution> resolution;
- const std::tr1::shared_ptr<ArrowSequence> arrows;
-
- Implementation(const std::tr1::shared_ptr<const Resolution> & r) :
- resolution(r),
- arrows(new ArrowSequence)
- {
- }
- };
-
- template <>
struct Implementation<UsableJob>
{
const std::tr1::shared_ptr<const Resolution> resolution;
@@ -155,15 +142,7 @@ Job::deserialise(Deserialisation & d)
{
std::tr1::shared_ptr<Job> result;
- if (d.class_name() == "NoChangeJob")
- {
- Deserialisator v(d, "NoChangeJob");
- result.reset(new NoChangeJob(
- v.member<std::tr1::shared_ptr<Resolution> >("resolution")
- ));
- do_arrows(result, v);
- }
- else if (d.class_name() == "UsableJob")
+ if (d.class_name() == "UsableJob")
{
Deserialisator v(d, "UsableJob");
result.reset(new UsableJob(
@@ -220,44 +199,6 @@ Job::deserialise(Deserialisation & d)
return result;
}
-NoChangeJob::NoChangeJob(const std::tr1::shared_ptr<const Resolution> & r) :
- PrivateImplementationPattern<NoChangeJob>(new Implementation<NoChangeJob>(r))
-{
-}
-
-NoChangeJob::~NoChangeJob()
-{
-}
-
-const std::tr1::shared_ptr<const Resolution>
-NoChangeJob::resolution() const
-{
- return _imp->resolution;
-}
-
-const std::tr1::shared_ptr<ArrowSequence>
-NoChangeJob::arrows() const
-{
- return _imp->arrows;
-}
-
-const JobID
-NoChangeJob::id() const
-{
- return make_named_values<JobID>(
- value_for<n::string_id>("n:" + stringify(resolution()->resolvent()))
- );
-}
-
-void
-NoChangeJob::serialise(Serialiser & s) const
-{
- s.object("NoChangeJob")
- .member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "arrows", arrows())
- .member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
- ;
-}
-
UsableJob::UsableJob(const std::tr1::shared_ptr<const Resolution> & r) :
PrivateImplementationPattern<UsableJob>(new Implementation<UsableJob>(r))
{
@@ -510,7 +451,6 @@ SyncPointJob::serialise(Serialiser & s) const
;
}
-template class PrivateImplementationPattern<resolver::NoChangeJob>;
template class PrivateImplementationPattern<resolver::UsableJob>;
template class PrivateImplementationPattern<resolver::PretendJob>;
template class PrivateImplementationPattern<resolver::FetchJob>;
diff --git a/paludis/resolver/job.hh b/paludis/resolver/job.hh
index c1c8bf3..a007ef7 100644
--- a/paludis/resolver/job.hh
+++ b/paludis/resolver/job.hh
@@ -39,7 +39,7 @@ namespace paludis
{
class PALUDIS_VISIBLE Job :
public virtual DeclareAbstractAcceptMethods<Job, MakeTypeList<
- NoChangeJob, UsableJob, SimpleInstallJob, PretendJob, FetchJob, UntakenInstallJob, SyncPointJob>::Type>
+ UsableJob, SimpleInstallJob, PretendJob, FetchJob, UntakenInstallJob, SyncPointJob>::Type>
{
public:
virtual ~Job() = 0;
@@ -56,25 +56,6 @@ namespace paludis
Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
};
- class PALUDIS_VISIBLE NoChangeJob :
- public Job,
- public ImplementAcceptMethods<Job, NoChangeJob>,
- private PrivateImplementationPattern<NoChangeJob>
- {
- public:
- NoChangeJob(const std::tr1::shared_ptr<const Resolution> &);
- ~NoChangeJob();
-
- virtual const JobID id() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual const std::tr1::shared_ptr<ArrowSequence> arrows()
- const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual void serialise(Serialiser &) const;
- };
-
class PALUDIS_VISIBLE UsableJob :
public Job,
public ImplementAcceptMethods<Job, UsableJob>,
@@ -200,7 +181,6 @@ namespace paludis
}
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
- extern template class PrivateImplementationPattern<resolver::NoChangeJob>;
extern template class PrivateImplementationPattern<resolver::UsableJob>;
extern template class PrivateImplementationPattern<resolver::PretendJob>;
extern template class PrivateImplementationPattern<resolver::FetchJob>;
diff --git a/paludis/resolver/jobs.cc b/paludis/resolver/jobs.cc
index 53ef32c..24396ab 100644
--- a/paludis/resolver/jobs.cc
+++ b/paludis/resolver/jobs.cc
@@ -67,11 +67,6 @@ namespace
{
}
- void visit(const NoChangeJob & j)
- {
- jobs_list_by_resolvent_index.insert(std::make_pair(j.resolution()->resolvent(), i));
- }
-
void visit(const UsableJob & j)
{
jobs_list_by_resolvent_index.insert(std::make_pair(j.resolution()->resolvent(), i));
@@ -135,11 +130,6 @@ namespace
return true;
}
- bool visit(const NoChangeJob &) const
- {
- return true;
- }
-
bool visit(const UsableJob &) const
{
return false;
@@ -173,11 +163,6 @@ namespace
return true;
}
- bool visit(const NoChangeJob &) const
- {
- return true;
- }
-
bool visit(const UsableJob &) const
{
return true;
@@ -202,26 +187,26 @@ Jobs::find_id_for_installed(const Resolvent & r) const
return (*candidates.first->second)->id();
}
- throw InternalError(PALUDIS_HERE, "no build job for " + stringify(r));
+ return find_id_for_usable(r);
}
-bool
-Jobs::have_job_for_installed(const Resolvent & r) const
+const JobID
+Jobs::find_id_for_usable(const Resolvent & r) const
{
std::pair<JobsListByResolventIndex::const_iterator, JobsListByResolventIndex::const_iterator> candidates(
_imp->jobs_list_by_resolvent_index.equal_range(r));
for ( ; candidates.first != candidates.second ; ++candidates.first)
{
- if ((*candidates.first->second)->accept_returning<bool>(InstalledJobChecker()))
- return true;
+ if ((*candidates.first->second)->accept_returning<bool>(UsableJobChecker()))
+ return (*candidates.first->second)->id();
}
- return false;
+ throw InternalError(PALUDIS_HERE, "no build job for " + stringify(r));
}
-const JobID
-Jobs::find_id_for_usable(const Resolvent & r) const
+bool
+Jobs::have_job_for_installed(const Resolvent & r) const
{
std::pair<JobsListByResolventIndex::const_iterator, JobsListByResolventIndex::const_iterator> candidates(
_imp->jobs_list_by_resolvent_index.equal_range(r));
@@ -229,10 +214,10 @@ Jobs::find_id_for_usable(const Resolvent & r) const
for ( ; candidates.first != candidates.second ; ++candidates.first)
{
if ((*candidates.first->second)->accept_returning<bool>(UsableJobChecker()))
- return (*candidates.first->second)->id();
+ return true;
}
- throw InternalError(PALUDIS_HERE, "no build job for " + stringify(r));
+ return have_job_for_usable(r);
}
bool
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 84193f0..44b9a29 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -135,13 +135,13 @@ namespace
Log::get_instance()->message("resolver.orderer.job.nothing_no_change", ll_debug, lc_no_context)
<< "taken " << resolution->resolvent() << " nothing no change";
- const std::tr1::shared_ptr<NoChangeJob> no_change_job(new NoChangeJob(resolution));
- lists->jobs()->add(no_change_job);
- lists->unordered_job_ids()->push_back(no_change_job->id());
+ const std::tr1::shared_ptr<UsableJob> usable_job(new UsableJob(resolution));
+ lists->jobs()->add(usable_job);
+ lists->unordered_job_ids()->push_back(usable_job->id());
/* we want to do all of these as part of the main build process,
* not at pretend time */
- no_change_job->arrows()->push_back(make_named_values<Arrow>(
+ usable_job->arrows()->push_back(make_named_values<Arrow>(
value_for<n::comes_after>(common_jobs.done_pretends()->id()),
value_for<n::maybe_reason>(make_null_shared_ptr())
));
@@ -160,13 +160,13 @@ namespace
Log::get_instance()->message("resolver.orderer.job.existing_no_change", ll_debug, lc_no_context)
<< "taken " << resolution->resolvent() << " existing no change";
- const std::tr1::shared_ptr<NoChangeJob> no_change_job(new NoChangeJob(resolution));
- lists->jobs()->add(no_change_job);
- lists->unordered_job_ids()->push_back(no_change_job->id());
+ const std::tr1::shared_ptr<UsableJob> usable_job(new UsableJob(resolution));
+ lists->jobs()->add(usable_job);
+ lists->unordered_job_ids()->push_back(usable_job->id());
/* we want to do all of these as part of the main build process,
* not at pretend time */
- no_change_job->arrows()->push_back(make_named_values<Arrow>(
+ usable_job->arrows()->push_back(make_named_values<Arrow>(
value_for<n::comes_after>(common_jobs.done_pretends()->id()),
value_for<n::maybe_reason>(make_null_shared_ptr())
));
@@ -489,12 +489,6 @@ namespace
add_dep_arrows(false, c.resolution());
}
- void visit(const NoChangeJob & c)
- {
- /* a dep b dep c, b not changing. we still want c before a. */
- add_dep_arrows(true, c.resolution());
- }
-
void visit(const UsableJob & c)
{
add_dep_arrows(true, c.resolution());
@@ -600,13 +594,6 @@ namespace
struct AlreadyMetDep
{
- const AlreadyMetFn already_met;
-
- AlreadyMetDep(const AlreadyMetFn & a) :
- already_met(a)
- {
- }
-
bool visit(const PresetReason &) const
{
return false;
@@ -624,17 +611,12 @@ namespace
bool visit(const DependencyReason & r) const
{
- return already_met(r.sanitised_dependency().spec());
+ return r.already_met();
}
};
struct Pass2Ignorable
{
- bool visit(const NoChangeJob &) const
- {
- return true;
- }
-
bool visit(const UsableJob &) const
{
return true;
@@ -693,8 +675,7 @@ Orderer::_can_order(const JobID & i, const int pass) const
{
/* we can also ignore any arrows that are already met (e.g a
* dep b, b dep a, a is already installed */
- if (a->maybe_reason() && a->maybe_reason()->accept_returning<bool>(
- AlreadyMetDep(std::tr1::bind(&Orderer::_already_met, this, std::tr1::placeholders::_1))))
+ if (a->maybe_reason() && a->maybe_reason()->accept_returning<bool>(AlreadyMetDep()))
skippable = true;
}
@@ -719,15 +700,3 @@ Orderer::_mark_already_ordered(const JobID & i)
throw InternalError(PALUDIS_HERE, "already already ordered");
}
-bool
-Orderer::_already_met(const PackageOrBlockDepSpec & spec) const
-{
- const std::tr1::shared_ptr<const PackageIDSequence> installed_ids((*_imp->env)[selection::BestVersionOnly(
- generator::Matches(spec.if_package() ? *spec.if_package() : spec.if_block()->blocking(), MatchPackageOptions()) |
- filter::InstalledAtRoot(FSEntry("/")))]);
- if (installed_ids->empty())
- return spec.if_block();
- else
- return spec.if_package();
-}
-
diff --git a/paludis/resolver/orderer.hh b/paludis/resolver/orderer.hh
index 045efe4..2c10677 100644
--- a/paludis/resolver/orderer.hh
+++ b/paludis/resolver/orderer.hh
@@ -52,8 +52,6 @@ namespace paludis
bool _can_order(const JobID &, const int pass) const PALUDIS_ATTRIBUTE((warn_unused_result));
void _mark_already_ordered(const JobID &);
- bool _already_met(const PackageOrBlockDepSpec &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
public:
Orderer(
const Environment * const,
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index eafef9c..67afeb8 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -46,12 +46,14 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> from_id;
const Resolvent from_resolvent;
const SanitisedDependency dep;
+ const bool already_met;
Implementation(const std::tr1::shared_ptr<const PackageID> & i,
- const Resolvent & r, const SanitisedDependency & d) :
+ const Resolvent & r, const SanitisedDependency & d, const bool a) :
from_id(i),
from_resolvent(r),
- dep(d)
+ dep(d),
+ already_met(a)
{
}
};
@@ -59,8 +61,9 @@ namespace paludis
DependencyReason::DependencyReason(const std::tr1::shared_ptr<const PackageID> & i,
const Resolvent & r,
- const SanitisedDependency & d) :
- PrivateImplementationPattern<DependencyReason>(new Implementation<DependencyReason>(i, r, d))
+ const SanitisedDependency & d,
+ const bool a) :
+ PrivateImplementationPattern<DependencyReason>(new Implementation<DependencyReason>(i, r, d, a))
{
}
@@ -86,10 +89,17 @@ DependencyReason::sanitised_dependency() const
return _imp->dep;
}
+bool
+DependencyReason::already_met() const
+{
+ return _imp->already_met;
+}
+
void
DependencyReason::serialise(Serialiser & s) const
{
s.object("DependencyReason")
+ .member(SerialiserFlags<>(), "already_met", already_met())
.member(SerialiserFlags<serialise::might_be_null>(), "from_id", from_id())
.member(SerialiserFlags<>(), "from_resolvent", from_resolvent())
.member(SerialiserFlags<>(), "sanitised_dependency", sanitised_dependency())
@@ -177,7 +187,8 @@ Reason::deserialise(Deserialisation & d)
return make_shared_ptr(new DependencyReason(
from_id,
v.member<Resolvent>("from_resolvent"),
- SanitisedDependency::deserialise(*v.find_remove_member("sanitised_dependency"), from_id))
+ SanitisedDependency::deserialise(*v.find_remove_member("sanitised_dependency"), from_id),
+ v.member<bool>("already_met"))
);
}
else
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 2fcda3c..247f32b 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -65,13 +65,15 @@ namespace paludis
DependencyReason(
const std::tr1::shared_ptr<const PackageID> & id,
const Resolvent &,
- const SanitisedDependency & s);
+ const SanitisedDependency & s,
+ const bool already_met);
~DependencyReason();
const std::tr1::shared_ptr<const PackageID> from_id() const;
const Resolvent from_resolvent() const;
const SanitisedDependency & sanitised_dependency() const;
+ bool already_met() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const;
};
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 623fb16..5467f34 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -380,12 +380,6 @@ namespace
}
const std::tr1::shared_ptr<const Resolution> visit(
- const NoChangeJob &) const
- {
- return make_null_shared_ptr();
- }
-
- const std::tr1::shared_ptr<const Resolution> visit(
const UsableJob &) const
{
return make_null_shared_ptr();
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 709a2d0..c5525bd 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -300,10 +300,6 @@ namespace
++y_fetches;
}
- void visit(const NoChangeJob &)
- {
- }
-
void visit(const UsableJob &)
{
}
@@ -441,11 +437,6 @@ namespace
return true;
}
- bool visit(const NoChangeJob &)
- {
- return true;
- }
-
bool visit(const UsableJob &)
{
return true;