aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-03 18:57:52 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-03 18:57:52 +0100
commit1819f770003b2d5bb99d1499de54b473fa96b879 (patch)
tree2422dd764976a9895d528d5f6e8c09d2414bef88
parent6b447b15064e6b7786e99c5da174b3a3793341c9 (diff)
downloadpaludis-1819f770003b2d5bb99d1499de54b473fa96b879.tar.gz
paludis-1819f770003b2d5bb99d1499de54b473fa96b879.tar.xz
restarts
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/resolver.cc7
-rw-r--r--paludis/resolver/suggest_restart-fwd.hh31
-rw-r--r--paludis/resolver/suggest_restart.cc108
-rw-r--r--paludis/resolver/suggest_restart.hh62
-rw-r--r--src/clients/cave/cmd_resolve.cc17
6 files changed, 217 insertions, 10 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 65a723c..eb1e946 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -25,6 +25,7 @@ noinst_HEADERS = \
resolver.hh resolver-fwd.hh \
resolver_functions.hh resolver_functions-fwd.hh \
sanitised_dependencies.hh sanitised_dependencies-fwd.hh \
+ suggest_restart.hh suggest_restart-fwd.hh \
use_installed.hh use_installed-fwd.hh use_installed-se.hh
libpaludisresolver_a_SOURCES = \
@@ -38,6 +39,7 @@ libpaludisresolver_a_SOURCES = \
resolution.cc \
resolver.cc \
sanitised_dependencies.cc \
+ suggest_restart.cc \
use_installed.cc
TESTS_ENVIRONMENT = env PALUDIS_OPTIONS="" \
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index ea4ff03..886b8cc 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -27,6 +27,7 @@
#include <paludis/resolver/decision.hh>
#include <paludis/resolver/destinations.hh>
#include <paludis/resolver/resolver_functions.hh>
+#include <paludis/resolver/suggest_restart.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/log.hh>
@@ -949,11 +950,7 @@ Resolver::_suggest_restart_with(const QPN_S & qpn_s,
const std::tr1::shared_ptr<const Constraint> & constraint,
const std::tr1::shared_ptr<const Decision> & decision) const
{
- std::cout << "Suggesting a restart: for " << qpn_s << ", we originally decided " << *resolution
- << ", but new constraint " << *constraint << " means we want " << *decision << " instead" << std::endl;
-
- // throw SuggestRestart(qpn_s, _make_constraint_for_preloading(decision));
- throw InternalError(PALUDIS_HERE, "need a restart");
+ throw SuggestRestart(qpn_s, resolution->decision(), constraint, decision, _make_constraint_for_preloading(decision));
}
const std::tr1::shared_ptr<const Constraint>
diff --git a/paludis/resolver/suggest_restart-fwd.hh b/paludis/resolver/suggest_restart-fwd.hh
new file mode 100644
index 0000000..d63f2b5
--- /dev/null
+++ b/paludis/resolver/suggest_restart-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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_SUGGEST_RESTART_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_SUGGEST_RESTART_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct SuggestRestart;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/suggest_restart.cc b/paludis/resolver/suggest_restart.cc
new file mode 100644
index 0000000..b25437f
--- /dev/null
+++ b/paludis/resolver/suggest_restart.cc
@@ -0,0 +1,108 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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/suggest_restart.hh>
+#include <paludis/resolver/qpn_s.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/stringify.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<SuggestRestart>
+ {
+ const QPN_S qpn_s;
+ const std::tr1::shared_ptr<const Decision> previous_decision;
+ const std::tr1::shared_ptr<const Constraint> problematic_constraint;
+ const std::tr1::shared_ptr<const Decision> new_decision;
+ const std::tr1::shared_ptr<const Constraint> suggested_preset;
+
+ Implementation(const QPN_S & q,
+ const std::tr1::shared_ptr<const Decision> & pd,
+ const std::tr1::shared_ptr<const Constraint> & pc,
+ const std::tr1::shared_ptr<const Decision> & nd,
+ const std::tr1::shared_ptr<const Constraint> & nc
+ ) :
+ qpn_s(q),
+ previous_decision(pd),
+ problematic_constraint(pc),
+ new_decision(nd),
+ suggested_preset(nc)
+ {
+ }
+ };
+}
+
+SuggestRestart::SuggestRestart(const QPN_S & q,
+ const std::tr1::shared_ptr<const Decision> & pd,
+ const std::tr1::shared_ptr<const Constraint> & pc,
+ const std::tr1::shared_ptr<const Decision> & nd,
+ const std::tr1::shared_ptr<const Constraint> & nc
+ ) throw () :
+ PrivateImplementationPattern<SuggestRestart>(new Implementation<SuggestRestart>(q, pd, pc, nd, nc)),
+ Exception("Suggesting restart with " + stringify(*nc) + " for " + stringify(q))
+{
+}
+
+SuggestRestart::SuggestRestart(const SuggestRestart & o) :
+ PrivateImplementationPattern<SuggestRestart>(new Implementation<SuggestRestart>(o.qpn_s(), o.previous_decision(), o.problematic_constraint(),
+ o.new_decision(), o.suggested_preset())),
+ Exception(o)
+{
+}
+
+SuggestRestart::~SuggestRestart() throw ()
+{
+}
+
+const QPN_S
+SuggestRestart::qpn_s() const
+{
+ return _imp->qpn_s;
+}
+
+const std::tr1::shared_ptr<const Decision>
+SuggestRestart::previous_decision() const
+{
+ return _imp->previous_decision;
+}
+
+const std::tr1::shared_ptr<const Constraint>
+SuggestRestart::problematic_constraint() const
+{
+ return _imp->problematic_constraint;
+}
+
+const std::tr1::shared_ptr<const Decision>
+SuggestRestart::new_decision() const
+{
+ return _imp->new_decision;
+}
+
+const std::tr1::shared_ptr<const Constraint>
+SuggestRestart::suggested_preset() const
+{
+ return _imp->suggested_preset;
+}
+
+template class PrivateImplementationPattern<SuggestRestart>;
+
diff --git a/paludis/resolver/suggest_restart.hh b/paludis/resolver/suggest_restart.hh
new file mode 100644
index 0000000..fe88781
--- /dev/null
+++ b/paludis/resolver/suggest_restart.hh
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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_SUGGEST_RESTART_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_SUGGEST_RESTART_HH 1
+
+#include <paludis/resolver/suggest_restart-fwd.hh>
+#include <paludis/resolver/qpn_s-fwd.hh>
+#include <paludis/resolver/constraint-fwd.hh>
+#include <paludis/resolver/decision-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE SuggestRestart :
+ private PrivateImplementationPattern<SuggestRestart>,
+ public Exception
+ {
+ public:
+ SuggestRestart(
+ const QPN_S &,
+ const std::tr1::shared_ptr<const Decision> & previous_decision,
+ const std::tr1::shared_ptr<const Constraint> & problematic_constraint,
+ const std::tr1::shared_ptr<const Decision> & new_decision,
+ const std::tr1::shared_ptr<const Constraint> & suggested_preset) throw ();
+ SuggestRestart(const SuggestRestart &);
+ ~SuggestRestart() throw ();
+
+ const QPN_S qpn_s() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Decision> previous_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Constraint> problematic_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Decision> new_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Constraint> suggested_preset() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+ }
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<resolver::SuggestRestart>;
+#endif
+}
+
+#endif
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 3f78048..bac5aa2 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -32,6 +32,8 @@
#include <paludis/resolver/decision.hh>
#include <paludis/resolver/resolver_functions.hh>
#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/suggest_restart.hh>
+#include <paludis/resolver/qpn_s.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -232,7 +234,7 @@ namespace
a_reinstall_targets(&g_reinstall_options, "reinstall-targets", 'R',
"Select whether to reinstall target packages",
args::EnumArg::EnumArgOptions
- ("auto", 'x', "If the target is a set, if-necessary, otherwise always")
+ ("auto", 'x', "If the target is a set, if-same, otherwise always")
("always", 'a', "Always")
("unless-transient", 't', "Unless the target is transient (e.g. from 'importare')"
" (default if --everything)")
@@ -478,7 +480,7 @@ namespace
UseInstalled use_installed_from_cmdline(const args::EnumArg & a, const bool is_set)
{
if (a.argument() == "auto")
- return is_set ? ui_if_possible : ui_never;
+ return is_set ? ui_if_same : ui_never;
else if (a.argument() == "always")
return ui_never;
else if (a.argument() == "unless-transient")
@@ -575,10 +577,15 @@ ResolveCommand::run(
resolver->resolve();
break;
}
- catch (...)
+ catch (const SuggestRestart & e)
{
- /* handle restarts etc */
- throw;
+ std::cout << "Restarting: for '" << e.qpn_s() << "' we had chosen '" << *e.previous_decision()
+ << "' but new constraint '" << *e.problematic_constraint() << "' means we now want '"
+ << *e.new_decision() << "' instead" << std::endl;
+ std::tr1::shared_ptr<Resolver> new_resolver(new Resolver(env.get(), resolver_functions));
+ new_resolver->copy_initial_constraints_from(*resolver);
+ new_resolver->add_initial_constraint(e.qpn_s(), e.suggested_preset());
+ resolver = new_resolver;
}
}