aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-16 19:26:15 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-16 19:26:15 +0100
commit8a515b7cec728f9f30c7016e9d4d71ab97720177 (patch)
tree70663c8a6f66a08f9306f8199ad1783e13ab5771
parente02d79752c97694a220ce8015fca574330bb2dc1 (diff)
downloadpaludis-8a515b7cec728f9f30c7016e9d4d71ab97720177.tar.gz
paludis-8a515b7cec728f9f30c7016e9d4d71ab97720177.tar.xz
Summaries
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/job.cc41
-rw-r--r--paludis/resolver/job.hh13
-rw-r--r--paludis/resolver/job_state-fwd.hh37
-rw-r--r--paludis/resolver/job_state.cc118
-rw-r--r--paludis/resolver/job_state.hh94
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc178
7 files changed, 448 insertions, 35 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 34d556d..59e4fe2 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -33,6 +33,7 @@ noinst_HEADERS = \
job.hh job-fwd.hh \
job_list.hh job_list-fwd.hh \
job_lists.hh job_lists-fwd.hh \
+ job_state.hh job_state-fwd.hh \
nag.hh nag-fwd.hh \
orderer.hh orderer-fwd.hh \
orderer_notes.hh orderer_notes-fwd.hh \
@@ -65,6 +66,7 @@ libpaludisresolver_a_SOURCES = \
job.cc \
job_list.cc \
job_lists.cc \
+ job_state.cc \
nag.cc \
orderer.cc \
orderer_notes.cc \
diff --git a/paludis/resolver/job.cc b/paludis/resolver/job.cc
index 2afe034..480542c 100644
--- a/paludis/resolver/job.cc
+++ b/paludis/resolver/job.cc
@@ -97,6 +97,7 @@ namespace paludis
struct Implementation<FetchJob>
{
const std::tr1::shared_ptr<const PackageID> origin_id;
+ std::tr1::shared_ptr<JobState> state;
Implementation(const std::tr1::shared_ptr<const PackageID> & o) :
origin_id(o)
@@ -120,6 +121,18 @@ FetchJob::origin_id() const
return _imp->origin_id;
}
+const std::tr1::shared_ptr<JobState>
+FetchJob::state() const
+{
+ return _imp->state;
+}
+
+void
+FetchJob::set_state(const std::tr1::shared_ptr<JobState> & s)
+{
+ _imp->state = s;
+}
+
const std::tr1::shared_ptr<FetchJob>
FetchJob::deserialise(Deserialisation & d)
{
@@ -147,6 +160,8 @@ namespace paludis
const DestinationType destination_type;
const std::tr1::shared_ptr<const PackageIDSequence> replacing;
+ std::tr1::shared_ptr<JobState> state;
+
Implementation(
const std::tr1::shared_ptr<const PackageID> & o,
const RepositoryName & d,
@@ -200,6 +215,18 @@ InstallJob::replacing() const
return _imp->replacing;
}
+const std::tr1::shared_ptr<JobState>
+InstallJob::state() const
+{
+ return _imp->state;
+}
+
+void
+InstallJob::set_state(const std::tr1::shared_ptr<JobState> & s)
+{
+ _imp->state = s;
+}
+
const std::tr1::shared_ptr<InstallJob>
InstallJob::deserialise(Deserialisation & d)
{
@@ -238,6 +265,8 @@ namespace paludis
{
const std::tr1::shared_ptr<const PackageIDSequence> ids_to_remove;
+ std::tr1::shared_ptr<JobState> state;
+
Implementation(
const std::tr1::shared_ptr<const PackageIDSequence> & r
) :
@@ -264,6 +293,18 @@ UninstallJob::ids_to_remove() const
return _imp->ids_to_remove;
}
+const std::tr1::shared_ptr<JobState>
+UninstallJob::state() const
+{
+ return _imp->state;
+}
+
+void
+UninstallJob::set_state(const std::tr1::shared_ptr<JobState> & s)
+{
+ _imp->state = s;
+}
+
const std::tr1::shared_ptr<UninstallJob>
UninstallJob::deserialise(Deserialisation & d)
{
diff --git a/paludis/resolver/job.hh b/paludis/resolver/job.hh
index d0fedef..3483bea 100644
--- a/paludis/resolver/job.hh
+++ b/paludis/resolver/job.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_RESOLVER_JOB_HH 1
#include <paludis/resolver/job-fwd.hh>
+#include <paludis/resolver/job_state-fwd.hh>
#include <paludis/resolver/destination_types-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/simple_visitor.hh>
@@ -56,6 +57,9 @@ namespace paludis
public:
virtual ~ExecuteJob();
+ virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual void set_state(const std::tr1::shared_ptr<JobState> &) = 0;
+
static const std::tr1::shared_ptr<ExecuteJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const = 0;
};
@@ -73,6 +77,9 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> origin_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void set_state(const std::tr1::shared_ptr<JobState> &);
+
static const std::tr1::shared_ptr<FetchJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const;
};
@@ -95,6 +102,9 @@ namespace paludis
DestinationType destination_type() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::tr1::shared_ptr<const PackageIDSequence> replacing() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void set_state(const std::tr1::shared_ptr<JobState> &);
+
static const std::tr1::shared_ptr<InstallJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const;
};
@@ -112,6 +122,9 @@ namespace paludis
const std::tr1::shared_ptr<const PackageIDSequence> ids_to_remove() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<JobState> state() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void set_state(const std::tr1::shared_ptr<JobState> &);
+
static const std::tr1::shared_ptr<UninstallJob> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void serialise(Serialiser &) const;
};
diff --git a/paludis/resolver/job_state-fwd.hh b/paludis/resolver/job_state-fwd.hh
new file mode 100644
index 0000000..2970e5f
--- /dev/null
+++ b/paludis/resolver/job_state-fwd.hh
@@ -0,0 +1,37 @@
+/* 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_JOB_STATE_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_JOB_STATE_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct JobState;
+
+ struct JobPendingState;
+ struct JobActiveState;
+ struct JobSucceededState;
+ struct JobFailedState;
+ struct JobSkippedState;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/job_state.cc b/paludis/resolver/job_state.cc
new file mode 100644
index 0000000..78ae200
--- /dev/null
+++ b/paludis/resolver/job_state.cc
@@ -0,0 +1,118 @@
+/* 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/job_state.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<JobActiveState>
+ {
+ std::tr1::shared_ptr<OutputManager> output_manager;
+ };
+
+ template <>
+ struct Implementation<JobSucceededState>
+ {
+ const std::tr1::shared_ptr<OutputManager> output_manager;
+
+ Implementation(const std::tr1::shared_ptr<OutputManager> & m) :
+ output_manager(m)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<JobFailedState>
+ {
+ const std::tr1::shared_ptr<OutputManager> output_manager;
+
+ Implementation(const std::tr1::shared_ptr<OutputManager> & m) :
+ output_manager(m)
+ {
+ }
+ };
+}
+
+JobState::~JobState()
+{
+}
+
+JobActiveState::JobActiveState() :
+ PrivateImplementationPattern<JobActiveState>(new Implementation<JobActiveState>)
+{
+}
+
+JobActiveState::~JobActiveState()
+{
+}
+
+void
+JobActiveState::set_output_manager(const std::tr1::shared_ptr<OutputManager> & m)
+{
+ _imp->output_manager = m;
+}
+
+const std::tr1::shared_ptr<JobSucceededState>
+JobActiveState::succeeded() const
+{
+ return make_shared_ptr(new JobSucceededState(_imp->output_manager));
+}
+
+const std::tr1::shared_ptr<JobFailedState>
+JobActiveState::failed() const
+{
+ return make_shared_ptr(new JobFailedState(_imp->output_manager));
+}
+
+JobSucceededState::JobSucceededState(const std::tr1::shared_ptr<OutputManager> & m) :
+ PrivateImplementationPattern<JobSucceededState>(new Implementation<JobSucceededState>(m))
+{
+}
+
+JobSucceededState::~JobSucceededState()
+{
+}
+
+const std::tr1::shared_ptr<OutputManager>
+JobSucceededState::output_manager() const
+{
+ return _imp->output_manager;
+}
+
+JobFailedState::JobFailedState(const std::tr1::shared_ptr<OutputManager> & m) :
+ PrivateImplementationPattern<JobFailedState>(new Implementation<JobFailedState>(m))
+{
+}
+
+JobFailedState::~JobFailedState()
+{
+}
+
+const std::tr1::shared_ptr<OutputManager>
+JobFailedState::output_manager() const
+{
+ return _imp->output_manager;
+}
+
diff --git a/paludis/resolver/job_state.hh b/paludis/resolver/job_state.hh
new file mode 100644
index 0000000..8e3a8c0
--- /dev/null
+++ b/paludis/resolver/job_state.hh
@@ -0,0 +1,94 @@
+/* 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_JOB_STATE_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_JOB_STATE_HH 1
+
+#include <paludis/resolver/job_state-fwd.hh>
+#include <paludis/util/simple_visitor.hh>
+#include <paludis/util/type_list.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE JobState :
+ public virtual DeclareAbstractAcceptMethods<JobState, MakeTypeList<
+ JobPendingState, JobActiveState, JobSucceededState, JobFailedState, JobSkippedState>::Type>
+ {
+ public:
+ virtual ~JobState() = 0;
+ };
+
+ class PALUDIS_VISIBLE JobPendingState :
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobPendingState>
+ {
+ };
+
+ class PALUDIS_VISIBLE JobActiveState :
+ private PrivateImplementationPattern<JobActiveState>,
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobActiveState>
+ {
+ public:
+ JobActiveState();
+ ~JobActiveState();
+
+ void set_output_manager(const std::tr1::shared_ptr<OutputManager> &);
+ const std::tr1::shared_ptr<JobSucceededState> succeeded() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<JobFailedState> failed() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE JobSucceededState :
+ private PrivateImplementationPattern<JobSucceededState>,
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobSucceededState>
+ {
+ public:
+ JobSucceededState(const std::tr1::shared_ptr<OutputManager> &);
+ ~JobSucceededState();
+
+ const std::tr1::shared_ptr<OutputManager> output_manager() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE JobFailedState :
+ private PrivateImplementationPattern<JobFailedState>,
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobFailedState>
+ {
+ public:
+ JobFailedState(const std::tr1::shared_ptr<OutputManager> &);
+ ~JobFailedState();
+
+ const std::tr1::shared_ptr<OutputManager> output_manager() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE JobSkippedState :
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobSkippedState>
+ {
+ };
+ }
+}
+
+#endif
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 99af01e..78f9d7f 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -40,6 +40,7 @@
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/type_list.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/resolver/resolutions_by_resolvent.hh>
#include <paludis/resolver/reason.hh>
#include <paludis/resolver/sanitised_dependencies.hh>
@@ -52,6 +53,7 @@
#include <paludis/resolver/job_lists.hh>
#include <paludis/resolver/job_list.hh>
#include <paludis/resolver/job.hh>
+#include <paludis/resolver/job_state.hh>
#include <paludis/package_id.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -221,7 +223,7 @@ namespace
const ExecuteResolutionCommandLine & cmdline,
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)
+ JobActiveState & active_state)
{
Context context("When fetching for '" + stringify(*id) + "':");
@@ -285,7 +287,7 @@ namespace
if (output_manager)
{
output_manager->nothing_more_to_come();
- output_manager_goes_here = output_manager;
+ active_state.set_output_manager(output_manager);
}
done_action("fetch (" + std::string(normal_only ? "regular parts" : "extra parts") + ")", id, 0 == retcode);
@@ -300,7 +302,7 @@ namespace
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)
+ JobActiveState & active_state)
{
std::string destination_string, action_string;
switch (destination_type)
@@ -387,7 +389,7 @@ namespace
if (output_manager)
{
output_manager->nothing_more_to_come();
- output_manager_goes_here = output_manager;
+ active_state.set_output_manager(output_manager);
}
done_action(action_string, id, 0 == retcode);
@@ -399,7 +401,7 @@ namespace
const ExecuteResolutionCommandLine & cmdline,
const std::tr1::shared_ptr<const PackageID> & id,
const int x, const int y,
- std::tr1::shared_ptr<OutputManager> & output_manager_goes_here)
+ JobActiveState & active_state)
{
Context context("When removing '" + stringify(*id) + "':");
@@ -461,7 +463,7 @@ namespace
if (output_manager)
{
output_manager->nothing_more_to_come();
- output_manager_goes_here = output_manager;
+ active_state.set_output_manager(output_manager);
}
done_action("remove", id, 0 == retcode);
@@ -615,10 +617,6 @@ namespace
return failed ? 1 : 0;
}
- struct Summary
- {
- };
-
struct ExecuteOneVisitor
{
const std::tr1::shared_ptr<Environment> env;
@@ -643,16 +641,24 @@ namespace
{
++x_install;
- std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
+ const std::tr1::shared_ptr<JobActiveState> active_state(new JobActiveState);
+ install_item.set_state(active_state);
- if (! do_fetch(env, cmdline, install_item.origin_id(), x_install, y, false, output_manager_goes_here))
+ if (! do_fetch(env, cmdline, install_item.origin_id(), x_install, y, false, *active_state))
+ {
+ install_item.set_state(active_state->failed());
return 1;
+ }
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))
+ x_install, y, *active_state))
+ {
+ install_item.set_state(active_state->failed());
return 1;
+ }
+ install_item.set_state(active_state->succeeded());
return 0;
}
@@ -663,24 +669,36 @@ namespace
* means you get to change it. */
++x_install;
- std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
+ const std::tr1::shared_ptr<JobActiveState> active_state(new JobActiveState);
+ uninstall_item.set_state(active_state);
+
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))
+ if (! do_uninstall(env, cmdline, *i, x_install, y, *active_state))
+ {
+ uninstall_item.set_state(active_state->failed());
return 1;
+ }
+ uninstall_item.set_state(active_state->succeeded());
return 0;
}
int visit(FetchJob & fetch_item)
{
++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))
+ const std::tr1::shared_ptr<JobActiveState> active_state(new JobActiveState);
+ fetch_item.set_state(active_state);
+
+ if (! do_fetch(env, cmdline, fetch_item.origin_id(), x_fetch, y, true, *active_state))
+ {
+ fetch_item.set_state(active_state->failed());
return 1;
+ }
+ fetch_item.set_state(active_state->succeeded());
return 0;
}
};
@@ -688,8 +706,7 @@ namespace
int execute_executions(
const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<JobLists> & lists,
- const ExecuteResolutionCommandLine & cmdline,
- Summary &)
+ const ExecuteResolutionCommandLine & cmdline)
{
int retcode(0);
int x_fetch(0), x_install(0), y(lists->pretend_job_list()->length());
@@ -703,11 +720,13 @@ namespace
c_end(lists->execute_job_list()->end()) ;
c != c_end ; ++c)
{
- ExecuteOneVisitor execute(env, cmdline, x_fetch, x_install, y);
- retcode |= (*c)->accept_returning<int>(execute);
-
- if (0 != retcode)
- break;
+ if (0 == retcode)
+ {
+ ExecuteOneVisitor execute(env, cmdline, x_fetch, x_install, y);
+ retcode |= (*c)->accept_returning<int>(execute);
+ }
+ else
+ (*c)->set_state(make_shared_ptr(new JobSkippedState));
}
if (0 != env->perform_hook(Hook("install_all_post")
@@ -721,16 +740,20 @@ namespace
int execute_resolution_main(
const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<JobLists> & lists,
- const ExecuteResolutionCommandLine & cmdline,
- Summary & summary)
+ const ExecuteResolutionCommandLine & cmdline)
{
+ for (JobList<ExecuteJob>::ConstIterator c(lists->execute_job_list()->begin()),
+ c_end(lists->execute_job_list()->end()) ;
+ c != c_end ; ++c)
+ (*c)->set_state(make_shared_ptr(new JobPendingState));
+
int retcode(0);
retcode |= execute_pretends(env, lists, cmdline);
if (0 != retcode || cmdline.a_pretend.specified())
return retcode;
- retcode |= execute_executions(env, lists, cmdline, summary);
+ retcode |= execute_executions(env, lists, cmdline);
if (0 != retcode)
return retcode;
@@ -740,11 +763,98 @@ namespace
return retcode;
}
+ struct SummaryNameVisitor
+ {
+ std::string visit(const FetchJob & j) const
+ {
+ return "fetch " + stringify(*j.origin_id());
+ }
+
+ std::string visit(const InstallJob & j) const
+ {
+ return "install " + stringify(*j.origin_id()) + " to " + stringify(j.destination_repository_name());
+ }
+
+ std::string visit(const UninstallJob & j) const
+ {
+ return "uninstall " + join(indirect_iterator(j.ids_to_remove()->begin()), indirect_iterator(j.ids_to_remove()->end()), ", ");
+ }
+
+ };
+
+ struct SummaryDisplayer
+ {
+ const std::tr1::shared_ptr<const ExecuteJob> job;
+ const bool something_failed;
+ bool & done_heading;
+
+ SummaryDisplayer(const std::tr1::shared_ptr<const ExecuteJob> & j, const bool s, bool & b) :
+ job(j),
+ something_failed(s),
+ done_heading(b)
+ {
+ }
+
+ void need_heading() const
+ {
+ if (! done_heading)
+ {
+ done_heading = true;
+ cout << endl << c::bold_blue() << "Summary:" << c::normal() << endl << endl;
+ }
+ }
+
+ void visit(const JobActiveState &) const
+ {
+ need_heading();
+ cout << c::bold_yellow() << "pending: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ }
+
+ void visit(const JobPendingState &) const
+ {
+ need_heading();
+ cout << c::bold_yellow() << "pending: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ }
+
+ void visit(const JobSucceededState & s) const
+ {
+ if ((s.output_manager() && s.output_manager()->want_to_flush())
+ || (something_failed && ! simple_visitor_cast<const FetchJob>(*job)))
+ {
+ need_heading();
+ cout << c::bold_green() << "succeeded: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ }
+ }
+
+ void visit(const JobFailedState &) const
+ {
+ need_heading();
+ cout << c::bold_red() << "failed: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ }
+
+ void visit(const JobSkippedState &) const
+ {
+ if (! simple_visitor_cast<const FetchJob>(*job))
+ {
+ need_heading();
+ cout << c::bold_yellow() << "skipped: " << job->accept_returning<std::string>(SummaryNameVisitor()) << c::normal() << endl;
+ }
+ }
+ };
+
void display_summary(
- const std::tr1::shared_ptr<JobLists> &,
- Summary &,
- const bool)
+ const std::tr1::shared_ptr<JobLists> & lists,
+ const bool something_failed)
{
+ bool done_heading(false);
+
+ for (JobList<ExecuteJob>::ConstIterator c(lists->execute_job_list()->begin()),
+ c_end(lists->execute_job_list()->end()) ;
+ c != c_end ; ++c)
+ {
+ (*c)->state()->accept(SummaryDisplayer(*c, something_failed, done_heading));
+ (*c)->set_state(make_null_shared_ptr());
+ }
}
int execute_resolution(
@@ -760,15 +870,13 @@ namespace
).max_exit_status())
throw ActionAbortedError("Aborted by hook");
- Summary summary;
-
try
{
- retcode = execute_resolution_main(env, lists, cmdline, summary);
+ retcode = execute_resolution_main(env, lists, cmdline);
}
catch (...)
{
- display_summary(lists, summary, 0 != retcode);
+ display_summary(lists, 0 != retcode);
if (0 != env->perform_hook(Hook("install_task_execute_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
@@ -779,7 +887,7 @@ namespace
throw;
}
- display_summary(lists, summary, 0 != retcode);
+ display_summary(lists, 0 != retcode);
if (0 != env->perform_hook(Hook("install_task_execute_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))