aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-19 18:29:22 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-19 18:29:22 +0000
commitd83965fef9cb945a2dd42fc17d709fbfac1ce0fe (patch)
tree3bb396aa30273068f0eedd1821c9fd1db0a61403
parent9418c6b546001af699ff4d9d3c9e5451be0a2125 (diff)
downloadpaludis-d83965fef9cb945a2dd42fc17d709fbfac1ce0fe.tar.gz
paludis-d83965fef9cb945a2dd42fc17d709fbfac1ce0fe.tar.xz
Support group names for suggestions
-rw-r--r--paludis/resolver/interest_in_spec_helper.cc33
-rw-r--r--paludis/resolver/interest_in_spec_helper.hh2
-rw-r--r--src/clients/cave/cmd_display_resolution-fmt.hh6
-rwxr-xr-xsrc/clients/cave/cmd_display_resolution.cc32
-rw-r--r--src/clients/cave/resolve_cmdline.cc7
-rw-r--r--src/clients/cave/resolve_common.cc42
6 files changed, 112 insertions, 10 deletions
diff --git a/paludis/resolver/interest_in_spec_helper.cc b/paludis/resolver/interest_in_spec_helper.cc
index 86e92e0..4b39582 100644
--- a/paludis/resolver/interest_in_spec_helper.cc
+++ b/paludis/resolver/interest_in_spec_helper.cc
@@ -37,7 +37,9 @@
#include <paludis/package_dep_spec_collection.hh>
#include <paludis/metadata_key.hh>
#include <paludis/match_package.hh>
+#include <paludis/dep_spec_annotations.hh>
#include <list>
+#include <set>
using namespace paludis;
using namespace paludis::resolver;
@@ -49,8 +51,10 @@ namespace paludis
{
const Environment * const env;
std::list<PackageDepSpec> take_specs;
+ std::set<std::string> take_groups;
std::list<PackageDepSpec> take_from_specs;
std::list<PackageDepSpec> ignore_specs;
+ std::set<std::string> ignore_groups;
std::list<PackageDepSpec> ignore_from_specs;
PackageDepSpecCollection no_blockers_from_specs;
PackageDepSpecCollection no_dependencies_from_specs;
@@ -84,6 +88,12 @@ InterestInSpecHelper::add_take_spec(const PackageDepSpec & spec)
}
void
+InterestInSpecHelper::add_take_group(const std::string & group)
+{
+ _imp->take_groups.insert(group);
+}
+
+void
InterestInSpecHelper::add_take_from_spec(const PackageDepSpec & spec)
{
_imp->take_from_specs.push_back(spec);
@@ -96,6 +106,12 @@ InterestInSpecHelper::add_ignore_spec(const PackageDepSpec & spec)
}
void
+InterestInSpecHelper::add_ignore_group(const std::string & group)
+{
+ _imp->ignore_groups.insert(group);
+}
+
+void
InterestInSpecHelper::add_ignore_from_spec(const PackageDepSpec & spec)
{
_imp->ignore_from_specs.push_back(spec);
@@ -259,6 +275,20 @@ InterestInSpecHelper::operator() (
return si_take;
}
+ std::string spec_group;
+ {
+ const DepSpec & spec(dep.spec().if_block() ? static_cast<const DepSpec &>(*dep.spec().if_block()) : *dep.spec().if_package());
+ if (spec.maybe_annotations())
+ {
+ auto a(spec.maybe_annotations()->find(dsar_suggestions_group_name));
+ if (a != spec.maybe_annotations()->end())
+ spec_group = a->value();
+ }
+ }
+
+ if ((! spec_group.empty()) && _imp->take_groups.end() != _imp->take_groups.find(spec_group))
+ return si_take;
+
if (dep.spec().if_package())
{
for (auto l(_imp->ignore_specs.begin()), l_end(_imp->ignore_specs.end()) ;
@@ -274,6 +304,9 @@ InterestInSpecHelper::operator() (
return si_ignore;
}
+ if ((! spec_group.empty()) && _imp->ignore_groups.end() != _imp->ignore_groups.find(spec_group))
+ return si_ignore;
+
if (suggestion)
{
if (_imp->take_suggestions.is_true())
diff --git a/paludis/resolver/interest_in_spec_helper.hh b/paludis/resolver/interest_in_spec_helper.hh
index 34cccaa..bb7080c 100644
--- a/paludis/resolver/interest_in_spec_helper.hh
+++ b/paludis/resolver/interest_in_spec_helper.hh
@@ -44,8 +44,10 @@ namespace paludis
~InterestInSpecHelper();
void add_take_spec(const PackageDepSpec &);
+ void add_take_group(const std::string &);
void add_take_from_spec(const PackageDepSpec &);
void add_ignore_spec(const PackageDepSpec &);
+ void add_ignore_group(const std::string &);
void add_ignore_from_spec(const PackageDepSpec &);
void add_no_blockers_from_spec(const PackageDepSpec &);
void add_no_dependencies_from_spec(const PackageDepSpec &);
diff --git a/src/clients/cave/cmd_display_resolution-fmt.hh b/src/clients/cave/cmd_display_resolution-fmt.hh
index 7a63210..55d5375 100644
--- a/src/clients/cave/cmd_display_resolution-fmt.hh
+++ b/src/clients/cave/cmd_display_resolution-fmt.hh
@@ -104,8 +104,10 @@ const auto fs_reasons_end = make_format_string_fetcher("display-resolution/reaso
const auto fs_confirm = make_format_string_fetcher("display-resolution/confirm", 1)
<< c::bold_red() << " Cannot proceed without: " << c::normal() << param<'s'>() << "\\n";
-const auto fs_take = make_format_string_fetcher("display-resolution/take", 1)
- << c::bold_green_or_pink() << " Take using: " << c::normal() << "--take" << "\\n";
+const auto fs_take = make_format_string_fetcher("display-resolution/take", 2)
+ << c::bold_green_or_pink() << " Take using: " << c::normal() << "--take"
+ << param_if<'g'>() << " (" << param<'g'>() << ")" << param_endif<'g'>()
+ << "\\n";
const auto fs_take_purge = make_format_string_fetcher("display-resolution/take_purge", 1)
<< c::bold_green_or_pink() << " Take using: " << c::normal() << "--purge" << "\\n";
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index a1f6e82..309cd0f 100755
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -783,10 +783,36 @@ namespace
cout << fuc(fs_confirm(), fv<'s'>(join(indirect_iterator(r->begin()), indirect_iterator(r->end()), ", ", stringify_confirmation)));
}
+ std::string find_suggestion_groups(
+ const std::shared_ptr<const Resolution> & resolution,
+ const Decision &)
+ {
+ std::stringstream result;
+
+ for (auto c(resolution->constraints()->begin()), c_end(resolution->constraints()->end()) ;
+ c != c_end ; ++c)
+ {
+ const DepSpec & spec((*c)->spec().if_block() ? static_cast<const DepSpec &>(*(*c)->spec().if_block()) : *(*c)->spec().if_package());
+ if (spec.maybe_annotations())
+ {
+ auto a(spec.maybe_annotations()->find(dsar_suggestions_group_name));
+ if (a != spec.maybe_annotations()->end())
+ {
+ if (! result.str().empty())
+ result << ", ";
+ result << a->value();
+ }
+ }
+ }
+
+ return result.str();
+ }
+
void display_untaken_change(
- const ChangesToMakeDecision &)
+ const std::shared_ptr<const Resolution> resolution,
+ const ChangesToMakeDecision & decision)
{
- cout << fuc(fs_take());
+ cout << fuc(fs_take(), fv<'g'>(find_suggestion_groups(resolution, decision)));
}
struct IsPurgeVisitor
@@ -1270,7 +1296,7 @@ namespace
if (maybe_totals)
display_downloads(env, cmdline, decision.origin_id(), maybe_totals);
if (untaken)
- display_untaken_change(decision);
+ display_untaken_change(resolution, decision);
if (confirmations)
display_confirmations(decision);
if (! cycle_notes.empty())
diff --git a/src/clients/cave/resolve_cmdline.cc b/src/clients/cave/resolve_cmdline.cc
index 48e5882..89ecb01 100644
--- a/src/clients/cave/resolve_cmdline.cc
+++ b/src/clients/cave/resolve_cmdline.cc
@@ -202,11 +202,12 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
("display", "Display recommendations, but do not take them unless explicitly told to do so")
("take", "Take all recommendations"),
"take"),
- a_take(&g_suggestion_options, "take", 't', "Take any suggestion matching the supplied package specification"
- " (e.g. --take 'app-vim/securemodelines' or --take 'app-vim/*')"),
+ a_take(&g_suggestion_options, "take", 't', "Take any suggestion matching the supplied package specification "
+ "or suggestion group name (e.g. --take 'app-vim/securemodelines' or --take 'app-vim/*' or --take send-email)"),
a_take_from(&g_suggestion_options, "take-from", 'T', "Take all suggestions made by any package matching the "
"supplied package specification"),
- a_ignore(&g_suggestion_options, "ignore", 'i', "Discard any suggestion matching the supplied package specification"),
+ a_ignore(&g_suggestion_options, "ignore", 'i', "Discard any suggestion matching the supplied package specification "
+ "or group name"),
a_ignore_from(&g_suggestion_options, "ignore-from", 'I', "Discard all suggestions made by any package matching the "
"supplied package specification"),
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 6ff20f4..e554495 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -933,7 +933,26 @@ paludis::cave::resolve_common(
for (args::StringSetArg::ConstIterator i(resolution_options.a_take.begin_args()),
i_end(resolution_options.a_take.end_args()) ;
i != i_end ; ++i)
- interest_in_spec_helper.add_take_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ {
+ bool might_be_group(std::string::npos == i->find_first_not_of(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-_"));
+
+ if (might_be_group)
+ {
+ interest_in_spec_helper.add_take_group(*i);
+ try
+ {
+ interest_in_spec_helper.add_take_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ }
+ catch (const Exception &)
+ {
+ }
+ }
+ else
+ interest_in_spec_helper.add_take_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ }
for (args::StringSetArg::ConstIterator i(resolution_options.a_take_from.begin_args()),
i_end(resolution_options.a_take_from.end_args()) ;
@@ -943,7 +962,26 @@ paludis::cave::resolve_common(
for (args::StringSetArg::ConstIterator i(resolution_options.a_ignore.begin_args()),
i_end(resolution_options.a_ignore.end_args()) ;
i != i_end ; ++i)
- interest_in_spec_helper.add_ignore_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ {
+ bool might_be_group(std::string::npos == i->find_first_not_of(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-_"));
+
+ if (might_be_group)
+ {
+ interest_in_spec_helper.add_ignore_group(*i);
+ try
+ {
+ interest_in_spec_helper.add_ignore_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ }
+ catch (const Exception &)
+ {
+ }
+ }
+ else
+ interest_in_spec_helper.add_ignore_spec(parse_user_package_dep_spec(*i, env.get(), { updso_allow_wildcards }));
+ }
for (args::StringSetArg::ConstIterator i(resolution_options.a_ignore_from.begin_args()),
i_end(resolution_options.a_ignore_from.end_args()) ;