aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-02 21:01:39 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-02 21:01:39 +0100
commit0e4fa17d2ac232fdbf223444deea974eb561f21c (patch)
treec63f082171bbdef00468bff199297c78c51be8a2
parentf2792e0e32498fe3c2369c3becdb0078fc2b5ee9 (diff)
downloadpaludis-0e4fa17d2ac232fdbf223444deea974eb561f21c.tar.gz
paludis-0e4fa17d2ac232fdbf223444deea974eb561f21c.tar.xz
cave display-resolution
-rw-r--r--paludis/resolver/resolution.cc2
-rw-r--r--paludis/resolver/resolution.hh3
-rw-r--r--paludis/resolver/resolutions-fwd.hh1
-rw-r--r--paludis/resolver/resolutions.cc20
-rw-r--r--paludis/resolver/resolutions.hh17
-rw-r--r--paludis/resolver/resolver.cc23
-rw-r--r--paludis/resolver/resolver.hh2
-rw-r--r--src/clients/cave/Makefile.am4
-rw-r--r--src/clients/cave/cave.cc9
-rw-r--r--src/clients/cave/cmd_display_resolution.cc491
-rw-r--r--src/clients/cave/cmd_display_resolution.hh (renamed from src/clients/cave/cmd_resolve_display_explanations.hh)25
-rw-r--r--src/clients/cave/cmd_resolve.cc44
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc17
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh8
-rw-r--r--src/clients/cave/cmd_resolve_display_explanations.cc157
-rw-r--r--src/clients/cave/cmd_resolve_display_resolution.cc286
-rw-r--r--src/clients/cave/cmd_resolve_display_resolution.hh38
-rw-r--r--src/clients/cave/cmd_resolve_dump.cc4
-rw-r--r--src/clients/cave/command_factory.cc2
19 files changed, 627 insertions, 526 deletions
diff --git a/paludis/resolver/resolution.cc b/paludis/resolver/resolution.cc
index 3e70938..419ccd5 100644
--- a/paludis/resolver/resolution.cc
+++ b/paludis/resolver/resolution.cc
@@ -58,6 +58,7 @@ Resolution::serialise(Serialiser & s) const
.member(SerialiserFlags<>(), "constraints", *constraints())
.member(SerialiserFlags<serialise::might_be_null>(), "decision", decision())
.member(SerialiserFlags<serialise::might_be_null>(), "destinations", destinations())
+ .member(SerialiserFlags<>(), "qpn_s", qpn_s())
;
}
@@ -77,6 +78,7 @@ Resolution::deserialise(Deserialisation & d)
value_for<n::constraints>(v.member<std::tr1::shared_ptr<Constraints> >("constraints")),
value_for<n::decision>(v.member<std::tr1::shared_ptr<Decision> >("decision")),
value_for<n::destinations>(v.member<std::tr1::shared_ptr<Destinations> >("destinations")),
+ value_for<n::qpn_s>(v.member<QPN_S>("qpn_s")),
value_for<n::sanitised_dependencies>(make_null_shared_ptr())
)));
}
diff --git a/paludis/resolver/resolution.hh b/paludis/resolver/resolution.hh
index d7d9307..59abe1e 100644
--- a/paludis/resolver/resolution.hh
+++ b/paludis/resolver/resolution.hh
@@ -26,6 +26,7 @@
#include <paludis/resolver/decision-fwd.hh>
#include <paludis/resolver/destinations-fwd.hh>
#include <paludis/resolver/sanitised_dependencies-fwd.hh>
+#include <paludis/resolver/qpn_s.hh>
#include <paludis/util/named_value.hh>
#include <tr1/memory>
@@ -38,6 +39,7 @@ namespace paludis
struct constraints;
struct decision;
struct destinations;
+ struct qpn_s;
struct sanitised_dependencies;
}
@@ -50,6 +52,7 @@ namespace paludis
NamedValue<n::constraints, std::tr1::shared_ptr<Constraints> > constraints;
NamedValue<n::decision, std::tr1::shared_ptr<Decision> > decision;
NamedValue<n::destinations, std::tr1::shared_ptr<Destinations> > destinations;
+ NamedValue<n::qpn_s, QPN_S> qpn_s;
NamedValue<n::sanitised_dependencies, std::tr1::shared_ptr<SanitisedDependencies> > sanitised_dependencies;
void serialise(Serialiser &) const;
diff --git a/paludis/resolver/resolutions-fwd.hh b/paludis/resolver/resolutions-fwd.hh
index 4fb6dfe..715c1d1 100644
--- a/paludis/resolver/resolutions-fwd.hh
+++ b/paludis/resolver/resolutions-fwd.hh
@@ -27,6 +27,7 @@ namespace paludis
{
namespace resolver
{
+ struct ResolutionLists;
struct Resolutions;
}
}
diff --git a/paludis/resolver/resolutions.cc b/paludis/resolver/resolutions.cc
index afb7f69..c0c2af1 100644
--- a/paludis/resolver/resolutions.cc
+++ b/paludis/resolver/resolutions.cc
@@ -24,6 +24,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/sequence-impl.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/make_named_values.hh>
using namespace paludis;
using namespace paludis::resolver;
@@ -83,6 +84,25 @@ Resolutions::deserialise(Deserialisation & d)
return result;
}
+void
+ResolutionLists::serialise(Serialiser & s) const
+{
+ s.object("ResolutionLists")
+ .member(SerialiserFlags<serialise::might_be_null>(), "all", all())
+ .member(SerialiserFlags<serialise::might_be_null>(), "ordered", ordered())
+ ;
+}
+
+ResolutionLists
+ResolutionLists::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "ResolutionLists");
+ return make_named_values<ResolutionLists>(
+ value_for<n::all>(v.member<std::tr1::shared_ptr<Resolutions> >("all")),
+ value_for<n::ordered>(v.member<std::tr1::shared_ptr<Resolutions> >("ordered"))
+ );
+}
+
template class PrivateImplementationPattern<Resolutions>;
template class WrappedForwardIterator<Resolutions::ConstIteratorTag, const std::tr1::shared_ptr<const Resolution> >;
diff --git a/paludis/resolver/resolutions.hh b/paludis/resolver/resolutions.hh
index 1b246f4..c57c4c8 100644
--- a/paludis/resolver/resolutions.hh
+++ b/paludis/resolver/resolutions.hh
@@ -25,12 +25,29 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/named_value.hh>
#include <tr1/memory>
namespace paludis
{
+ namespace n
+ {
+ struct all;
+ struct ordered;
+ }
+
namespace resolver
{
+ struct ResolutionLists
+ {
+ NamedValue<n::all, std::tr1::shared_ptr<Resolutions> > all;
+ NamedValue<n::ordered, std::tr1::shared_ptr<Resolutions> > ordered;
+
+ void serialise(Serialiser &) const;
+ static ResolutionLists deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
class PALUDIS_VISIBLE Resolutions :
private PrivateImplementationPattern<Resolutions>
{
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 0313bc4..0f42e4d 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -71,12 +71,16 @@ namespace paludis
const ResolverFunctions fns;
ResolutionsByQPN_SMap resolutions_by_qpn_s;
- std::tr1::shared_ptr<Resolutions> resolutions;
+
+ std::tr1::shared_ptr<ResolutionLists> resolution_lists;
Implementation(const Environment * const e, const ResolverFunctions & f) :
env(e),
fns(f),
- resolutions(new Resolutions)
+ resolution_lists(new ResolutionLists(make_named_values<ResolutionLists>(
+ value_for<n::all>(new Resolutions),
+ value_for<n::ordered>(new Resolutions)
+ )))
{
}
};
@@ -316,6 +320,7 @@ Resolver::_create_resolution_for_qpn_s(const QPN_S & qpn_s) const
value_for<n::constraints>(_initial_constraints_for(qpn_s)),
value_for<n::decision>(make_null_shared_ptr()),
value_for<n::destinations>(make_null_shared_ptr()),
+ value_for<n::qpn_s>(qpn_s),
value_for<n::sanitised_dependencies>(make_null_shared_ptr())
)));
}
@@ -327,7 +332,11 @@ Resolver::_resolution_for_qpn_s(const QPN_S & qpn_s, const bool create)
if (_imp->resolutions_by_qpn_s.end() == i)
{
if (create)
- i = _imp->resolutions_by_qpn_s.insert(std::make_pair(qpn_s, _create_resolution_for_qpn_s(qpn_s))).first;
+ {
+ std::tr1::shared_ptr<Resolution> resolution(_create_resolution_for_qpn_s(qpn_s));
+ i = _imp->resolutions_by_qpn_s.insert(std::make_pair(qpn_s, resolution)).first;
+ _imp->resolution_lists->all()->append(resolution);
+ }
else
throw InternalError(PALUDIS_HERE, "doesn't exist");
}
@@ -806,7 +815,7 @@ Resolver::_can_order_now(const QPN_S &, const std::tr1::shared_ptr<const Resolut
void
Resolver::_do_order(const QPN_S &, const std::tr1::shared_ptr<Resolution> & resolution)
{
- _imp->resolutions->append(resolution);
+ _imp->resolution_lists->ordered()->append(resolution);
resolution->already_ordered() = true;
}
@@ -1310,10 +1319,10 @@ Resolver::_find_id_for_from(
return std::make_pair(make_null_shared_ptr(), false);
}
-const std::tr1::shared_ptr<const Resolutions>
-Resolver::resolutions() const
+const std::tr1::shared_ptr<const ResolutionLists>
+Resolver::resolution_lists() const
{
- return _imp->resolutions;
+ return _imp->resolution_lists;
}
template class WrappedForwardIterator<Resolver::ResolutionsByQPN_SConstIteratorTag,
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index f32cbef..3d1ac0d 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -155,7 +155,7 @@ namespace paludis
void resolve();
- const std::tr1::shared_ptr<const Resolutions> resolutions() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const ResolutionLists> resolution_lists() const PALUDIS_ATTRIBUTE((warn_unused_result));
struct ResolutionsByQPN_SConstIteratorTag;
typedef WrappedForwardIterator<ResolutionsByQPN_SConstIteratorTag,
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index 6d581c5..55458b5 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -16,6 +16,7 @@ bin_PROGRAMS = cave
noinst_PROGRAMS = man-cave
command_MANS = \
+ cave-display-resolution.1 \
cave-help.1 \
cave-perform.1 \
cave-print-categories.1 \
@@ -77,6 +78,7 @@ libcave_a_SOURCES = \
command_line.cc command_line.hh \
command_command_line.cc command_command_line.hh \
command_factory.cc command_factory.hh \
+ cmd_display_resolution.cc cmd_display_resolution.hh \
cmd_help.cc cmd_help.hh \
cmd_perform.cc cmd_perform.hh \
cmd_print_categories.cc cmd_print_categories.hh \
@@ -95,8 +97,6 @@ libcave_a_SOURCES = \
cmd_resolve.cc cmd_resolve.hh \
cmd_resolve_cmdline.cc cmd_resolve_cmdline.hh \
cmd_resolve_display_callback.cc cmd_resolve_display_callback.hh \
- cmd_resolve_display_explanations.cc cmd_resolve_display_explanations.hh \
- cmd_resolve_display_resolution.cc cmd_resolve_display_resolution.hh \
cmd_resolve_dump.cc cmd_resolve_dump.hh \
cmd_show.cc cmd_show.hh \
cmd_sync.cc cmd_sync.hh \
diff --git a/src/clients/cave/cave.cc b/src/clients/cave/cave.cc
index 090857e..f406b0f 100644
--- a/src/clients/cave/cave.cc
+++ b/src/clients/cave/cave.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 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
@@ -48,6 +48,13 @@ int main(int argc, char * argv[])
if (cmdline.begin_parameters() == cmdline.end_parameters())
throw args::DoHelp();
+ std::string cave_var(argv[0]);
+ if (cmdline.a_environment.specified())
+ cave_var = cave_var + " --" + cmdline.a_environment.long_name() + " " + cmdline.a_environment.argument();
+ if (cmdline.a_log_level.specified())
+ cave_var = cave_var + " --" + cmdline.a_log_level.long_name() + " " + cmdline.a_log_level.argument();
+ setenv("CAVE", cave_var.c_str(), 1);
+
Log::get_instance()->set_program_name(argv[0]);
Log::get_instance()->set_log_level(cmdline.a_log_level.option());
std::tr1::shared_ptr<Environment> env(EnvironmentFactory::get_instance()->create(cmdline.a_environment.argument()));
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
new file mode 100644
index 0000000..271f346
--- /dev/null
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -0,0 +1,491 @@
+/* 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 "cmd_display_resolution.hh"
+#include "cmd_resolve_cmdline.hh"
+#include "exceptions.hh"
+#include "command_command_line.hh"
+#include "formats.hh"
+#include "colour_formatter.hh"
+#include <paludis/args/do_help.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/destringify.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/iterator_funcs.hh>
+#include <paludis/util/options.hh>
+#include <paludis/resolver/resolutions.hh>
+#include <paludis/resolver/serialise.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/sanitised_dependencies.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/destinations.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolver.hh>
+#include <paludis/resolver/qpn_s.hh>
+#include <paludis/package_id.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/choice.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/match_package.hh>
+
+#include <set>
+#include <iterator>
+#include <iostream>
+#include <cstdlib>
+
+using namespace paludis;
+using namespace cave;
+using namespace paludis::resolver;
+
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct DisplayResolutionCommandLine :
+ CaveCommandCommandLine
+ {
+ ResolveCommandLineDisplayOptions display_options;
+
+ DisplayResolutionCommandLine() :
+ display_options(this)
+ {
+ add_environment_variable("PALUDIS_SERIALISED_RESOLUTION_FD",
+ "The file descriptor on which the serialised resolution can be found.");
+ }
+
+ virtual std::string app_name() const
+ {
+ return "cave display-resolution";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "Displays a dependency resolution created using 'cave resolve'.";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "Displays a dependency resolution created using 'cave resolve'. Mostly for "
+ "internal use; most users will not use this command directly.";
+ }
+ };
+
+ struct ReasonNameGetter
+ {
+ std::pair<std::string, bool> visit(const DependencyReason & r) const
+ {
+ if (r.sanitised_dependency().spec().if_block())
+ return std::make_pair(stringify(r.from_id()->name()) + " blocker " +
+ stringify(*r.sanitised_dependency().spec().if_block()), true);
+ else
+ return std::make_pair(stringify(r.from_id()->name()), false);
+ }
+
+ std::pair<std::string, bool> visit(const TargetReason &) const
+ {
+ return std::make_pair("target", true);
+ }
+
+ std::pair<std::string, bool> visit(const SetReason & r) const
+ {
+ std::pair<std::string, bool> rr(r.reason_for_set()->accept_returning<std::pair<std::string, bool> >(*this));
+ return std::make_pair(rr.first + " (" + stringify(r.set_name()) + ")", rr.second);
+ }
+
+ std::pair<std::string, bool> visit(const PresetReason &) const
+ {
+ return std::make_pair("", false);
+ }
+ };
+
+ void display_resolution(
+ const std::tr1::shared_ptr<Environment> &,
+ const ResolutionLists & lists,
+ const DisplayResolutionCommandLine &)
+ {
+ Context context("When displaying chosen resolution:");
+
+ cout << "These are the actions I will take, in order:" << endl << endl;
+
+ for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
+ c != c_end ; ++c)
+ {
+ const std::tr1::shared_ptr<const PackageID> id((*c)->decision()->if_package_id());
+ if (! id)
+ throw InternalError(PALUDIS_HERE, "why did that happen?");
+
+ bool is_new(false), is_upgrade(false), is_downgrade(false), is_reinstall(false);
+ std::tr1::shared_ptr<const PackageID> old_id;
+
+ if ((*c)->destinations()->slash())
+ {
+ if ((*c)->destinations()->slash()->replacing()->empty())
+ is_new = true;
+ else
+ for (PackageIDSequence::ConstIterator x((*c)->destinations()->slash()->replacing()->begin()),
+ x_end((*c)->destinations()->slash()->replacing()->end()) ;
+ x != x_end ; ++x)
+ {
+ old_id = *x;
+ if ((*x)->version() == id->version())
+ is_reinstall = true;
+ else if ((*x)->version() < id->version())
+ is_upgrade = true;
+ else if ((*x)->version() > id->version())
+ is_downgrade = true;
+ }
+
+ /* pick the worst of what it is */
+ is_upgrade = is_upgrade && (! is_reinstall) && (! is_downgrade);
+ is_reinstall = is_reinstall && (! is_downgrade);
+ }
+
+ if (is_new)
+ cout << "[n] " << c::bold_blue() << id->canonical_form(idcf_no_version);
+ else if (is_upgrade)
+ cout << "[u] " << c::blue() << id->canonical_form(idcf_no_version);
+ else if (is_reinstall)
+ cout << "[r] " << c::yellow() << id->canonical_form(idcf_no_version);
+ else if (is_downgrade)
+ cout << "[d] " << c::bold_yellow() << id->canonical_form(idcf_no_version);
+ else
+ throw InternalError(PALUDIS_HERE, "why did that happen?");
+
+ cout << c::normal() << " " << id->canonical_form(idcf_version);
+
+ if ((*c)->destinations()->slash())
+ {
+ cout << " to ::" << (*c)->destinations()->slash()->repository();
+ if (! (*c)->destinations()->slash()->replacing()->empty())
+ {
+ cout << " replacing";
+ for (PackageIDSequence::ConstIterator x((*c)->destinations()->slash()->replacing()->begin()),
+ x_end((*c)->destinations()->slash()->replacing()->end()) ;
+ x != x_end ; ++x)
+ cout << " " << (*x)->canonical_form(idcf_version);
+ }
+ }
+
+ cout << endl;
+
+ if (id->choices_key())
+ {
+ ColourFormatter formatter(0);
+
+ std::tr1::shared_ptr<const Choices> old_choices;
+ if (old_id && old_id->choices_key())
+ old_choices = old_id->choices_key()->value();
+
+ bool non_blank_prefix(false);
+ std::string s;
+ for (Choices::ConstIterator k(id->choices_key()->value()->begin()),
+ k_end(id->choices_key()->value()->end()) ;
+ k != k_end ; ++k)
+ {
+ if ((*k)->hidden())
+ continue;
+
+ bool shown_prefix(false);
+ for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! (*i)->explicitly_listed())
+ continue;
+
+ if (! shown_prefix)
+ {
+ if (non_blank_prefix || ! (*k)->show_with_no_prefix())
+ {
+ shown_prefix = true;
+ if (! s.empty())
+ s.append(" ");
+ s.append((*k)->raw_name() + ":");
+ }
+ }
+
+ if (! s.empty())
+ s.append(" ");
+
+ std::string t;
+ if ((*i)->enabled())
+ {
+ if ((*i)->locked())
+ t = formatter.format(**i, format::Forced());
+ else
+ t = formatter.format(**i, format::Enabled());
+ }
+ else
+ {
+ if ((*i)->locked())
+ t = formatter.format(**i, format::Masked());
+ else
+ t = formatter.format(**i, format::Disabled());
+ }
+
+ bool changed(false), added(false);
+ if ((*k)->consider_added_or_changed())
+ {
+ if (old_choices)
+ {
+ std::tr1::shared_ptr<const ChoiceValue> old_choice(
+ old_choices->find_by_name_with_prefix((*i)->name_with_prefix()));
+ if (! old_choice)
+ added = true;
+ else if (old_choice->enabled() != (*i)->enabled())
+ changed = true;
+ }
+ else
+ added = true;
+ }
+
+ if (changed)
+ {
+ t = formatter.decorate(**i, t, format::Changed());
+ }
+ else if (added)
+ {
+ if (old_id)
+ t = formatter.decorate(**i, t, format::Added());
+ }
+
+ s.append(t);
+ }
+ }
+
+ if (s.empty())
+ break;
+
+ cout << " " << s << endl;
+ }
+
+ if (id->short_description_key())
+ cout << " \"" << id->short_description_key()->value() << "\"" << endl;
+
+ std::set<std::string> reason_names, special_reason_names;
+ for (Constraints::ConstIterator r((*c)->constraints()->begin()),
+ r_end((*c)->constraints()->end()) ;
+ r != r_end ; ++r)
+ {
+ ReasonNameGetter g;
+ std::pair<std::string, bool> s((*r)->reason()->accept_returning<std::pair<std::string, bool> >(g));
+ if (! s.first.empty())
+ {
+ if (s.second)
+ special_reason_names.insert(s.first);
+ else
+ reason_names.insert(s.first);
+ }
+ }
+
+ if ((! special_reason_names.empty()) || (! reason_names.empty()))
+ {
+ cout << " Because of ";
+
+ if (! special_reason_names.empty())
+ cout << c::bold_yellow() << join(special_reason_names.begin(), special_reason_names.end(), ", ")
+ << c::normal();
+
+ if (! reason_names.empty())
+ {
+ if (! special_reason_names.empty())
+ cout << ", ";
+
+ if (reason_names.size() > 4)
+ cout << join(reason_names.begin(), next(reason_names.begin(), 3), ", ")
+ << ", " << (reason_names.size() - 3) << " more";
+ else
+ cout << join(reason_names.begin(), reason_names.end(), ", ");
+ }
+
+ if ((! (*c)->decision()->is_best()) && (! (*c)->decision()->is_nothing())
+ && (! (*c)->decision()->is_installed()))
+ cout << c::bold_red() << " which prevented selection of the best candidate" << c::normal();
+
+ cout << endl;
+ }
+ }
+
+ cout << endl;
+ }
+
+ struct ReasonDisplayer
+ {
+ void visit(const TargetReason &)
+ {
+ std::cout << "it is a target";
+ }
+
+ void visit(const DependencyReason & reason)
+ {
+ std::cout << "of dependency " << reason.sanitised_dependency() << " from " << *reason.from_id();
+ }
+
+ void visit(const PresetReason &)
+ {
+ std::cout << "of a preset";
+ }
+
+ void visit(const SetReason & reason)
+ {
+ std::cout << "of set " << reason.set_name() << ", which is because ";
+ reason.reason_for_set()->accept(*this);
+ }
+ };
+
+ void display_explanations(
+ const std::tr1::shared_ptr<Environment> & env,
+ const ResolutionLists & lists,
+ const DisplayResolutionCommandLine & cmdline)
+ {
+ Context context("When displaying explanations:");
+
+ if (cmdline.display_options.a_explain.begin_args() == cmdline.display_options.a_explain.end_args())
+ return;
+
+ std::cout << "Explaining requested decisions:" << std::endl << std::endl;
+
+ for (args::StringSetArg::ConstIterator i(cmdline.display_options.a_explain.begin_args()),
+ i_end(cmdline.display_options.a_explain.end_args()) ;
+ i != i_end ; ++i)
+ {
+ bool any(false);
+ PackageDepSpec spec(parse_user_package_dep_spec(*i, env.get(), UserPackageDepSpecOptions() + updso_allow_wildcards));
+ for (Resolutions::ConstIterator r(lists.all()->begin()), r_end(lists.all()->end()) ;
+ r != r_end ; ++r)
+ {
+ if (! (*r)->decision()->if_package_id())
+ {
+ /* really we want this to work for simple cat/pkg and
+ * cat/pkg:slot specs anyway, even if we chose nothing */
+ continue;
+ }
+
+ if (! match_package(*env, spec, *(*r)->decision()->if_package_id(), MatchPackageOptions()))
+ continue;
+
+ any = true;
+
+ std::cout << "For " << (*r)->qpn_s() << ":" << std::endl;
+ std::cout << " The following constraints were in action:" << std::endl;
+ for (Constraints::ConstIterator c((*r)->constraints()->begin()),
+ c_end((*r)->constraints()->end()) ;
+ c != c_end ; ++c)
+ {
+ std::cout << " * " << (*c)->spec();
+
+ switch ((*c)->use_installed())
+ {
+ case ui_if_same:
+ std::cout << ", use installed if same";
+ break;
+ case ui_never:
+ std::cout << ", never using installed";
+ break;
+ case ui_only_if_transient:
+ std::cout << ", using installed only if transient";
+ break;
+ case ui_if_same_version:
+ std::cout << ", use installed if same version";
+ break;
+ case ui_if_possible:
+ std::cout << ", use installed if possible";
+ break;
+
+ case last_ui:
+ break;
+ }
+
+ if ((*c)->to_destination_slash())
+ std::cout << ", installing to /";
+
+ std::cout << std::endl;
+ std::cout << " because ";
+ ReasonDisplayer v;
+ (*c)->reason()->accept(v);
+ std::cout << std::endl;
+ }
+ std::cout << " The decision made was:" << std::endl;
+ std::cout << " Use " << *(*r)->decision()->if_package_id() << std::endl;
+ if ((*r)->destinations()->slash())
+ {
+ std::cout << " Install to / using repository " << (*r)->destinations()->slash()->repository() << std::endl;
+ if (! (*r)->destinations()->slash()->replacing()->empty())
+ for (PackageIDSequence::ConstIterator x((*r)->destinations()->slash()->replacing()->begin()),
+ x_end((*r)->destinations()->slash()->replacing()->end()) ;
+ x != x_end ; ++x)
+ std::cout << " Replacing " << **x << std::endl;
+ }
+ std::cout << std::endl;
+ }
+
+ if (! any)
+ throw args::DoHelp("There is nothing matching '" + *i + "' in the resolution set.");
+ }
+ }
+}
+
+bool
+DisplayResolutionCommand::important() const
+{
+ return false;
+}
+
+int
+DisplayResolutionCommand::run(
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ )
+{
+ DisplayResolutionCommandLine cmdline;
+ cmdline.run(args, "CAVE", "CAVE_DISPLAY_RESOLUTION_OPTIONS", "CAVE_DISPLAY_RESOLUTION_CMDLINE");
+
+ if (cmdline.a_help.specified())
+ {
+ cout << cmdline;
+ return EXIT_SUCCESS;
+ }
+
+ if (getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "").empty())
+ throw args::DoHelp("PALUDIS_SERIALISED_RESOLUTION_FD must be provided");
+
+ int fd(destringify<int>(getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "")));
+ SafeIFStream deser_stream(fd);
+ const std::string deser_str((std::istreambuf_iterator<char>(deser_stream)), std::istreambuf_iterator<char>());
+ Deserialiser deserialiser(env.get(), deser_str);
+ Deserialisation deserialisation("ResolutionLists", deserialiser);
+ ResolutionLists lists(ResolutionLists::deserialise(deserialisation));
+
+ display_resolution(env, lists, cmdline);
+ display_explanations(env, lists, cmdline);
+
+ return 0;
+}
+
+std::tr1::shared_ptr<args::ArgsHandler>
+DisplayResolutionCommand::make_doc_cmdline()
+{
+ return make_shared_ptr(new DisplayResolutionCommandLine);
+}
+
diff --git a/src/clients/cave/cmd_resolve_display_explanations.hh b/src/clients/cave/cmd_display_resolution.hh
index 0166f74..4d6c3be 100644
--- a/src/clients/cave/cmd_resolve_display_explanations.hh
+++ b/src/clients/cave/cmd_display_resolution.hh
@@ -17,21 +17,28 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_EXPLANATIONS_HH
-#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_EXPLANATIONS_HH 1
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_DISPLAY_RESOLUTION_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_DISPLAY_RESOLUTION_HH 1
-#include <paludis/environment-fwd.hh>
-#include <paludis/resolver/resolver-fwd.hh>
-#include "cmd_resolve_cmdline.hh"
+#include "command.hh"
namespace paludis
{
namespace cave
{
- void display_explanations(
- const std::tr1::shared_ptr<Environment> & env,
- const std::tr1::shared_ptr<resolver::Resolver> & resolver,
- const ResolveCommandLine & cmdline);
+ class PALUDIS_VISIBLE DisplayResolutionCommand :
+ public Command
+ {
+ public:
+ bool important() const;
+
+ int run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ );
+
+ std::tr1::shared_ptr<args::ArgsHandler> make_doc_cmdline();
+ };
}
}
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 0a2017d..f362951 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -20,8 +20,6 @@
#include "cmd_resolve.hh"
#include "cmd_resolve_cmdline.hh"
#include "cmd_resolve_display_callback.hh"
-#include "cmd_resolve_display_explanations.hh"
-#include "cmd_resolve_display_resolution.hh"
#include "cmd_resolve_dump.hh"
#include "exceptions.hh"
#include "command_command_line.hh"
@@ -30,6 +28,7 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/system.hh>
#include <paludis/args/do_help.hh>
#include <paludis/resolver/resolver.hh>
#include <paludis/resolver/resolution.hh>
@@ -511,6 +510,37 @@ namespace
return true;
}
+
+ int display_resolution(
+ const std::tr1::shared_ptr<Environment> &,
+ const ResolutionLists & resolution_lists,
+ const ResolveCommandLine & cmdline)
+ {
+ Context context("When displaying chosen resolution:");
+
+ std::stringstream ser_stream;
+ Serialiser ser(ser_stream);
+ resolution_lists.serialise(ser);
+
+ std::string command(cmdline.program_options.a_display_resolution_program.argument());
+ if (command.empty())
+ command = "$CAVE display-resolution";
+
+ for (args::ArgsSection::GroupsConstIterator g(cmdline.display_options.begin()), g_end(cmdline.display_options.end()) ;
+ g != g_end ; ++g)
+ {
+ for (args::ArgsGroup::ConstIterator o(g->begin()), o_end(g->end()) ;
+ o != o_end ; ++o)
+ if ((*o)->specified())
+ command = command + " " + (*o)->forwardable_string();
+ }
+
+ paludis::Command cmd(command);
+ cmd
+ .with_input_stream(&ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
+
+ return run_command(cmd);
+ }
}
@@ -620,15 +650,7 @@ ResolveCommand::run(
}
}
- std::stringstream ser;
- Serialiser s(ser);
- resolver->resolutions()->serialise(s);
-
- std::tr1::shared_ptr<Resolutions> copied_resolutions(deserialise<Resolutions>(
- env.get(), ser.str(), "Resolutions"));
-
- display_resolution(env, copied_resolutions, cmdline);
- display_explanations(env, resolver, cmdline);
+ retcode |= display_resolution(env, *resolver->resolution_lists(), cmdline);
}
catch (...)
{
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index d67b5d9..467dc59 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -164,7 +164,8 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
"Follow build dependencies for installed packages (default if --complete or --everything)", true),
a_ignore_installed_dependencies(&g_dependency_options, "ignore-installed-dependencies", 'd',
"Ignore dependencies (except compiled-against dependencies, which are already taken) "
- "for installed packages. (default if --lazy)", true)
+ "for installed packages. (default if --lazy)", true),
+
//
// g_suggestion_options(this, "Suggestion Options", "Control whether suggestions are taken. Suggestions that are "
// "already installed are instead treated as hard dependencies."),
@@ -211,6 +212,12 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
// a_create_binaries(&g_destination_options, "create-binaries", '\0', "Create binary packages", true),
// a_install_to_chroot(&g_destination_options, "install-to-chroot", '\0', "Install packages to the environment-configured chroot", true),
// a_install_to_root(&g_destination_options, "install-to-root", '\0', "Install packages to /", true),
+
+ g_dump_options(this, "Dump Options", "Dump the resolver's state to stdout after completion, or when an "
+ "error occurs. For debugging purposes; produces rather a lot of noise."),
+ a_dump(&g_dump_options, "dump", '\0', "Dump debug output", true),
+ a_dump_dependencies(&g_dump_options, "dump-dependencies", '\0', "If dumping, also dump the "
+ "sanitised dependencies selected for every package" , true)
{
}
@@ -220,13 +227,7 @@ ResolveCommandLineDisplayOptions::ResolveCommandLineDisplayOptions(args::ArgsHan
"that it made"),
a_explain(&g_explanations, "explain", '\0', "Explain why the resolver made a particular decision. The "
"argument is a package dependency specification, so --explain dev-libs/boost or --explain qt:3"
- " or even --explain '*/*' (although --dump is a better way of getting highly noisy debug output)."),
-
- g_dump_options(this, "Dump Options", "Dump the resolver's state to stdout after completion, or when an "
- "error occurs. For debugging purposes; produces rather a lot of noise."),
- a_dump(&g_dump_options, "dump", '\0', "Dump debug output", true),
- a_dump_dependencies(&g_dump_options, "dump-dependencies", '\0', "If dumping, also dump the "
- "sanitised dependencies selected for every package" , true)
+ " or even --explain '*/*' (although --dump is a better way of getting highly noisy debug output).")
{
}
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index ad5240c..5c4725c 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -94,6 +94,10 @@ namespace paludis
// args::SwitchArg a_interactive_slots;
// args::SwitchArg a_interactive_decisions;
// args::SwitchArg a_interactive_ordering;
+
+ args::ArgsGroup g_dump_options;
+ args::SwitchArg a_dump;
+ args::SwitchArg a_dump_dependencies;
};
struct ResolveCommandLineExecutionOptions :
@@ -127,10 +131,6 @@ namespace paludis
args::ArgsGroup g_explanations;
args::StringSetArg a_explain;
-
- args::ArgsGroup g_dump_options;
- args::SwitchArg a_dump;
- args::SwitchArg a_dump_dependencies;
};
struct ResolveCommandLineProgramOptions :
diff --git a/src/clients/cave/cmd_resolve_display_explanations.cc b/src/clients/cave/cmd_resolve_display_explanations.cc
deleted file mode 100644
index 7a75a53..0000000
--- a/src/clients/cave/cmd_resolve_display_explanations.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-/* 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 "cmd_resolve_display_explanations.hh"
-#include <paludis/dep_spec.hh>
-#include <paludis/user_dep_spec.hh>
-#include <paludis/match_package.hh>
-#include <paludis/resolver/resolver.hh>
-#include <paludis/resolver/qpn_s.hh>
-#include <paludis/resolver/resolution.hh>
-#include <paludis/resolver/decision.hh>
-#include <paludis/resolver/constraint.hh>
-#include <paludis/resolver/reason.hh>
-#include <paludis/resolver/destinations.hh>
-#include <paludis/args/do_help.hh>
-#include <iostream>
-
-using namespace paludis;
-using namespace cave;
-using namespace paludis::resolver;
-
-namespace
-{
- struct ReasonDisplayer
- {
- void visit(const TargetReason &)
- {
- std::cout << "it is a target";
- }
-
- void visit(const DependencyReason & reason)
- {
- std::cout << "of dependency " << reason.sanitised_dependency() << " from " << *reason.from_id();
- }
-
- void visit(const PresetReason &)
- {
- std::cout << "of a preset";
- }
-
- void visit(const SetReason & reason)
- {
- std::cout << "of set " << reason.set_name() << ", which is because ";
- reason.reason_for_set()->accept(*this);
- }
- };
-}
-
-void
-cave::display_explanations(
- const std::tr1::shared_ptr<Environment> & env,
- const std::tr1::shared_ptr<Resolver> & resolver,
- const ResolveCommandLine & cmdline)
-{
- Context context("When displaying explanations:");
-
- if (cmdline.display_options.a_explain.begin_args() == cmdline.display_options.a_explain.end_args())
- return;
-
- std::cout << "Explaining requested decisions:" << std::endl << std::endl;
-
- for (args::StringSetArg::ConstIterator i(cmdline.display_options.a_explain.begin_args()),
- i_end(cmdline.display_options.a_explain.end_args()) ;
- i != i_end ; ++i)
- {
- bool any(false);
- PackageDepSpec spec(parse_user_package_dep_spec(*i, env.get(), UserPackageDepSpecOptions() + updso_allow_wildcards));
- for (Resolver::ResolutionsByQPN_SConstIterator r(resolver->begin_resolutions_by_qpn_s()),
- r_end(resolver->end_resolutions_by_qpn_s()) ;
- r != r_end ; ++r)
- {
- if (! r->second->decision()->if_package_id())
- {
- /* really we want this to work for simple cat/pkg and
- * cat/pkg:slot specs anyway, even if we chose nothing */
- continue;
- }
-
- if (! match_package(*env, spec, *r->second->decision()->if_package_id(), MatchPackageOptions()))
- continue;
-
- any = true;
-
- std::cout << "For " << r->first << ":" << std::endl;
- std::cout << " The following constraints were in action:" << std::endl;
- for (Constraints::ConstIterator c(r->second->constraints()->begin()),
- c_end(r->second->constraints()->end()) ;
- c != c_end ; ++c)
- {
- std::cout << " * " << (*c)->spec();
-
- switch ((*c)->use_installed())
- {
- case ui_if_same:
- std::cout << ", use installed if same";
- break;
- case ui_never:
- std::cout << ", never using installed";
- break;
- case ui_only_if_transient:
- std::cout << ", using installed only if transient";
- break;
- case ui_if_same_version:
- std::cout << ", use installed if same version";
- break;
- case ui_if_possible:
- std::cout << ", use installed if possible";
- break;
-
- case last_ui:
- break;
- }
-
- if ((*c)->to_destination_slash())
- std::cout << ", installing to /";
-
- std::cout << std::endl;
- std::cout << " because ";
- ReasonDisplayer v;
- (*c)->reason()->accept(v);
- std::cout << std::endl;
- }
- std::cout << " The decision made was:" << std::endl;
- std::cout << " Use " << *r->second->decision()->if_package_id() << std::endl;
- if (r->second->destinations()->slash())
- {
- std::cout << " Install to / using repository " << r->second->destinations()->slash()->repository() << std::endl;
- if (! r->second->destinations()->slash()->replacing()->empty())
- for (PackageIDSequence::ConstIterator x(r->second->destinations()->slash()->replacing()->begin()),
- x_end(r->second->destinations()->slash()->replacing()->end()) ;
- x != x_end ; ++x)
- std::cout << " Replacing " << **x << std::endl;
- }
- std::cout << std::endl;
- }
-
- if (! any)
- throw args::DoHelp("There is nothing matching '" + *i + "' in the resolution set.");
- }
-}
-
diff --git a/src/clients/cave/cmd_resolve_display_resolution.cc b/src/clients/cave/cmd_resolve_display_resolution.cc
deleted file mode 100644
index 6a6e95b..0000000
--- a/src/clients/cave/cmd_resolve_display_resolution.cc
+++ /dev/null
@@ -1,286 +0,0 @@
-/* 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 "cmd_resolve_display_resolution.hh"
-#include "colour_formatter.hh"
-#include "formats.hh"
-#include <paludis/resolver/resolver.hh>
-#include <paludis/resolver/resolution.hh>
-#include <paludis/resolver/decision.hh>
-#include <paludis/resolver/destinations.hh>
-#include <paludis/resolver/constraint.hh>
-#include <paludis/resolver/reason.hh>
-#include <paludis/resolver/resolutions.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/simple_visitor_cast.hh>
-#include <paludis/util/join.hh>
-#include <paludis/util/iterator_funcs.hh>
-#include <paludis/package_id.hh>
-#include <paludis/version_spec.hh>
-#include <paludis/metadata_key.hh>
-#include <paludis/choice.hh>
-#include <iostream>
-#include <set>
-
-using namespace paludis;
-using namespace cave;
-using namespace paludis::resolver;
-
-namespace
-{
- struct ReasonNameGetter
- {
- std::pair<std::string, bool> visit(const DependencyReason & r) const
- {
- if (r.sanitised_dependency().spec().if_block())
- return std::make_pair(stringify(r.from_id()->name()) + " blocker " +
- stringify(*r.sanitised_dependency().spec().if_block()), true);
- else
- return std::make_pair(stringify(r.from_id()->name()), false);
- }
-
- std::pair<std::string, bool> visit(const TargetReason &) const
- {
- return std::make_pair("target", true);
- }
-
- std::pair<std::string, bool> visit(const SetReason & r) const
- {
- std::pair<std::string, bool> rr(r.reason_for_set()->accept_returning<std::pair<std::string, bool> >(*this));
- return std::make_pair(rr.first + " (" + stringify(r.set_name()) + ")", rr.second);
- }
-
- std::pair<std::string, bool> visit(const PresetReason &) const
- {
- return std::make_pair("", false);
- }
- };
-}
-
-void
-paludis::cave::display_resolution(
- const std::tr1::shared_ptr<Environment> &,
- const std::tr1::shared_ptr<Resolutions> & resolutions,
- const ResolveCommandLine &)
-{
- Context context("When displaying chosen resolution:");
-
- std::cout << "These are the actions I will take, in order:" << std::endl << std::endl;
-
- for (Resolutions::ConstIterator c(resolutions->begin()), c_end(resolutions->end()) ;
- c != c_end ; ++c)
- {
- const std::tr1::shared_ptr<const PackageID> id((*c)->decision()->if_package_id());
- if (! id)
- throw InternalError(PALUDIS_HERE, "why did that happen?");
-
- bool is_new(false), is_upgrade(false), is_downgrade(false), is_reinstall(false);
- std::tr1::shared_ptr<const PackageID> old_id;
-
- if ((*c)->destinations()->slash())
- {
- if ((*c)->destinations()->slash()->replacing()->empty())
- is_new = true;
- else
- for (PackageIDSequence::ConstIterator x((*c)->destinations()->slash()->replacing()->begin()),
- x_end((*c)->destinations()->slash()->replacing()->end()) ;
- x != x_end ; ++x)
- {
- old_id = *x;
- if ((*x)->version() == id->version())
- is_reinstall = true;
- else if ((*x)->version() < id->version())
- is_upgrade = true;
- else if ((*x)->version() > id->version())
- is_downgrade = true;
- }
-
- /* pick the worst of what it is */
- is_upgrade = is_upgrade && (! is_reinstall) && (! is_downgrade);
- is_reinstall = is_reinstall && (! is_downgrade);
- }
-
- if (is_new)
- std::cout << "[n] " << c::bold_blue() << id->canonical_form(idcf_no_version);
- else if (is_upgrade)
- std::cout << "[u] " << c::blue() << id->canonical_form(idcf_no_version);
- else if (is_reinstall)
- std::cout << "[r] " << c::yellow() << id->canonical_form(idcf_no_version);
- else if (is_downgrade)
- std::cout << "[d] " << c::bold_yellow() << id->canonical_form(idcf_no_version);
- else
- throw InternalError(PALUDIS_HERE, "why did that happen?");
-
- std::cout << c::normal() << " " << id->canonical_form(idcf_version);
-
- if ((*c)->destinations()->slash())
- {
- std::cout << " to ::" << (*c)->destinations()->slash()->repository();
- if (! (*c)->destinations()->slash()->replacing()->empty())
- {
- std::cout << " replacing";
- for (PackageIDSequence::ConstIterator x((*c)->destinations()->slash()->replacing()->begin()),
- x_end((*c)->destinations()->slash()->replacing()->end()) ;
- x != x_end ; ++x)
- std::cout << " " << (*x)->canonical_form(idcf_version);
- }
- }
-
- std::cout << std::endl;
-
- if (id->choices_key())
- {
- ColourFormatter formatter(0);
-
- std::tr1::shared_ptr<const Choices> old_choices;
- if (old_id && old_id->choices_key())
- old_choices = old_id->choices_key()->value();
-
- bool non_blank_prefix(false);
- std::string s;
- for (Choices::ConstIterator k(id->choices_key()->value()->begin()),
- k_end(id->choices_key()->value()->end()) ;
- k != k_end ; ++k)
- {
- if ((*k)->hidden())
- continue;
-
- bool shown_prefix(false);
- for (Choice::ConstIterator i((*k)->begin()), i_end((*k)->end()) ;
- i != i_end ; ++i)
- {
- if (! (*i)->explicitly_listed())
- continue;
-
- if (! shown_prefix)
- {
- if (non_blank_prefix || ! (*k)->show_with_no_prefix())
- {
- shown_prefix = true;
- if (! s.empty())
- s.append(" ");
- s.append((*k)->raw_name() + ":");
- }
- }
-
- if (! s.empty())
- s.append(" ");
-
- std::string t;
- if ((*i)->enabled())
- {
- if ((*i)->locked())
- t = formatter.format(**i, format::Forced());
- else
- t = formatter.format(**i, format::Enabled());
- }
- else
- {
- if ((*i)->locked())
- t = formatter.format(**i, format::Masked());
- else
- t = formatter.format(**i, format::Disabled());
- }
-
- bool changed(false), added(false);
- if ((*k)->consider_added_or_changed())
- {
- if (old_choices)
- {
- std::tr1::shared_ptr<const ChoiceValue> old_choice(
- old_choices->find_by_name_with_prefix((*i)->name_with_prefix()));
- if (! old_choice)
- added = true;
- else if (old_choice->enabled() != (*i)->enabled())
- changed = true;
- }
- else
- added = true;
- }
-
- if (changed)
- {
- t = formatter.decorate(**i, t, format::Changed());
- }
- else if (added)
- {
- if (old_id)
- t = formatter.decorate(**i, t, format::Added());
- }
-
- s.append(t);
- }
- }
-
- if (s.empty())
- break;
-
- std::cout << " " << s << std::endl;
- }
-
- if (id->short_description_key())
- std::cout << " \"" << id->short_description_key()->value() << "\"" << std::endl;
-
- std::set<std::string> reason_names, special_reason_names;
- for (Constraints::ConstIterator r((*c)->constraints()->begin()),
- r_end((*c)->constraints()->end()) ;
- r != r_end ; ++r)
- {
- ReasonNameGetter g;
- std::pair<std::string, bool> s((*r)->reason()->accept_returning<std::pair<std::string, bool> >(g));
- if (! s.first.empty())
- {
- if (s.second)
- special_reason_names.insert(s.first);
- else
- reason_names.insert(s.first);
- }
- }
-
- if ((! special_reason_names.empty()) || (! reason_names.empty()))
- {
- std::cout << " Because of ";
-
- if (! special_reason_names.empty())
- std::cout << c::bold_yellow() << join(special_reason_names.begin(), special_reason_names.end(), ", ")
- << c::normal();
-
- if (! reason_names.empty())
- {
- if (! special_reason_names.empty())
- std::cout << ", ";
-
- if (reason_names.size() > 4)
- std::cout << join(reason_names.begin(), next(reason_names.begin(), 3), ", ")
- << ", " << (reason_names.size() - 3) << " more";
- else
- std::cout << join(reason_names.begin(), reason_names.end(), ", ");
- }
-
- if ((! (*c)->decision()->is_best()) && (! (*c)->decision()->is_nothing())
- && (! (*c)->decision()->is_installed()))
- std::cout << c::bold_red() << " which prevented selection of the best candidate" << c::normal();
-
- std::cout << std::endl;
- }
- }
-
- std::cout << std::endl;
-}
-
diff --git a/src/clients/cave/cmd_resolve_display_resolution.hh b/src/clients/cave/cmd_resolve_display_resolution.hh
deleted file mode 100644
index 472d7a0..0000000
--- a/src/clients/cave/cmd_resolve_display_resolution.hh
+++ /dev/null
@@ -1,38 +0,0 @@
-/* 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_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_RESOLUTION_HH
-#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_RESOLUTION_HH 1
-
-#include <paludis/environment-fwd.hh>
-#include <paludis/resolver/resolutions-fwd.hh>
-#include "cmd_resolve_cmdline.hh"
-
-namespace paludis
-{
- namespace cave
- {
- void display_resolution(
- const std::tr1::shared_ptr<Environment> &,
- const std::tr1::shared_ptr<resolver::Resolutions> &,
- const ResolveCommandLine &);
- }
-}
-
-#endif
diff --git a/src/clients/cave/cmd_resolve_dump.cc b/src/clients/cave/cmd_resolve_dump.cc
index 37d0f91..951bde2 100644
--- a/src/clients/cave/cmd_resolve_dump.cc
+++ b/src/clients/cave/cmd_resolve_dump.cc
@@ -36,7 +36,7 @@ paludis::cave::dump_if_requested(
{
Context context("When dumping the resolver:");
- if (! cmdline.display_options.a_dump.specified())
+ if (! cmdline.resolution_options.a_dump.specified())
return;
std::cout << "Dumping resolutions by QPN:S:" << std::endl << std::endl;
@@ -47,7 +47,7 @@ paludis::cave::dump_if_requested(
{
std::cout << c->first << std::endl;
std::cout << " = " << *c->second << std::endl;
- if (cmdline.display_options.a_dump_dependencies.specified() && c->second->sanitised_dependencies())
+ if (cmdline.resolution_options.a_dump_dependencies.specified() && c->second->sanitised_dependencies())
for (SanitisedDependencies::ConstIterator d(c->second->sanitised_dependencies()->begin()),
d_end(c->second->sanitised_dependencies()->end()) ;
d != d_end ; ++d)
diff --git a/src/clients/cave/command_factory.cc b/src/clients/cave/command_factory.cc
index 4cc97ef..843cc2c 100644
--- a/src/clients/cave/command_factory.cc
+++ b/src/clients/cave/command_factory.cc
@@ -26,6 +26,7 @@
#include <tr1/functional>
#include <map>
+#include "cmd_display_resolution.hh"
#include "cmd_help.hh"
#include "cmd_perform.hh"
#include "cmd_print_categories.hh"
@@ -72,6 +73,7 @@ namespace
CommandFactory::CommandFactory() :
PrivateImplementationPattern<CommandFactory>(new Implementation<CommandFactory>)
{
+ _imp->handlers.insert(std::make_pair("display-resolution", make_command<DisplayResolutionCommand>));
_imp->handlers.insert(std::make_pair("help", make_command<HelpCommand>));
_imp->handlers.insert(std::make_pair("perform", make_command<PerformCommand>));
_imp->handlers.insert(std::make_pair("print-categories", make_command<PrintCategoriesCommand>));