aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2012-04-28 20:15:28 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2012-04-28 20:15:28 +0100
commit7b3ebc2fdcec58663aa07cc2451950d71a32f80e (patch)
treea786e9ffa04415a7321481a59f2f84cd5aebc749
parentd37e49b9dac955110cd9e2d5d7bd6beb0453a342 (diff)
downloadpaludis-7b3ebc2fdcec58663aa07cc2451950d71a32f80e.tar.gz
paludis-7b3ebc2fdcec58663aa07cc2451950d71a32f80e.tar.xz
Remember whether a job was for a target
-rw-r--r--paludis/resolver/job.cc66
-rw-r--r--paludis/resolver/job.hh17
-rw-r--r--paludis/resolver/orderer.cc25
3 files changed, 87 insertions, 21 deletions
diff --git a/paludis/resolver/job.cc b/paludis/resolver/job.cc
index 75a7ec3..211e728 100644
--- a/paludis/resolver/job.cc
+++ b/paludis/resolver/job.cc
@@ -124,12 +124,15 @@ namespace paludis
const std::shared_ptr<const JobRequirements> requirements;
const PackageDepSpec origin_id_spec;
std::shared_ptr<JobState> state;
+ const bool was_target;
Imp(
const std::shared_ptr<const JobRequirements> & r,
- const PackageDepSpec & o) :
+ const PackageDepSpec & o,
+ const bool t) :
requirements(r),
- origin_id_spec(o)
+ origin_id_spec(o),
+ was_target(t)
{
}
};
@@ -137,8 +140,9 @@ namespace paludis
FetchJob::FetchJob(
const std::shared_ptr<const JobRequirements> & r,
- const PackageDepSpec & o) :
- _imp(r, o)
+ const PackageDepSpec & o,
+ const bool t) :
+ _imp(r, o, t)
{
}
@@ -164,6 +168,12 @@ FetchJob::set_state(const std::shared_ptr<JobState> & s)
_imp->state = s;
}
+bool
+FetchJob::was_target() const
+{
+ return _imp->was_target;
+}
+
const std::shared_ptr<const JobRequirements>
FetchJob::requirements() const
{
@@ -185,7 +195,8 @@ FetchJob::deserialise(Deserialisation & d)
std::shared_ptr<FetchJob> result(std::make_shared<FetchJob>(
requirements,
parse_user_package_dep_spec(v.member<std::string>("origin_id_spec"),
- d.deserialiser().environment(), { updso_no_disambiguation })
+ d.deserialiser().environment(), { updso_no_disambiguation }),
+ v.member<bool>("was_target")
));
result->set_state(v.member<std::shared_ptr<JobState> >("state"));
return result;
@@ -198,6 +209,7 @@ FetchJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "requirements", requirements())
.member(SerialiserFlags<>(), "origin_id_spec", stringify(origin_id_spec()))
.member(SerialiserFlags<serialise::might_be_null>(), "state", state())
+ .member(SerialiserFlags<>(), "was_target", was_target())
;
}
@@ -211,6 +223,7 @@ namespace paludis
const RepositoryName destination_repository_name;
const DestinationType destination_type;
const std::shared_ptr<const Sequence<PackageDepSpec> > replacing_specs;
+ const bool was_target;
std::shared_ptr<JobState> state;
@@ -219,13 +232,15 @@ namespace paludis
const PackageDepSpec & o,
const RepositoryName & d,
const DestinationType t,
- const std::shared_ptr<const Sequence<PackageDepSpec> > & r
+ const std::shared_ptr<const Sequence<PackageDepSpec> > & r,
+ const bool w
) :
requirements(q),
origin_id_spec(o),
destination_repository_name(d),
destination_type(t),
- replacing_specs(r)
+ replacing_specs(r),
+ was_target(w)
{
}
};
@@ -236,9 +251,10 @@ InstallJob::InstallJob(
const PackageDepSpec & o,
const RepositoryName & d,
const DestinationType t,
- const std::shared_ptr<const Sequence<PackageDepSpec> > & r
+ const std::shared_ptr<const Sequence<PackageDepSpec> > & r,
+ const bool w
) :
- _imp(q, o, d, t, r)
+ _imp(q, o, d, t, r, w)
{
}
@@ -282,6 +298,12 @@ InstallJob::set_state(const std::shared_ptr<JobState> & s)
_imp->state = s;
}
+bool
+InstallJob::was_target() const
+{
+ return _imp->was_target;
+}
+
const std::shared_ptr<const JobRequirements>
InstallJob::requirements() const
{
@@ -314,7 +336,8 @@ InstallJob::deserialise(Deserialisation & d)
d.deserialiser().environment(), { updso_no_disambiguation }),
RepositoryName(v.member<std::string>("destination_repository_name")),
destringify<DestinationType>(v.member<std::string>("destination_type")),
- replacing_specs
+ replacing_specs,
+ v.member<bool>("was_target")
));
result->set_state(v.member<std::shared_ptr<JobState> >("state"));
@@ -337,6 +360,7 @@ InstallJob::serialise(Serialiser & s) const
.member(SerialiserFlags<>(), "destination_type", stringify(destination_type()))
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "replacing_specs", replacing_specs_s)
.member(SerialiserFlags<serialise::might_be_null>(), "state", state())
+ .member(SerialiserFlags<>(), "was_target", was_target())
;
}
@@ -347,15 +371,18 @@ namespace paludis
{
const std::shared_ptr<const JobRequirements> requirements;
const std::shared_ptr<const Sequence<PackageDepSpec> > ids_to_remove_specs;
+ const bool was_target;
std::shared_ptr<JobState> state;
Imp(
const std::shared_ptr<const JobRequirements> & q,
- const std::shared_ptr<const Sequence<PackageDepSpec> > & r
+ const std::shared_ptr<const Sequence<PackageDepSpec> > & r,
+ const bool t
) :
requirements(q),
- ids_to_remove_specs(r)
+ ids_to_remove_specs(r),
+ was_target(t)
{
}
};
@@ -363,9 +390,10 @@ namespace paludis
UninstallJob::UninstallJob(
const std::shared_ptr<const JobRequirements> & q,
- const std::shared_ptr<const Sequence<PackageDepSpec> > & r
+ const std::shared_ptr<const Sequence<PackageDepSpec> > & r,
+ const bool t
) :
- _imp(q, r)
+ _imp(q, r, t)
{
}
@@ -391,6 +419,12 @@ UninstallJob::set_state(const std::shared_ptr<JobState> & s)
_imp->state = s;
}
+bool
+UninstallJob::was_target() const
+{
+ return _imp->was_target;
+}
+
const std::shared_ptr<const JobRequirements>
UninstallJob::requirements() const
{
@@ -419,7 +453,8 @@ UninstallJob::deserialise(Deserialisation & d)
std::shared_ptr<UninstallJob> result(std::make_shared<UninstallJob>(
requirements,
- ids_to_remove_specs
+ ids_to_remove_specs,
+ v.member<bool>("was_target")
));
result->set_state(v.member<std::shared_ptr<JobState> >("state"));
@@ -439,6 +474,7 @@ UninstallJob::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "requirements", requirements())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "ids_to_remove_specs", ids_to_remove_specs_s)
.member(SerialiserFlags<serialise::might_be_null>(), "state", state())
+ .member(SerialiserFlags<>(), "was_target", was_target())
;
}
diff --git a/paludis/resolver/job.hh b/paludis/resolver/job.hh
index 02eba91..58a4974 100644
--- a/paludis/resolver/job.hh
+++ b/paludis/resolver/job.hh
@@ -67,6 +67,8 @@ namespace paludis
virtual const std::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
virtual void set_state(const std::shared_ptr<JobState> &) = 0;
+ virtual bool was_target() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
virtual const std::shared_ptr<const JobRequirements> requirements() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
static const std::shared_ptr<ExecuteJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -83,7 +85,8 @@ namespace paludis
public:
FetchJob(
const std::shared_ptr<const JobRequirements> &,
- const PackageDepSpec &
+ const PackageDepSpec &,
+ const bool was_target
);
~FetchJob();
@@ -92,6 +95,8 @@ namespace paludis
virtual const std::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_state(const std::shared_ptr<JobState> &);
+ virtual bool was_target() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual const std::shared_ptr<const JobRequirements> requirements() const PALUDIS_ATTRIBUTE((warn_unused_result));
static const std::shared_ptr<FetchJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -111,7 +116,8 @@ namespace paludis
const PackageDepSpec &,
const RepositoryName &,
const DestinationType,
- const std::shared_ptr<const Sequence<PackageDepSpec> > &);
+ const std::shared_ptr<const Sequence<PackageDepSpec> > &,
+ const bool was_target);
~InstallJob();
const PackageDepSpec origin_id_spec() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -122,6 +128,8 @@ namespace paludis
virtual const std::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_state(const std::shared_ptr<JobState> &);
+ virtual bool was_target() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual const std::shared_ptr<const JobRequirements> requirements() const PALUDIS_ATTRIBUTE((warn_unused_result));
static const std::shared_ptr<InstallJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -138,7 +146,8 @@ namespace paludis
public:
UninstallJob(
const std::shared_ptr<const JobRequirements> &,
- const std::shared_ptr<const Sequence<PackageDepSpec> > &
+ const std::shared_ptr<const Sequence<PackageDepSpec> > &,
+ const bool was_target
);
~UninstallJob();
@@ -147,6 +156,8 @@ namespace paludis
virtual const std::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_state(const std::shared_ptr<JobState> &);
+ virtual bool was_target() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual const std::shared_ptr<const JobRequirements> requirements() const PALUDIS_ATTRIBUTE((warn_unused_result));
static const std::shared_ptr<UninstallJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 58e4cc1..61ae3a1 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -838,6 +838,22 @@ namespace
return result;
}
+ bool was_target(
+ const std::shared_ptr<const Resolved> & r,
+ const Decision & d)
+ {
+ auto resolution(r->resolutions_by_resolvent()->find(d.resolvent()));
+ if (r->resolutions_by_resolvent()->end() == resolution)
+ throw InternalError(PALUDIS_HERE, "couldn't find " + stringify(d.resolvent()));
+
+ for (auto c((*resolution)->constraints()->begin()), c_end((*resolution)->constraints()->end()) ;
+ c != c_end ; ++c)
+ if (visitor_cast<const TargetReason>(*(*c)->reason()))
+ return true;
+
+ return false;
+ }
+
struct ExtraScheduler
{
const std::shared_ptr<const Resolved> resolved;
@@ -904,7 +920,8 @@ namespace
make_origin_spec(changes_to_make_decision),
changes_to_make_decision.destination()->repository(),
changes_to_make_decision.resolvent().destination_type(),
- replacing
+ replacing,
+ was_target(resolved, changes_to_make_decision)
)));
change_or_remove_job_numbers.insert(std::make_pair(index, install_job_n));
@@ -931,7 +948,8 @@ namespace
JobNumber fetch_job_n(resolved->job_lists()->execute_job_list()->append(std::make_shared<FetchJob>(
requirements,
- make_origin_spec(changes_to_make_decision))));
+ make_origin_spec(changes_to_make_decision),
+ was_target(resolved, changes_to_make_decision))));
fetch_job_numbers.insert(std::make_pair(index.resolvent(), fetch_job_n));
}
return;
@@ -968,7 +986,8 @@ namespace
JobNumber uninstall_job_n(resolved->job_lists()->execute_job_list()->append(std::make_shared<UninstallJob>(
requirements,
- removing
+ removing,
+ was_target(resolved, remove_decision)
)));
change_or_remove_job_numbers.insert(std::make_pair(index, uninstall_job_n));