aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-15 16:08:58 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-15 16:08:58 +0100
commit004b5620a3f60ccf1b6e97521d6b3004b27ab147 (patch)
tree6806448acc1e138bb41f6b54039d17c39d9ef183
parent63a53c38146bdf97c6f0d4b321732422b7565752 (diff)
downloadpaludis-004b5620a3f60ccf1b6e97521d6b3004b27ab147.tar.gz
paludis-004b5620a3f60ccf1b6e97521d6b3004b27ab147.tar.xz
Switch to work lists
-rw-r--r--paludis/resolver/Makefile.am10
-rw-r--r--paludis/resolver/lineariser.cc33
-rw-r--r--paludis/resolver/resolved.cc5
-rw-r--r--paludis/resolver/resolved.hh3
-rw-r--r--paludis/resolver/resolver.cc8
-rw-r--r--paludis/resolver/work_item-fwd.hh36
-rw-r--r--paludis/resolver/work_item.cc291
-rw-r--r--paludis/resolver/work_item.hh121
-rw-r--r--paludis/resolver/work_list-fwd.hh34
-rw-r--r--paludis/resolver/work_list.cc117
-rw-r--r--paludis/resolver/work_list.hh71
-rw-r--r--paludis/resolver/work_lists-fwd.hh31
-rw-r--r--paludis/resolver/work_lists.cc47
-rw-r--r--paludis/resolver/work_lists.hh51
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc779
-rw-r--r--src/clients/cave/cmd_execute_resolution.hh4
-rw-r--r--src/clients/cave/resolve_common.cc23
17 files changed, 980 insertions, 684 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index fdc431e..f543baa 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -58,7 +58,10 @@ noinst_HEADERS = \
decisions.hh decisions-fwd.hh \
lineariser.hh lineariser-fwd.hh \
nag.hh nag-fwd.hh \
- strongly_connected_component.hh strongly_connected_component-fwd.hh
+ strongly_connected_component.hh strongly_connected_component-fwd.hh \
+ work_item.hh work_item-fwd.hh \
+ work_list.hh work_list-fwd.hh \
+ work_lists.hh work_lists-fwd.hh
libpaludisresolver_a_SOURCES = \
any_child_score.cc \
@@ -94,7 +97,10 @@ libpaludisresolver_a_SOURCES = \
decisions.cc \
lineariser.cc \
nag.cc \
- strongly_connected_component.cc
+ strongly_connected_component.cc \
+ work_item.cc \
+ work_list.cc \
+ work_lists.cc
if ENABLE_VIRTUALS_REPOSITORY
virtuals_tests = resolver_TEST_virtuals
diff --git a/paludis/resolver/lineariser.cc b/paludis/resolver/lineariser.cc
index 67b4ea3..bed3413 100644
--- a/paludis/resolver/lineariser.cc
+++ b/paludis/resolver/lineariser.cc
@@ -26,12 +26,18 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/strongly_connected_component.hh>
#include <paludis/resolver/resolutions_by_resolvent.hh>
+#include <paludis/resolver/work_lists.hh>
+#include <paludis/resolver/work_list.hh>
+#include <paludis/resolver/work_item.hh>
+#include <paludis/resolver/destination.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/join.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/environment.hh>
#include <paludis/notifier_callback.hh>
#include <tr1/unordered_set>
@@ -467,5 +473,32 @@ Lineariser::schedule(const std::tr1::shared_ptr<const ChangeOrRemoveDecision> &
_imp->resolved->taken_change_or_remove_decisions()->push_back(d);
if (d->required_confirmations_if_any())
_imp->resolved->taken_unconfirmed_change_or_remove_decisions()->push_back(d);
+
+ const ChangesToMakeDecision * const changes_to_make_decision(simple_visitor_cast<const ChangesToMakeDecision>(*d));
+ const RemoveDecision * const remove_decision(simple_visitor_cast<const RemoveDecision>(*d));
+
+ if (changes_to_make_decision)
+ {
+ _imp->resolved->work_lists()->pretend_work_list()->append(make_shared_ptr(new PretendWorkItem(
+ changes_to_make_decision->origin_id())));
+
+ _imp->resolved->work_lists()->execute_work_list()->append(make_shared_ptr(new FetchWorkItem(
+ changes_to_make_decision->origin_id())));
+
+ _imp->resolved->work_lists()->execute_work_list()->append(make_shared_ptr(new InstallWorkItem(
+ changes_to_make_decision->origin_id(),
+ changes_to_make_decision->destination()->repository(),
+ changes_to_make_decision->resolvent().destination_type(),
+ changes_to_make_decision->destination()->replacing()
+ )));
+ }
+ else if (remove_decision)
+ {
+ _imp->resolved->work_lists()->execute_work_list()->append(make_shared_ptr(new UninstallWorkItem(
+ remove_decision->ids()
+ )));
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "huh?");
}
diff --git a/paludis/resolver/resolved.cc b/paludis/resolver/resolved.cc
index ef389c0..ff09e5e 100644
--- a/paludis/resolver/resolved.cc
+++ b/paludis/resolver/resolved.cc
@@ -21,6 +21,7 @@
#include <paludis/resolver/decisions.hh>
#include <paludis/resolver/decision.hh>
#include <paludis/resolver/resolutions_by_resolvent.hh>
+#include <paludis/resolver/work_lists.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/serialise-impl.hh>
@@ -37,6 +38,7 @@ Resolved::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "taken_unconfirmed_change_or_remove_decisions", taken_unconfirmed_change_or_remove_decisions())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "untaken_change_or_remove_decisions", untaken_change_or_remove_decisions())
.member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "untaken_unable_to_make_decisions", untaken_unable_to_make_decisions())
+ .member(SerialiserFlags<serialise::might_be_null>(), "work_lists", work_lists())
;
}
@@ -86,7 +88,8 @@ Resolved::deserialise(Deserialisation & d)
n::taken_unable_to_make_decisions() = taken_unable_to_make_decisions,
n::taken_unconfirmed_change_or_remove_decisions() = taken_unconfirmed_change_or_remove_decisions,
n::untaken_change_or_remove_decisions() = untaken_change_or_remove_decisions,
- n::untaken_unable_to_make_decisions() = untaken_unable_to_make_decisions
+ n::untaken_unable_to_make_decisions() = untaken_unable_to_make_decisions,
+ n::work_lists() = v.member<std::tr1::shared_ptr<WorkLists> >("work_lists")
);
}
diff --git a/paludis/resolver/resolved.hh b/paludis/resolver/resolved.hh
index 757063d..fb90e88 100644
--- a/paludis/resolver/resolved.hh
+++ b/paludis/resolver/resolved.hh
@@ -24,6 +24,7 @@
#include <paludis/resolver/decisions-fwd.hh>
#include <paludis/resolver/resolutions_by_resolvent-fwd.hh>
#include <paludis/resolver/decision-fwd.hh>
+#include <paludis/resolver/work_lists-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/serialise-fwd.hh>
#include <tr1/memory>
@@ -38,6 +39,7 @@ namespace paludis
typedef Name<struct taken_unconfirmed_change_or_remove_decisions_name> taken_unconfirmed_change_or_remove_decisions;
typedef Name<struct untaken_change_or_remove_decisions_name> untaken_change_or_remove_decisions;
typedef Name<struct untaken_unable_to_make_decisions_name> untaken_unable_to_make_decisions;
+ typedef Name<struct work_lists_name> work_lists;
}
namespace resolver
@@ -50,6 +52,7 @@ namespace paludis
NamedValue<n::taken_unconfirmed_change_or_remove_decisions, std::tr1::shared_ptr<Decisions<ChangeOrRemoveDecision> > > taken_unconfirmed_change_or_remove_decisions;
NamedValue<n::untaken_change_or_remove_decisions, std::tr1::shared_ptr<Decisions<ChangeOrRemoveDecision> > > untaken_change_or_remove_decisions;
NamedValue<n::untaken_unable_to_make_decisions, std::tr1::shared_ptr<Decisions<UnableToMakeDecision> > > untaken_unable_to_make_decisions;
+ NamedValue<n::work_lists, std::tr1::shared_ptr<WorkLists> > work_lists;
static const Resolved deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
void serialise(Serialiser &) const;
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 386edf9..fd3b3e2 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -30,6 +30,8 @@
#include <paludis/resolver/orderer.hh>
#include <paludis/resolver/lineariser.hh>
#include <paludis/resolver/decisions.hh>
+#include <paludis/resolver/work_list.hh>
+#include <paludis/resolver/work_lists.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/sequence.hh>
@@ -81,7 +83,11 @@ namespace paludis
n::taken_unable_to_make_decisions() = make_shared_ptr(new Decisions<UnableToMakeDecision>),
n::taken_unconfirmed_change_or_remove_decisions() = make_shared_ptr(new Decisions<ChangeOrRemoveDecision>),
n::untaken_change_or_remove_decisions() = make_shared_ptr(new Decisions<ChangeOrRemoveDecision>),
- n::untaken_unable_to_make_decisions() = make_shared_ptr(new Decisions<UnableToMakeDecision>)
+ n::untaken_unable_to_make_decisions() = make_shared_ptr(new Decisions<UnableToMakeDecision>),
+ n::work_lists() = make_shared_copy(make_named_values<WorkLists>(
+ n::execute_work_list() = make_shared_ptr(new WorkList<ExecuteWorkItem>),
+ n::pretend_work_list() = make_shared_ptr(new WorkList<PretendWorkItem>)
+ ))
))),
decider(new Decider(e, f, resolved->resolutions_by_resolvent())),
orderer(new Orderer(e, f, decider, lists)),
diff --git a/paludis/resolver/work_item-fwd.hh b/paludis/resolver/work_item-fwd.hh
new file mode 100644
index 0000000..3725412
--- /dev/null
+++ b/paludis/resolver/work_item-fwd.hh
@@ -0,0 +1,36 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_ITEM_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_ITEM_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PretendWorkItem;
+
+ class ExecuteWorkItem;
+ class FetchWorkItem;
+ class InstallWorkItem;
+ class UninstallWorkItem;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/work_item.cc b/paludis/resolver/work_item.cc
new file mode 100644
index 0000000..67e20cc
--- /dev/null
+++ b/paludis/resolver/work_item.cc
@@ -0,0 +1,291 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/work_item.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/serialise-impl.hh>
+#include <paludis/package_id.hh>
+#include <paludis/name.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<PretendWorkItem>
+ {
+ const std::tr1::shared_ptr<const PackageID> origin_id;
+
+ Implementation(const std::tr1::shared_ptr<const PackageID> & o) :
+ origin_id(o)
+ {
+ }
+ };
+}
+
+PretendWorkItem::PretendWorkItem(const std::tr1::shared_ptr<const PackageID> & o) :
+ PrivateImplementationPattern<PretendWorkItem>(new Implementation<PretendWorkItem>(o))
+{
+}
+
+PretendWorkItem::~PretendWorkItem()
+{
+}
+
+const std::tr1::shared_ptr<const PackageID>
+PretendWorkItem::origin_id() const
+{
+ return _imp->origin_id;
+}
+
+const std::tr1::shared_ptr<PretendWorkItem>
+PretendWorkItem::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "PretendWorkItem");
+ return make_shared_ptr(new PretendWorkItem(
+ v.member<std::tr1::shared_ptr<const PackageID> >("origin_id")
+ ));
+}
+
+void
+PretendWorkItem::serialise(Serialiser & s) const
+{
+ s.object("PretendWorkItem")
+ .member(SerialiserFlags<serialise::might_be_null>(), "origin_id", origin_id())
+ ;
+}
+
+ExecuteWorkItem::~ExecuteWorkItem()
+{
+}
+
+const std::tr1::shared_ptr<ExecuteWorkItem>
+ExecuteWorkItem::deserialise(Deserialisation & d)
+{
+ if (d.class_name() == "FetchWorkItem")
+ return FetchWorkItem::deserialise(d);
+ else if (d.class_name() == "InstallWorkItem")
+ return InstallWorkItem::deserialise(d);
+ else if (d.class_name() == "UninstallWorkItem")
+ return UninstallWorkItem::deserialise(d);
+ else
+ throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<FetchWorkItem>
+ {
+ const std::tr1::shared_ptr<const PackageID> origin_id;
+
+ Implementation(const std::tr1::shared_ptr<const PackageID> & o) :
+ origin_id(o)
+ {
+ }
+ };
+}
+
+FetchWorkItem::FetchWorkItem(const std::tr1::shared_ptr<const PackageID> & o) :
+ PrivateImplementationPattern<FetchWorkItem>(new Implementation<FetchWorkItem>(o))
+{
+}
+
+FetchWorkItem::~FetchWorkItem()
+{
+}
+
+const std::tr1::shared_ptr<const PackageID>
+FetchWorkItem::origin_id() const
+{
+ return _imp->origin_id;
+}
+
+const std::tr1::shared_ptr<FetchWorkItem>
+FetchWorkItem::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "FetchWorkItem");
+ return make_shared_ptr(new FetchWorkItem(
+ v.member<std::tr1::shared_ptr<const PackageID> >("origin_id")
+ ));
+}
+
+void
+FetchWorkItem::serialise(Serialiser & s) const
+{
+ s.object("FetchWorkItem")
+ .member(SerialiserFlags<serialise::might_be_null>(), "origin_id", origin_id())
+ ;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<InstallWorkItem>
+ {
+ const std::tr1::shared_ptr<const PackageID> origin_id;
+ const RepositoryName destination_repository_name;
+ const DestinationType destination_type;
+ const std::tr1::shared_ptr<const PackageIDSequence> replacing;
+
+ Implementation(
+ const std::tr1::shared_ptr<const PackageID> & o,
+ const RepositoryName & d,
+ const DestinationType t,
+ const std::tr1::shared_ptr<const PackageIDSequence> & r
+ ) :
+ origin_id(o),
+ destination_repository_name(d),
+ destination_type(t),
+ replacing(r)
+ {
+ }
+ };
+}
+
+InstallWorkItem::InstallWorkItem(
+ const std::tr1::shared_ptr<const PackageID> & o,
+ const RepositoryName & d,
+ const DestinationType t,
+ const std::tr1::shared_ptr<const PackageIDSequence> & r
+ ) :
+ PrivateImplementationPattern<InstallWorkItem>(new Implementation<InstallWorkItem>(o, d, t, r))
+{
+}
+
+InstallWorkItem::~InstallWorkItem()
+{
+}
+
+const std::tr1::shared_ptr<const PackageID>
+InstallWorkItem::origin_id() const
+{
+ return _imp->origin_id;
+}
+
+const RepositoryName
+InstallWorkItem::destination_repository_name() const
+{
+ return _imp->destination_repository_name;
+}
+
+DestinationType
+InstallWorkItem::destination_type() const
+{
+ return _imp->destination_type;
+}
+
+const std::tr1::shared_ptr<const PackageIDSequence>
+InstallWorkItem::replacing() const
+{
+ return _imp->replacing;
+}
+
+const std::tr1::shared_ptr<InstallWorkItem>
+InstallWorkItem::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "InstallWorkItem");
+
+ std::tr1::shared_ptr<PackageIDSequence> replacing(new PackageIDSequence);
+ {
+ Deserialisator vv(*v.find_remove_member("replacing"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ replacing->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ }
+
+ return make_shared_ptr(new InstallWorkItem(
+ v.member<std::tr1::shared_ptr<const PackageID> >("origin_id"),
+ RepositoryName(v.member<std::string>("destination_repository_name")),
+ destringify<DestinationType>(v.member<std::string>("destination_type")),
+ replacing
+ ));
+}
+
+void
+InstallWorkItem::serialise(Serialiser & s) const
+{
+ s.object("InstallWorkItem")
+ .member(SerialiserFlags<serialise::might_be_null>(), "origin_id", origin_id())
+ .member(SerialiserFlags<>(), "destination_repository_name", stringify(destination_repository_name()))
+ .member(SerialiserFlags<>(), "destination_type", stringify(destination_type()))
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "replacing", replacing())
+ ;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<UninstallWorkItem>
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> ids_to_remove;
+
+ Implementation(
+ const std::tr1::shared_ptr<const PackageIDSequence> & r
+ ) :
+ ids_to_remove(r)
+ {
+ }
+ };
+}
+
+UninstallWorkItem::UninstallWorkItem(
+ const std::tr1::shared_ptr<const PackageIDSequence> & r
+ ) :
+ PrivateImplementationPattern<UninstallWorkItem>(new Implementation<UninstallWorkItem>(r))
+{
+}
+
+UninstallWorkItem::~UninstallWorkItem()
+{
+}
+
+const std::tr1::shared_ptr<const PackageIDSequence>
+UninstallWorkItem::ids_to_remove() const
+{
+ return _imp->ids_to_remove;
+}
+
+const std::tr1::shared_ptr<UninstallWorkItem>
+UninstallWorkItem::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "UninstallWorkItem");
+
+ std::tr1::shared_ptr<PackageIDSequence> ids_to_remove(new PackageIDSequence);
+ {
+ Deserialisator vv(*v.find_remove_member("ids_to_remove"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ ids_to_remove->push_back(vv.member<std::tr1::shared_ptr<const PackageID> >(stringify(n)));
+ }
+
+ return make_shared_ptr(new UninstallWorkItem(
+ ids_to_remove
+ ));
+}
+
+void
+UninstallWorkItem::serialise(Serialiser & s) const
+{
+ s.object("UninstallWorkItem")
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(), "ids_to_remove", ids_to_remove())
+ ;
+}
+
diff --git a/paludis/resolver/work_item.hh b/paludis/resolver/work_item.hh
new file mode 100644
index 0000000..80bd885
--- /dev/null
+++ b/paludis/resolver/work_item.hh
@@ -0,0 +1,121 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_ITEM_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_ITEM_HH 1
+
+#include <paludis/resolver/work_item-fwd.hh>
+#include <paludis/resolver/destination_types-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/simple_visitor.hh>
+#include <paludis/util/type_list.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/serialise-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE PretendWorkItem :
+ private PrivateImplementationPattern<PretendWorkItem>
+ {
+ public:
+ PretendWorkItem(
+ const std::tr1::shared_ptr<const PackageID> &
+ );
+ ~PretendWorkItem();
+
+ const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<PretendWorkItem> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ void serialise(Serialiser &) const;
+ };
+
+ class PALUDIS_VISIBLE ExecuteWorkItem :
+ public virtual DeclareAbstractAcceptMethods<ExecuteWorkItem, MakeTypeList<
+ FetchWorkItem, InstallWorkItem, UninstallWorkItem>::Type>
+ {
+ public:
+ virtual ~ExecuteWorkItem();
+
+ static const std::tr1::shared_ptr<ExecuteWorkItem> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void serialise(Serialiser &) const = 0;
+ };
+
+ class PALUDIS_VISIBLE FetchWorkItem :
+ private PrivateImplementationPattern<FetchWorkItem>,
+ public ExecuteWorkItem,
+ public ImplementAcceptMethods<ExecuteWorkItem, FetchWorkItem>
+ {
+ public:
+ FetchWorkItem(
+ const std::tr1::shared_ptr<const PackageID> &
+ );
+ ~FetchWorkItem();
+
+ const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<FetchWorkItem> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void serialise(Serialiser &) const;
+ };
+
+ class PALUDIS_VISIBLE InstallWorkItem :
+ private PrivateImplementationPattern<InstallWorkItem>,
+ public ExecuteWorkItem,
+ public ImplementAcceptMethods<ExecuteWorkItem, InstallWorkItem>
+ {
+ public:
+ InstallWorkItem(
+ const std::tr1::shared_ptr<const PackageID> &,
+ const RepositoryName &,
+ const DestinationType,
+ const std::tr1::shared_ptr<const PackageIDSequence> &);
+ ~InstallWorkItem();
+
+ const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const RepositoryName destination_repository_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ DestinationType destination_type() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const PackageIDSequence> replacing() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<InstallWorkItem> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void serialise(Serialiser &) const;
+ };
+
+ class PALUDIS_VISIBLE UninstallWorkItem :
+ private PrivateImplementationPattern<UninstallWorkItem>,
+ public ExecuteWorkItem,
+ public ImplementAcceptMethods<ExecuteWorkItem, UninstallWorkItem>
+ {
+ public:
+ UninstallWorkItem(
+ const std::tr1::shared_ptr<const PackageIDSequence> &
+ );
+ ~UninstallWorkItem();
+
+ const std::tr1::shared_ptr<const PackageIDSequence> ids_to_remove() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<UninstallWorkItem> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void serialise(Serialiser &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/resolver/work_list-fwd.hh b/paludis/resolver/work_list-fwd.hh
new file mode 100644
index 0000000..c86896d
--- /dev/null
+++ b/paludis/resolver/work_list-fwd.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LIST_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LIST_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ template <typename WorkItem_>
+ struct WorkList;
+
+ typedef int WorkListIndex;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/work_list.cc b/paludis/resolver/work_list.cc
new file mode 100644
index 0000000..2678d54
--- /dev/null
+++ b/paludis/resolver/work_list.cc
@@ -0,0 +1,117 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/work_list.hh>
+#include <paludis/resolver/work_item.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/serialise-impl.hh>
+#include <vector>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+#ifndef PALUDIS_NO_DOUBLE_TEMPLATE
+ template <>
+#endif
+ template <typename WorkItem_>
+ struct Implementation<WorkList<WorkItem_> >
+ {
+ std::vector<std::tr1::shared_ptr<WorkItem_> > list;
+ };
+
+#ifdef PALUDIS_NO_DOUBLE_TEMPLATE
+ template <>
+#endif
+ template <typename WorkItem_>
+ struct WrappedForwardIteratorTraits<WorkListConstIteratorTag<WorkItem_> >
+ {
+ typedef typename std::vector<std::tr1::shared_ptr<WorkItem_> >::const_iterator UnderlyingIterator;
+ };
+}
+
+template <typename WorkItem_>
+WorkList<WorkItem_>::WorkList() :
+ PrivateImplementationPattern<WorkList<WorkItem_> >(new Implementation<WorkList<WorkItem_> >)
+{
+}
+
+template <typename WorkItem_>
+WorkList<WorkItem_>::~WorkList()
+{
+}
+
+template <typename WorkItem_>
+WorkListIndex
+WorkList<WorkItem_>::append(const std::tr1::shared_ptr<WorkItem_> & i)
+{
+ typename std::vector<std::tr1::shared_ptr<WorkItem_> >::const_iterator p(_imp->list.insert(_imp->list.end(), i));
+ return p - _imp->list.begin();
+}
+
+template <typename WorkItem_>
+int
+WorkList<WorkItem_>::length() const
+{
+ return _imp->list.size();
+}
+
+template <typename WorkItem_>
+typename WorkList<WorkItem_>::ConstIterator
+WorkList<WorkItem_>::begin() const
+{
+ return ConstIterator(_imp->list.begin());
+}
+
+template <typename WorkItem_>
+typename WorkList<WorkItem_>::ConstIterator
+WorkList<WorkItem_>::end() const
+{
+ return ConstIterator(_imp->list.end());
+}
+
+template <typename WorkItem_>
+const std::tr1::shared_ptr<WorkList<WorkItem_> >
+WorkList<WorkItem_>::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "WorkList");
+ Deserialisator vv(*v.find_remove_member("items"), "c");
+ std::tr1::shared_ptr<WorkList> result(new WorkList);
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ result->append(vv.member<std::tr1::shared_ptr<WorkItem_> >(stringify(n)));
+ return result;
+}
+
+template <typename WorkItem_>
+void
+WorkList<WorkItem_>::serialise(Serialiser & s) const
+{
+ s.object("WorkList")
+ .member(SerialiserFlags<serialise::container>(), "items", _imp->list)
+ ;
+}
+
+template class WorkList<PretendWorkItem>;
+template class WrappedForwardIterator<WorkListConstIteratorTag<PretendWorkItem>, const std::tr1::shared_ptr<PretendWorkItem> >;
+
+template class WorkList<ExecuteWorkItem>;
+template class WrappedForwardIterator<WorkListConstIteratorTag<ExecuteWorkItem>, const std::tr1::shared_ptr<ExecuteWorkItem> >;
+
diff --git a/paludis/resolver/work_list.hh b/paludis/resolver/work_list.hh
new file mode 100644
index 0000000..62f5afe
--- /dev/null
+++ b/paludis/resolver/work_list.hh
@@ -0,0 +1,71 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LIST_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LIST_HH 1
+
+#include <paludis/resolver/work_list-fwd.hh>
+#include <paludis/resolver/work_item-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/serialise-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ template <typename WorkItem_>
+ struct WorkListConstIteratorTag;
+
+ template <typename WorkItem_>
+ class PALUDIS_VISIBLE WorkList :
+ private PrivateImplementationPattern<WorkList<WorkItem_> >
+ {
+ private:
+ using PrivateImplementationPattern<WorkList<WorkItem_> >::_imp;
+
+ public:
+ WorkList();
+ ~WorkList();
+
+ WorkListIndex append(const std::tr1::shared_ptr<WorkItem_> &);
+
+ int length() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ typedef WorkListConstIteratorTag<WorkItem_> ConstIteratorTag;
+ typedef WrappedForwardIterator<ConstIteratorTag, const std::tr1::shared_ptr<WorkItem_> > ConstIterator;
+ ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<WorkList<WorkItem_> > deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ void serialise(Serialiser &) const;
+ };
+
+ extern template class WorkList<PretendWorkItem>;
+ extern template class WorkList<ExecuteWorkItem>;
+ }
+
+ extern template class WrappedForwardIterator<resolver::WorkListConstIteratorTag<resolver::PretendWorkItem>,
+ const std::tr1::shared_ptr<resolver::PretendWorkItem> >;
+ extern template class WrappedForwardIterator<resolver::WorkListConstIteratorTag<resolver::ExecuteWorkItem>,
+ const std::tr1::shared_ptr<resolver::ExecuteWorkItem> >;
+}
+
+#endif
diff --git a/paludis/resolver/work_lists-fwd.hh b/paludis/resolver/work_lists-fwd.hh
new file mode 100644
index 0000000..f3b12bb
--- /dev/null
+++ b/paludis/resolver/work_lists-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LISTS_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LISTS_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct WorkLists;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/work_lists.cc b/paludis/resolver/work_lists.cc
new file mode 100644
index 0000000..380718e
--- /dev/null
+++ b/paludis/resolver/work_lists.cc
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/work_lists.hh>
+#include <paludis/resolver/work_list.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/make_shared_copy.hh>
+#include <paludis/serialise-impl.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+void
+WorkLists::serialise(Serialiser & s) const
+{
+ s.object("WorkLists")
+ .member(SerialiserFlags<serialise::might_be_null>(), "execute_work_list", execute_work_list())
+ .member(SerialiserFlags<serialise::might_be_null>(), "pretend_work_list", pretend_work_list())
+ ;
+}
+
+const std::tr1::shared_ptr<WorkLists>
+WorkLists::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "WorkLists");
+
+ return make_shared_copy(make_named_values<WorkLists>(
+ n::execute_work_list() = v.member<std::tr1::shared_ptr<WorkList<ExecuteWorkItem> > >("execute_work_list"),
+ n::pretend_work_list() = v.member<std::tr1::shared_ptr<WorkList<PretendWorkItem> > >("pretend_work_list")
+ ));
+}
diff --git a/paludis/resolver/work_lists.hh b/paludis/resolver/work_lists.hh
new file mode 100644
index 0000000..9df0878
--- /dev/null
+++ b/paludis/resolver/work_lists.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LISTS_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_WORK_LISTS_HH 1
+
+#include <paludis/resolver/work_lists-fwd.hh>
+#include <paludis/resolver/work_list-fwd.hh>
+#include <paludis/resolver/work_item-fwd.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/serialise-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ namespace n
+ {
+ typedef Name<struct execute_work_list_name> execute_work_list;
+ typedef Name<struct pretend_work_list_name> pretend_work_list;
+ }
+
+ namespace resolver
+ {
+ struct WorkLists
+ {
+ NamedValue<n::execute_work_list, std::tr1::shared_ptr<WorkList<ExecuteWorkItem> > > execute_work_list;
+ NamedValue<n::pretend_work_list, std::tr1::shared_ptr<WorkList<PretendWorkItem> > > pretend_work_list;
+
+ static const std::tr1::shared_ptr<WorkLists> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ void serialise(Serialiser &) const;
+ };
+ }
+}
+
+#endif
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 1fede8e..1235ad2 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -55,6 +55,9 @@
#include <paludis/resolver/job_id.hh>
#include <paludis/resolver/job_state.hh>
#include <paludis/resolver/arrow.hh>
+#include <paludis/resolver/work_lists.hh>
+#include <paludis/resolver/work_list.hh>
+#include <paludis/resolver/work_item.hh>
#include <paludis/package_id.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -128,15 +131,15 @@ namespace
bool do_pretend(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const ChangesToMakeDecision & decision,
+ const std::tr1::shared_ptr<const PackageID> & origin_id,
const int x, const int y, const int last_x,
std::tr1::shared_ptr<OutputManager> & output_manager_goes_here)
{
- Context context("When pretending for '" + stringify(*decision.origin_id()) + "':");
+ Context context("When pretending for '" + stringify(*origin_id) + "':");
if (0 != last_x)
- std::cout << std::string(stringify(last_x).length() + stringify(y).length() + 4, '\010');
- std::cout << x << " of " << y << std::flush;
+ cout << std::string(stringify(last_x).length() + stringify(y).length() + 4, '\010');
+ cout << x << " of " << y << std::flush;
std::tr1::shared_ptr<Sequence<std::string> > args(new Sequence<std::string>);
@@ -145,7 +148,7 @@ namespace
args->push_back("--if-supported");
args->push_back("--x-of-y");
args->push_back(stringify(x) + " of " + stringify(y));
- args->push_back(stringify(decision.origin_id()->uniquely_identifying_spec()));
+ args->push_back(stringify(origin_id->uniquely_identifying_spec()));
int retcode;
@@ -222,15 +225,13 @@ namespace
bool do_fetch(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const ChangesToMakeDecision & decision,
+ const std::tr1::shared_ptr<const PackageID> & id,
const int x, const int y, bool normal_only,
std::tr1::shared_ptr<OutputManager> & output_manager_goes_here)
{
- const std::tr1::shared_ptr<const PackageID> id(decision.origin_id());
Context context("When fetching for '" + stringify(*id) + "':");
- starting_action("fetch (" + std::string(normal_only ? "regular parts" : "extra parts") + ")",
- decision.origin_id(), x, y);
+ starting_action("fetch (" + std::string(normal_only ? "regular parts" : "extra parts") + ")", id, x, y);
std::string command(cmdline.program_options.a_perform_program.argument());
if (command.empty())
@@ -293,15 +294,16 @@ namespace
output_manager_goes_here = output_manager;
}
- done_action("fetch (" + std::string(normal_only ? "regular parts" : "extra parts") + ")",
- decision.origin_id(), 0 == retcode);
+ done_action("fetch (" + std::string(normal_only ? "regular parts" : "extra parts") + ")", id, 0 == retcode);
return 0 == retcode;
}
bool do_install(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
- const ChangesToMakeDecision & decision,
+ const std::tr1::shared_ptr<const PackageID> & id,
+ const RepositoryName & destination_repository_name,
+ const std::tr1::shared_ptr<const PackageIDSequence> & replacing,
const DestinationType & destination_type,
const int x, const int y,
std::tr1::shared_ptr<OutputManager> & output_manager_goes_here)
@@ -326,10 +328,9 @@ namespace
if (destination_string.empty())
throw InternalError(PALUDIS_HERE, "unhandled dt");
- const std::tr1::shared_ptr<const PackageID> id(decision.origin_id());
Context context("When " + destination_string + " for '" + stringify(*id) + "':");
- starting_action(action_string, decision.origin_id(), x, y);
+ starting_action(action_string, id, x, y);
std::string command(cmdline.program_options.a_perform_program.argument());
if (command.empty())
@@ -337,9 +338,9 @@ namespace
command.append(" install --hooks --managed-output ");
command.append(stringify(id->uniquely_identifying_spec()));
- command.append(" --destination " + stringify(decision.destination()->repository()));
- for (PackageIDSequence::ConstIterator i(decision.destination()->replacing()->begin()),
- i_end(decision.destination()->replacing()->end()) ;
+ command.append(" --destination " + stringify(destination_repository_name));
+ for (PackageIDSequence::ConstIterator i(replacing->begin()),
+ i_end(replacing->end()) ;
i != i_end ; ++i)
command.append(" --replacing " + stringify((*i)->uniquely_identifying_spec()));
@@ -395,7 +396,7 @@ namespace
output_manager_goes_here = output_manager;
}
- done_action(action_string, decision.origin_id(), 0 == retcode);
+ done_action(action_string, id, 0 == retcode);
return 0 == retcode;
}
@@ -473,296 +474,6 @@ namespace
return 0 == retcode;
}
- struct JobCounts
- {
- int x_fetches, y_fetches, x_installs, y_installs;
-
- JobCounts() :
- x_fetches(0),
- y_fetches(0),
- x_installs(0),
- y_installs(0)
- {
- }
-
- void visit(const SimpleInstallJob &)
- {
- ++y_installs;
- }
-
- void visit(const UninstallJob &)
- {
- /* we'll count uninstalls as installs for now. this might be
- * confusing, or it might make most sense. if you're reading this,
- * chances are you think it's the wrong thing to do. */
- ++y_installs;
- }
-
- void visit(const FetchJob &)
- {
- ++y_fetches;
- }
-
- void visit(const UsableJob &)
- {
- }
-
- void visit(const UsableGroupJob &)
- {
- }
-
- void visit(const ErrorJob &)
- {
- }
- };
-
- typedef std::tr1::unordered_map<JobID, std::tr1::shared_ptr<JobState>, Hash<JobID> > JobStateMap;
- typedef std::list<std::tr1::shared_ptr<JobPendingState> > PendingJobsList;
- typedef std::list<std::tr1::shared_ptr<JobState> > Summary;
-
- struct DoOneTakenVisitor
- {
- const std::tr1::shared_ptr<Environment> env;
- const ExecuteResolutionCommandLine & cmdline;
- JobCounts & counts;
- std::tr1::shared_ptr<JobState> & state;
- JobStateMap & job_state_map;
-
- DoOneTakenVisitor(
- const std::tr1::shared_ptr<Environment> & e,
- const ExecuteResolutionCommandLine & c,
- JobCounts & k,
- std::tr1::shared_ptr<JobState> & s,
- JobStateMap & m) :
- env(e),
- cmdline(c),
- counts(k),
- state(s),
- job_state_map(m)
- {
- }
-
- bool visit(const SimpleInstallJob & job)
- {
- std::tr1::shared_ptr<OutputManager> fetch_output_manager_goes_here, install_output_manager_goes_here;
-
- ++counts.x_installs;
-
- /* not all of the fetch is done in the background */
- if (! do_fetch(env, cmdline, *job.changes_to_make_decision(), counts.x_installs, counts.y_installs,
- false, fetch_output_manager_goes_here))
- {
- std::tr1::shared_ptr<JobFailedState> failed_state(new JobFailedState(state->job()));
- if (fetch_output_manager_goes_here)
- failed_state->add_output_manager(fetch_output_manager_goes_here);
- state = failed_state;
- return false;
- }
-
- if (! do_install(env, cmdline, *job.changes_to_make_decision(), job.resolution()->resolvent().destination_type(),
- counts.x_installs, counts.y_installs, install_output_manager_goes_here))
- {
- std::tr1::shared_ptr<JobFailedState> failed_state(new JobFailedState(state->job()));
- if (fetch_output_manager_goes_here)
- failed_state->add_output_manager(fetch_output_manager_goes_here);
- if (install_output_manager_goes_here)
- failed_state->add_output_manager(install_output_manager_goes_here);
- state = failed_state;
- return false;
- }
- else
- {
- std::tr1::shared_ptr<JobSucceededState> succeeded_state(new JobSucceededState(state->job()));
- if (fetch_output_manager_goes_here)
- succeeded_state->add_output_manager(fetch_output_manager_goes_here);
- if (install_output_manager_goes_here)
- succeeded_state->add_output_manager(install_output_manager_goes_here);
- state = succeeded_state;
- return true;
- }
- }
-
- bool visit(const UninstallJob & job)
- {
- std::list<std::tr1::shared_ptr<OutputManager> > output_managers;
-
- ++counts.x_installs;
-
- bool failed(false);
- for (PackageIDSequence::ConstIterator i(job.remove_decision()->ids()->begin()),
- i_end(job.remove_decision()->ids()->end()) ;
- i != i_end ; ++i)
- {
- std::tr1::shared_ptr<OutputManager> uninstall_output_manager_goes_here;
- if (! do_uninstall(env, cmdline, *i,
- counts.x_installs, counts.y_installs, uninstall_output_manager_goes_here))
- failed = true;
- if (uninstall_output_manager_goes_here)
- output_managers.push_back(uninstall_output_manager_goes_here);
- }
-
- if (failed)
- {
- std::tr1::shared_ptr<JobFailedState> failed_state(new JobFailedState(state->job()));
- std::for_each(output_managers.begin(), output_managers.end(),
- std::tr1::bind(&JobFailedState::add_output_manager, failed_state, std::tr1::placeholders::_1));
- state = failed_state;
- return false;
- }
- else
- {
- std::tr1::shared_ptr<JobSucceededState> succeeded_state(new JobSucceededState(state->job()));
-
- /* uninstalls don't mark success themselves, to avoid confusing
- * things when called as part of an install. maybe we should
- * mark success individually rather than all together if we're
- * uninstalling multiple things. */
- std::for_each(output_managers.begin(), output_managers.end(),
- std::tr1::bind(&OutputManager::succeeded, std::tr1::placeholders::_1));
-
- std::for_each(output_managers.begin(), output_managers.end(),
- std::tr1::bind(&JobSucceededState::add_output_manager, succeeded_state, std::tr1::placeholders::_1));
- state = succeeded_state;
- return true;
- }
- }
-
- bool visit(const FetchJob & job)
- {
- std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
-
- ++counts.x_fetches;
- if (! do_fetch(env, cmdline, *job.changes_to_make_decision(), counts.x_fetches, counts.y_fetches,
- true, output_manager_goes_here))
- {
- std::tr1::shared_ptr<JobFailedState> failed_state(new JobFailedState(state->job()));
- if (output_manager_goes_here)
- failed_state->add_output_manager(output_manager_goes_here);
- state = failed_state;
- return false;
- }
- else
- {
- std::tr1::shared_ptr<JobSucceededState> succeeded_state(new JobSucceededState(state->job()));
- if (output_manager_goes_here)
- succeeded_state->add_output_manager(output_manager_goes_here);
- state = succeeded_state;
- return true;
- }
- }
-
- bool visit(const ErrorJob &)
- {
- state.reset(new JobFailedState(state->job()));
- return false;
- }
-
- bool visit(const UsableJob &)
- {
- state.reset(new JobSucceededState(state->job()));
- return true;
- }
-
- bool visit(const UsableGroupJob & job)
- {
- bool result(true);
-
- for (JobIDSequence::ConstIterator i(job.job_ids()->begin()), i_end(job.job_ids()->end()) ;
- i != i_end ; ++i)
- {
- JobStateMap::iterator s(job_state_map.find(*i));
- if (s == job_state_map.end())
- throw InternalError(PALUDIS_HERE, "missing state");
-
- DoOneTakenVisitor v(env, cmdline, counts, s->second, job_state_map);
- result = s->second->job()->accept_returning<bool>(v) && result;
- }
-
- state.reset(new JobSucceededState(state->job()));
- return result;
- }
- };
-
- struct DoOneSkippedVisitor
- {
- const std::tr1::shared_ptr<Environment> env;
- const ExecuteResolutionCommandLine & cmdline;
- JobCounts & counts;
- std::tr1::shared_ptr<JobState> & state;
- JobStateMap & job_state_map;
-
- DoOneSkippedVisitor(
- const std::tr1::shared_ptr<Environment> & e,
- const ExecuteResolutionCommandLine & c,
- JobCounts & k,
- std::tr1::shared_ptr<JobState> & s,
- JobStateMap & m) :
- env(e),
- cmdline(c),
- counts(k),
- state(s),
- job_state_map(m)
- {
- }
-
- void visit(const SimpleInstallJob & job)
- {
- ++counts.x_installs;
-
- cout << endl;
- cout << c::bold_blue() << counts.x_installs << " of " << counts.y_installs << ": Skipping install of "
- << *job.changes_to_make_decision()->origin_id() << c::normal() << endl;
- cout << endl;
-
- state.reset(new JobSkippedState(state->job()));
- }
-
- void visit(const UninstallJob & job)
- {
- ++counts.x_installs;
-
- cout << endl;
- cout << c::bold_blue() << counts.x_installs << " of " << counts.y_installs << ": Skipping uninstall of "
- << job.resolution()->resolvent() << c::normal() << endl;
- cout << endl;
-
- state.reset(new JobSkippedState(state->job()));
- }
-
- void visit(const FetchJob &)
- {
- ++counts.x_fetches;
-
- state.reset(new JobSkippedState(state->job()));
- }
-
- void visit(const ErrorJob &)
- {
- state.reset(new JobSkippedState(state->job()));
- }
-
- void visit(const UsableJob &)
- {
- state.reset(new JobSkippedState(state->job()));
- }
-
- void visit(const UsableGroupJob & job)
- {
- for (JobIDSequence::ConstIterator i(job.job_ids()->begin()), i_end(job.job_ids()->end()) ;
- i != i_end ; ++i)
- {
- JobStateMap::iterator s(job_state_map.find(*i));
- if (s == job_state_map.end())
- throw InternalError(PALUDIS_HERE, "missing state");
-
- DoOneSkippedVisitor v(env, cmdline, counts, s->second, job_state_map);
- s->second->job()->accept(v);
- }
-
- state.reset(new JobSkippedState(state->job()));
- }
- };
-
void update_world(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
@@ -863,7 +574,6 @@ namespace
void execute_update_world(
const std::tr1::shared_ptr<Environment> & env,
- const ResolverLists &,
const ExecuteResolutionCommandLine & cmdline)
{
if (cmdline.execution_options.a_preserve_world.specified())
@@ -875,289 +585,148 @@ namespace
update_world(env, cmdline, false);
}
- struct Populator
- {
- const std::tr1::shared_ptr<const Job> job;
- const ResolverLists & lists;
- JobStateMap & job_state_map;
- PendingJobsList * const pending;
-
- Populator(
- const std::tr1::shared_ptr<const Job> & j,
- const ResolverLists & l,
- JobStateMap & s,
- PendingJobsList * const p) :
- job(j),
- lists(l),
- job_state_map(s),
- pending(p)
- {
- }
-
- void common() const
- {
- const std::tr1::shared_ptr<JobPendingState> state(new JobPendingState(job));
- if (! job_state_map.insert(std::make_pair(job->id(), state)).second)
- throw InternalError(PALUDIS_HERE, "duplicate id");
-
- if (pending)
- pending->push_back(state);
- }
-
- void visit(const SimpleInstallJob &) const
- {
- common();
- }
-
- void visit(const UninstallJob &) const
- {
- common();
- }
-
- void visit(const UsableJob &) const
- {
- common();
- }
-
- void visit(const FetchJob &) const
- {
- common();
- }
-
- void visit(const ErrorJob &) const
- {
- common();
- }
-
- void visit(const UsableGroupJob & j) const
- {
- common();
-
- for (JobIDSequence::ConstIterator i(j.job_ids()->begin()), i_end(j.job_ids()->end()) ;
- i != i_end ; ++i)
- {
- const std::tr1::shared_ptr<const Job> k(lists.jobs()->fetch(*i));
- k->accept(Populator(k, lists, job_state_map, 0));
- }
- }
- };
-
- struct JobStateChecker
- {
- bool visit(const JobPendingState &) const PALUDIS_ATTRIBUTE((noreturn))
- {
- throw InternalError(PALUDIS_HERE, "still pending");
- }
-
- bool visit(const JobFailedState &) const
- {
- return false;
- }
-
- bool visit(const JobSkippedState &) const
- {
- return false;
- }
-
- bool visit(const JobSucceededState &) const
- {
- return true;
- }
- };
-
- int execute_taken(
+ int execute_pretends(
const std::tr1::shared_ptr<Environment> & env,
- const ResolverLists & lists,
- const ExecuteResolutionCommandLine & cmdline,
- Summary & summary)
+ const std::tr1::shared_ptr<WorkLists> & lists,
+ const ExecuteResolutionCommandLine & cmdline)
{
- int retcode(0);
-
- JobCounts counts;
- JobStateMap job_state_map;
- PendingJobsList pending;
-
- for (JobIDSequence::ConstIterator c(lists.taken_job_ids()->begin()),
- c_end(lists.taken_job_ids()->end()) ;
- c != c_end ; ++c)
- {
- const std::tr1::shared_ptr<const Job> job(lists.jobs()->fetch(*c));
- job->accept(counts);
- job->accept(Populator(job, lists, job_state_map, &pending));
- }
+ bool failed(false);
+ int x(0), y(lists->pretend_work_list()->length()), last_x(0);
- if (0 != env->perform_hook(Hook("install_all_pre")
+ if (0 != env->perform_hook(Hook("pretend_all_pre")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
).max_exit_status())
throw ActionAbortedError("Aborted by hook");
- for (PendingJobsList::iterator p(pending.begin()), p_next(p), p_end(pending.end()) ;
- p != p_end ; p = p_next)
+ for (WorkList<PretendWorkItem>::ConstIterator c(lists->pretend_work_list()->begin()),
+ c_end(lists->pretend_work_list()->end()) ;
+ c != c_end ; ++c)
{
- ++p_next;
-
- std::tr1::shared_ptr<const Job> skipped_because_of;
- for (ArrowSequence::ConstIterator a((*p)->job()->arrows()->begin()), a_end((*p)->job()->arrows()->end()) ;
- a != a_end ; ++a)
- {
- const std::tr1::shared_ptr<const Job> after_job(lists.jobs()->fetch(a->comes_after()));
- JobStateMap::const_iterator s(job_state_map.find(after_job->id()));
- if (s == job_state_map.end())
- throw InternalError(PALUDIS_HERE, "missing arrow: " + stringify(after_job->id().string_id()));
-
- if ((*p)->job()->used_existing_packages_when_ordering()->end() != std::find(
- (*p)->job()->used_existing_packages_when_ordering()->begin(),
- (*p)->job()->used_existing_packages_when_ordering()->end(),
- a->comes_after()))
- {
- if (! simple_visitor_cast<const JobPendingState>(*s->second))
- throw InternalError(PALUDIS_HERE, "not pending: " + stringify((*p)->job()->id().string_id()) + " -> "
- + stringify(a->comes_after().string_id()) + " " + s->second->state_name());
- }
- else
- {
- bool ignorable(false);
-
- if (cmdline.execution_options.a_continue_on_failure.argument() == "if-satisfied")
- ignorable = a->failure_kinds()[fk_ignorable_if_satisfied];
- else if (cmdline.execution_options.a_continue_on_failure.argument() == "always")
- ignorable = true;
-
- if ((! ignorable) && (! s->second->accept_returning<bool>(JobStateChecker())))
- {
- skipped_because_of = after_job;
- break;
- }
- }
- }
+ if (++x == 1)
+ cout << "Executing pretend actions: " << std::flush;
- JobStateMap::iterator s(job_state_map.find((*p)->job()->id()));
- if (s == job_state_map.end())
- throw InternalError(PALUDIS_HERE, "missing state");
- pending.erase(p);
-
- if (skipped_because_of)
- {
- DoOneSkippedVisitor v(env, cmdline, counts, s->second, job_state_map);
- s->second->job()->accept(v);
- retcode |= 1;
- }
- else
- {
- DoOneTakenVisitor v(env, cmdline, counts, s->second, job_state_map);
- if (! s->second->job()->accept_returning<bool>(v))
- retcode |= 1;
- }
-
- summary.push_back(s->second);
-
- if ((0 != retcode) && (cmdline.execution_options.a_continue_on_failure.argument() == "never"))
- break;
+ std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
+ failed = failed || ! do_pretend(env, cmdline, (*c)->origin_id(), x, y, last_x, output_manager_goes_here);
+ last_x = x;
}
- if (0 != env->perform_hook(Hook("install_all_post")
+ if (0 != last_x)
+ cout << endl;
+
+ if (0 != env->perform_hook(Hook("pretend_all_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
).max_exit_status())
throw ActionAbortedError("Aborted by hook");
- return retcode;
+ return failed ? 1 : 0;
}
- struct DoOnePretendVisitor
+ struct Summary
+ {
+ };
+
+ struct ExecuteOneVisitor
{
const std::tr1::shared_ptr<Environment> env;
const ExecuteResolutionCommandLine & cmdline;
- JobCounts & counts;
- int & last_x;
+ int & x_fetch;
+ int & x_install;
+ const int y;
- DoOnePretendVisitor(
+ ExecuteOneVisitor(
const std::tr1::shared_ptr<Environment> & e,
const ExecuteResolutionCommandLine & c,
- JobCounts & k,
- int & l) :
+ int & xf, int & xi, int yy) :
env(e),
cmdline(c),
- counts(k),
- last_x(l)
+ x_fetch(xf),
+ x_install(xi),
+ y(yy)
{
}
- bool visit(const SimpleInstallJob & c) const
+ int visit(InstallWorkItem & install_item)
{
- if (0 == last_x)
- std::cout << "Executing pretend actions: " << std::flush;
+ ++x_install;
std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
- return do_pretend(env, cmdline, *c.changes_to_make_decision(), ++counts.x_installs, counts.y_installs,
- last_x++, output_manager_goes_here);
- }
- bool visit(const UninstallJob &) const
- {
- ++counts.x_installs;
- return true;
- }
+ if (! do_fetch(env, cmdline, install_item.origin_id(), x_install, y, false, output_manager_goes_here))
+ return 1;
- bool visit(const ErrorJob &) const
- {
- return true;
- }
+ if (! do_install(env, cmdline, install_item.origin_id(), install_item.destination_repository_name(),
+ install_item.replacing(), install_item.destination_type(),
+ x_install, y, output_manager_goes_here))
+ return 1;
- bool visit(const FetchJob &) const
- {
- return true;
+ return 0;
}
- bool visit(const UsableJob &) const
+ int visit(UninstallWorkItem & uninstall_item)
{
- return true;
+ /* we treat uninstalls as installs for counts. if you're reading
+ * this it's probably because you think that that's silly, which
+ * means you get to change it. */
+ ++x_install;
+
+ std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
+ for (PackageIDSequence::ConstIterator i(uninstall_item.ids_to_remove()->begin()),
+ i_end(uninstall_item.ids_to_remove()->end()) ;
+ i != i_end ; ++i)
+ if (! do_uninstall(env, cmdline, *i, x_install, y, output_manager_goes_here))
+ return 1;
+
+ return 0;
}
- bool visit(const UsableGroupJob &) const
+ int visit(FetchWorkItem & fetch_item)
{
- return true;
+ ++x_fetch;
+ std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
+
+ if (! do_fetch(env, cmdline, fetch_item.origin_id(), x_fetch, y, true, output_manager_goes_here))
+ return 1;
+
+ return 0;
}
};
- int execute_pretends(
+ int execute_executions(
const std::tr1::shared_ptr<Environment> & env,
- const ResolverLists & lists,
- const ExecuteResolutionCommandLine & cmdline)
+ const std::tr1::shared_ptr<WorkLists> & lists,
+ const ExecuteResolutionCommandLine & cmdline,
+ Summary &)
{
- bool failed(false);
- JobCounts counts;
- int last_x(0);
-
- for (JobIDSequence::ConstIterator c(lists.taken_job_ids()->begin()),
- c_end(lists.taken_job_ids()->end()) ;
- c != c_end ; ++c)
- lists.jobs()->fetch(*c)->accept(counts);
+ int retcode(0);
+ int x_fetch(0), x_install(0), y(lists->pretend_work_list()->length());
- if (0 != env->perform_hook(Hook("pretend_all_pre")
+ if (0 != env->perform_hook(Hook("install_all_pre")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
).max_exit_status())
throw ActionAbortedError("Aborted by hook");
- for (JobIDSequence::ConstIterator c(lists.taken_job_ids()->begin()),
- c_end(lists.taken_job_ids()->end()) ;
+ for (WorkList<ExecuteWorkItem>::ConstIterator c(lists->execute_work_list()->begin()),
+ c_end(lists->execute_work_list()->end()) ;
c != c_end ; ++c)
- failed = failed || ! lists.jobs()->fetch(*c)->accept_returning<bool>(DoOnePretendVisitor(
- env, cmdline, counts, last_x));
+ {
+ ExecuteOneVisitor execute(env, cmdline, x_fetch, x_install, y);
+ retcode |= (*c)->accept_returning<int>(execute);
- if (0 != last_x)
- cout << endl;
+ if (0 != retcode)
+ break;
+ }
- if (0 != env->perform_hook(Hook("pretend_all_post")
+ if (0 != env->perform_hook(Hook("install_all_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
).max_exit_status())
throw ActionAbortedError("Aborted by hook");
- return failed ? 1 : 0;
+ return retcode;
}
int execute_resolution_main(
const std::tr1::shared_ptr<Environment> & env,
- const ResolverLists & lists,
+ const std::tr1::shared_ptr<WorkLists> & lists,
const ExecuteResolutionCommandLine & cmdline,
Summary & summary)
{
@@ -1167,150 +736,26 @@ namespace
if (0 != retcode || cmdline.a_pretend.specified())
return retcode;
- retcode |= execute_taken(env, lists, cmdline, summary);
+ retcode |= execute_executions(env, lists, cmdline, summary);
if (0 != retcode)
return retcode;
- execute_update_world(env, lists, cmdline);
+ execute_update_world(env, cmdline);
+
return retcode;
}
- struct SummaryJobNameDisplayer
- {
- const ResolverLists & lists;
- const std::string colour;
- const std::string state;
- const bool want_to_flush;
- const bool this_failed;
- const bool something_failed;
- bool & done_summary;
-
- SummaryJobNameDisplayer(
- const ResolverLists & l,
- const std::string & c,
- const std::string & s,
- const bool w,
- const bool t,
- const bool f,
- bool & d
- ) :
- lists(l),
- colour(c),
- state(s),
- want_to_flush(w),
- this_failed(t),
- something_failed(f),
- done_summary(d)
- {
- }
-
- void summary() const
- {
- if (! done_summary)
- cout << endl << c::bold_blue() << "Summary:" << c::normal() << endl << endl;
- done_summary = true;
- }
-
- void visit(const SimpleInstallJob & job) const
- {
- if (want_to_flush || something_failed)
- {
- summary();
- cout << colour << state << c::normal() << *job.changes_to_make_decision()->origin_id()
- << " to " << job.changes_to_make_decision()->destination()->repository() << endl;
- }
- }
-
- void visit(const UninstallJob & job) const
- {
- if (want_to_flush || something_failed)
- {
- summary();
- cout << colour << state << c::normal() << "uninstall " << job.resolution()->resolvent() << endl;
- }
- }
-
- void visit(const FetchJob & job) const
- {
- if (want_to_flush || this_failed)
- {
- summary();
- cout << colour << state << c::normal() << "fetch " << *job.changes_to_make_decision()->origin_id() << endl;
- }
- }
-
- void visit(const ErrorJob &) const PALUDIS_ATTRIBUTE((noreturn))
- {
- throw InternalError(PALUDIS_HERE, "ErrorJob?");
- }
-
- void visit(const UsableJob &) const
- {
- }
-
- void visit(const UsableGroupJob &) const
- {
- }
- };
-
- struct SummaryStateDisplayer
- {
- const ResolverLists & lists;
- const bool something_failed;
- bool & done_summary;
-
- SummaryStateDisplayer(const ResolverLists & l, const bool s, bool & d) :
- lists(l),
- something_failed(s),
- done_summary(d)
- {
- }
-
- void visit(const JobPendingState & state) const
- {
- state.job()->accept(SummaryJobNameDisplayer(lists, c::bold_normal(), "pending: ",
- false, false, something_failed, done_summary));
- }
-
- void visit(const JobSucceededState & state) const
- {
- state.job()->accept(SummaryJobNameDisplayer(lists, c::bold_green(), "succeeded: ",
- state.any_output_manager_wants_to_flush(), false, something_failed, done_summary));
- }
-
- void visit(const JobSkippedState & state) const
- {
- state.job()->accept(SummaryJobNameDisplayer(lists, c::bold_yellow(), "skipped: ",
- false, false, something_failed, done_summary));
- }
-
- void visit(const JobFailedState & state) const
- {
- state.job()->accept(SummaryJobNameDisplayer(lists, c::bold_red(), "failed: ",
- state.any_output_manager_wants_to_flush(), true, something_failed, done_summary));
- }
- };
-
void display_summary(
- const ResolverLists & lists,
- Summary & summary,
- const bool something_failed)
+ const std::tr1::shared_ptr<WorkLists> &,
+ Summary &,
+ const bool)
{
- bool done_summary(false);
- for (Summary::iterator s(summary.begin()), s_end(summary.end()) ;
- s != s_end ; )
- {
- const std::tr1::shared_ptr<JobState> state(*s);
- summary.erase(s++);
-
- state->accept(SummaryStateDisplayer(lists, something_failed, done_summary));
- }
}
int execute_resolution(
const std::tr1::shared_ptr<Environment> & env,
- const ResolverLists & lists,
+ const std::tr1::shared_ptr<WorkLists> & lists,
const ExecuteResolutionCommandLine & cmdline)
{
Context context("When executing chosen resolution:");
@@ -1363,7 +808,7 @@ int
ExecuteResolutionCommand::run(
const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<const Sequence<std::string > > & args,
- const std::tr1::shared_ptr<const ResolverLists> & maybe_lists
+ const std::tr1::shared_ptr<WorkLists> & maybe_lists
)
{
ExecuteResolutionCommandLine cmdline;
@@ -1377,7 +822,7 @@ ExecuteResolutionCommand::run(
cmdline.import_options.apply(env);
- std::tr1::shared_ptr<const ResolverLists> lists(maybe_lists);
+ std::tr1::shared_ptr<WorkLists> lists(maybe_lists);
if (! lists)
{
if (getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "").empty())
@@ -1386,12 +831,12 @@ ExecuteResolutionCommand::run(
int fd(destringify<int>(getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "")));
SafeIFStream deser_stream(fd);
Deserialiser deserialiser(env.get(), deser_stream);
- Deserialisation deserialisation("ResolverLists", deserialiser);
- lists = make_shared_copy(ResolverLists::deserialise(deserialisation));
+ Deserialisation deserialisation("WorkLists", deserialiser);
+ lists = WorkLists::deserialise(deserialisation);
close(fd);
}
- return execute_resolution(env, *lists, cmdline);
+ return execute_resolution(env, lists, cmdline);
}
int
diff --git a/src/clients/cave/cmd_execute_resolution.hh b/src/clients/cave/cmd_execute_resolution.hh
index 51f04cf..ec2fc1f 100644
--- a/src/clients/cave/cmd_execute_resolution.hh
+++ b/src/clients/cave/cmd_execute_resolution.hh
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_EXECUTE_RESOLUTION_HH 1
#include "command.hh"
-#include <paludis/resolver/resolver_lists-fwd.hh>
+#include <paludis/resolver/work_lists-fwd.hh>
namespace paludis
{
@@ -41,7 +41,7 @@ namespace paludis
int run(
const std::tr1::shared_ptr<Environment> &,
const std::tr1::shared_ptr<const Sequence<std::string > > & args,
- const std::tr1::shared_ptr<const resolver::ResolverLists> & maybe_lists);
+ const std::tr1::shared_ptr<resolver::WorkLists> & maybe_work_lists);
std::tr1::shared_ptr<args::ArgsHandler> make_doc_cmdline();
};
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index ffdf1d6..a2c599a 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -53,6 +53,7 @@
#include <paludis/resolver/resolutions_by_resolvent.hh>
#include <paludis/resolver/resolver_lists.hh>
#include <paludis/resolver/required_confirmations.hh>
+#include <paludis/resolver/work_lists.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/generator.hh>
@@ -1181,13 +1182,6 @@ namespace
return result;
}
- void ser_thread_func(StringListStream & ser_stream, const ResolverLists & resolution_lists)
- {
- Serialiser ser(ser_stream);
- resolution_lists.serialise(ser);
- ser_stream.nothing_more_to_write();
- }
-
void serialise_resolved(StringListStream & ser_stream, const Resolved & resolved)
{
Serialiser ser(ser_stream);
@@ -1256,9 +1250,16 @@ namespace
return DisplayResolutionCommand().run(env, args, resolved);
}
+ void serialise_work_lists(StringListStream & ser_stream, const WorkLists & work_lists)
+ {
+ Serialiser ser(ser_stream);
+ work_lists.serialise(ser);
+ ser_stream.nothing_more_to_write();
+ }
+
int perform_resolution(
const std::tr1::shared_ptr<Environment> & env,
- const std::tr1::shared_ptr<const ResolverLists> & resolution_lists,
+ const std::tr1::shared_ptr<const Resolved> & resolved,
const ResolveCommandLineResolutionOptions & resolution_options,
const ResolveCommandLineExecutionOptions & execution_options,
const ResolveCommandLineProgramOptions & program_options,
@@ -1310,7 +1311,7 @@ namespace
* be a fun exercise for someone with way too much time on their hands.
* */
StringListStream ser_stream;
- ser_thread_func(ser_stream, *resolution_lists);
+ serialise_work_lists(ser_stream, *resolved->work_lists());
std::string command;
if (program_options.a_execute_resolution_program.specified())
@@ -1338,7 +1339,7 @@ namespace
become_command(cmd);
}
else
- return ExecuteResolutionCommand().run(env, args, resolution_lists);
+ return ExecuteResolutionCommand().run(env, args, resolved->work_lists());
}
struct KindNameVisitor
@@ -1687,7 +1688,7 @@ paludis::cave::resolve_common(
retcode |= 3;
if (0 == retcode)
- return perform_resolution(env, resolver->lists(), resolution_options,
+ return perform_resolution(env, resolver->resolved(), resolution_options,
execution_options, program_options, keys_if_import, targets, is_set);
}
catch (...)