Support groups in suggestions.conf

This commit is contained in:
Ciaran McCreesh 2010-12-19 18:55:31 +00:00
parent d83965fef9
commit c1f12a3490
3 changed files with 90 additions and 32 deletions

@ -22,9 +22,10 @@ standard configuration file which may be a bash file (<code>suggestions.bash</co
<p>A token may be one of the following:</p>
<ul>
<li><code>*/*</code>, which says to take all suggestions from the package.</li>
<li>A simple <code>cat/pkg</code>, which says to take any suggestions related to the named package. Note that
complex dependency specifications may <em>not</em> be used here.</li>
complex dependency specifications may <em>not</em> be used here; however, either or both of the <code>cat</code>
and <code>pkg</code> tokens may be <code>*</code>.</li>
<li>A suggestions group name, to take all suggestions with that group.</li>
<li>A minus sign, followed by either of the above, to discard rather than take the suggestion in question.</li>
</ul>
@ -42,5 +43,8 @@ dev-util/kdevelop -dev-util/cvs
# Otherwise, we're interested in all kde-base suggestions:
kde-base/* */*
# We want the send-email suggestions from git:
dev-scm/git send-email
</pre>

@ -21,14 +21,7 @@
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/paludis_config.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/environment.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/spec_tree.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
#include <paludis/util/options.hh>
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
@ -38,6 +31,14 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/environment.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/spec_tree.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/package_id.hh>
#include <paludis/dep_spec_annotations.hh>
#include <unordered_map>
#include <list>
#include <vector>
@ -51,7 +52,9 @@ namespace
struct ValueFlag
{
bool negated;
std::shared_ptr<const QualifiedPackageName> name;
std::string cat_requirement;
std::string pkg_requirement;
std::string group_requirement;
ValueFlag(const std::string & s) :
negated(false)
@ -67,8 +70,19 @@ namespace
if (s_fixed.empty())
throw PaludisConfigError("Empty value flag '" + s + "'");
if (s_fixed != "*/*")
name = std::make_shared<QualifiedPackageName>(s_fixed);
std::string::size_type slash_p(s_fixed.find('/'));
if (std::string::npos == slash_p)
group_requirement = s_fixed;
else
{
std::string c(s_fixed.substr(0, slash_p));
if (c != "*")
cat_requirement = c;
std::string p(s_fixed.substr(slash_p + 1));
if (p != "*")
pkg_requirement = p;
}
}
};
}
@ -164,6 +178,14 @@ SuggestionsConf::interest_in_suggestion(
const std::shared_ptr<const PackageID> & from_id,
const PackageDepSpec & spec) const
{
std::string spec_group;
if (spec.maybe_annotations())
{
auto a(spec.maybe_annotations()->find(dsar_suggestions_group_name));
if (a != spec.maybe_annotations()->end())
spec_group = a->value();
}
/* highest priority: specific */
{
SpecificMap::const_iterator i(_imp->qualified.find(from_id->name()));
@ -178,11 +200,22 @@ SuggestionsConf::interest_in_suggestion(
for (ValuesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ;
l != l_end ; ++l)
{
if (! l->name)
return l->negated ? false : true;
if (! l->group_requirement.empty())
{
if (spec_group == l->group_requirement)
return l->negated ? false : true;
}
else
{
if (! l->pkg_requirement.empty())
if (stringify(spec.package_ptr()->package()) != l->pkg_requirement)
continue;
if (! l->cat_requirement.empty())
if (stringify(spec.package_ptr()->category()) != l->cat_requirement)
continue;
if (*l->name == *spec.package_ptr())
return l->negated ? false : true;
}
}
}
}
@ -211,11 +244,22 @@ SuggestionsConf::interest_in_suggestion(
for (ValuesList::const_iterator l(i->second.second.begin()), l_end(i->second.second.end()) ;
l != l_end ; ++l)
{
if (! l->name)
return l->negated ? false : true;
if (! l->group_requirement.empty())
{
if (spec_group == l->group_requirement)
return l->negated ? false : true;
}
else
{
if (! l->pkg_requirement.empty())
if (stringify(spec.package_ptr()->package()) != l->pkg_requirement)
continue;
if (! l->cat_requirement.empty())
if (stringify(spec.package_ptr()->category()) != l->cat_requirement)
continue;
if (*l->name == *spec.package_ptr())
return l->negated ? false : true;
}
}
}
}
@ -231,11 +275,22 @@ SuggestionsConf::interest_in_suggestion(
for (ValuesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ;
l != l_end ; ++l)
{
if (! l->name)
return l->negated ? false : true;
if (! l->group_requirement.empty())
{
if (spec_group == l->group_requirement)
return l->negated ? false : true;
}
else
{
if (! l->pkg_requirement.empty())
if (stringify(spec.package_ptr()->package()) != l->pkg_requirement)
continue;
if (! l->cat_requirement.empty())
if (stringify(spec.package_ptr()->category()) != l->cat_requirement)
continue;
if (*l->name == *spec.package_ptr())
return l->negated ? false : true;
}
}
}

@ -18,24 +18,23 @@ endif
syn region PaludisSuggestionsConfComment start=/^\s*#/ end=/$/
syn match PaludisSuggestionsConfPDS /^[^ \t#\/]\+\/[^ \t#\/]\+\s*/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfStars,PaludisSuggestionsConfContinuation
\ contains=PaludisSuggestionsConfWildcard
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfGroup,PaludisSuggestionsConfContinuation
\ contains=PaludisSuggestionsConfWildcard
syn match PaludisSuggestionsConfWildcard contained /\(\*\/\@=\|\/\@<=\*\)/
syn match PaludisSuggestionsConfSet /^[^ \t#\/]\+\S\@!/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfStars,PaludisSuggestionsConfContinuation skipwhite
syn match PaludisSuggestionsConfName contained /-\?[a-zA-Z0-9\-_]\+\/[a-zA-Z0-9\-_+]\+/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfStars,PaludisSuggestionsConfContinuation skipwhite
syn match PaludisSuggestionsConfStars contained /-\?\*\/\*/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfStars,PaludisSuggestionsConfContinuation skipwhite
syn match PaludisSuggestionsConfGroup contained /-\?[a-zA-Z0-9\-_]\+\S\@!/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfGroup,PaludisSuggestionsConfContinuation skipwhite
\ contains=PaludisSuggestionsConfWildcard
syn match PaludisSuggestionsConfName contained /-\?\(\*\|[a-zA-Z0-9\-_]\+\)\/\(\*\|[a-zA-Z0-9\-_+]\)\+/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfGroup,PaludisSuggestionsConfContinuation skipwhite
\ contains=PaludisSuggestionsConfWildcard
syn match PaludisSuggestionsConfContinuation contained /\\$/
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfStars,PaludisSuggestionsConfContinuation skipwhite skipnl
\ nextgroup=PaludisSuggestionsConfName,PaludisSuggestionsConfGroup,PaludisSuggestionsConfContinuation skipwhite skipnl
hi def link PaludisSuggestionsConfComment Comment
hi def link PaludisSuggestionsConfPDS Identifier
hi def link PaludisSuggestionsConfWildcard Special
hi def link PaludisSuggestionsConfSet Special
hi def link PaludisSuggestionsConfGroup Macro
hi def link PaludisSuggestionsConfName Keyword
hi def link PaludisSuggestionsConfStars Keyword
hi def link PaludisSuggestionsConfContinuation Preproc
let b:current_syntax = "paludis-suggestions-conf"