diff options
-rw-r--r-- | doc/en/aptitude.xml | 17 | ||||
-rw-r--r-- | src/load_grouppolicy.cc | 25 | ||||
-rw-r--r-- | src/pkg_grouppolicy.cc | 16 | ||||
-rw-r--r-- | src/pkg_grouppolicy.h | 9 |
4 files changed, 62 insertions, 5 deletions
diff --git a/doc/en/aptitude.xml b/doc/en/aptitude.xml index cd7910bc..ffd83b10 100644 --- a/doc/en/aptitude.xml +++ b/doc/en/aptitude.xml @@ -5233,6 +5233,23 @@ iuAU wesnoth-data +930kB 0.8.7-1 0.8.8-1.0w </para> <para> + Instead of <literal>=> + <replaceable>title</replaceable></literal>, an entry + may end with <literal>||</literal>. This indicates + that packages matching the corresponding + <replaceable>pattern</replaceable> will be inserted + into the tree at the same level as the + <literal>pattern</literal> grouping, rather than + being placed in subtrees. For instance, + <literal>pattern(~aremove => Packages Being Removed, + ~T ||)</literal> will place packages that are being + removed into a subtree, and place all the other + packages at the current level. Any later grouping + policies will apply to both sets of packages, of + course. + </para> + + <para> See <xref linkend='secSearchPatterns'/> for more information on the format of <replaceable>pattern</replaceable>. diff --git a/src/load_grouppolicy.cc b/src/load_grouppolicy.cc index b5c07ed4..8b930678 100644 --- a/src/load_grouppolicy.cc +++ b/src/load_grouppolicy.cc @@ -589,6 +589,7 @@ class pattern_policy_parser : public group_policy_parser vector<const char *> terminators; terminators.push_back(","); terminators.push_back("=>"); + terminators.push_back("||"); try { @@ -602,6 +603,8 @@ class pattern_policy_parser : public group_policy_parser terminators, false, true, false)); + bool passthrough = false; + if(matcher.get() == NULL) throw GroupParseException(_("Unable to parse pattern after \"%s\""), string(begin0, end).c_str()); @@ -628,8 +631,28 @@ class pattern_policy_parser : public group_policy_parser throw GroupParseException(_("Unexpectedly empty tree title after \"%s\""), string(begin0, end).c_str()); } + else if(begin != end && *begin == '|') + { + ++begin; + + eassert(begin != end && *begin == '|'); + + passthrough = true; + + ++begin; + + while(begin != end && isspace(*begin)) + ++begin; + + if(begin != end) + { + if(*begin != ',' && *begin != ')') + throw GroupParseException(_("Expected ',' or ')' following '||', got '%s'"), + string(begin, begin + 1).c_str()); + } + } - subgroups.push_back(pkg_grouppolicy_matchers_factory::match_pair(matcher.release(), transcode(format))); + subgroups.push_back(pkg_grouppolicy_matchers_factory::match_pair(matcher.release(), transcode(format), passthrough)); if(begin != end && *begin == ',') ++begin; diff --git a/src/pkg_grouppolicy.cc b/src/pkg_grouppolicy.cc index c83e5d56..2f9565b6 100644 --- a/src/pkg_grouppolicy.cc +++ b/src/pkg_grouppolicy.cc @@ -1032,6 +1032,7 @@ public: }; private: pkg_grouppolicy_factory *chain; + pkg_grouppolicy *passthrough_policy; const vector<match_pair> &subgroups; typedef map<wstring, subtree_pair> subtree_map; subtree_map subtrees; @@ -1122,7 +1123,8 @@ public: pkg_signal *_sig, desc_signal *_desc_sig, const vector<match_pair> &_subgroups) :pkg_grouppolicy(_sig, _desc_sig), - chain(_chain), subgroups(_subgroups) + chain(_chain), passthrough_policy(NULL), + subgroups(_subgroups) { } @@ -1131,6 +1133,7 @@ public: for(subtree_map::const_iterator i = subtrees.begin(); i != subtrees.end(); ++i) delete i->second.policy; + delete passthrough_policy; } void add_package(const pkgCache::PkgIterator &pkg, @@ -1142,6 +1145,15 @@ public: pkg_match_result *res = i->matcher->get_match(pkg); if(res != NULL) { + if(i->passthrough) + { + if(passthrough_policy == NULL) + passthrough_policy = chain->instantiate(get_sig(), + get_desc_sig()); + passthrough_policy->add_package(pkg, root); + break; + } + wstring title = substitute(i->tree_name, res); delete res; @@ -1161,6 +1173,8 @@ public: policy->add_package(pkg, tree); } + + break; } } } diff --git a/src/pkg_grouppolicy.h b/src/pkg_grouppolicy.h index 8c613436..466fb64d 100644 --- a/src/pkg_grouppolicy.h +++ b/src/pkg_grouppolicy.h @@ -1,6 +1,6 @@ // pkg_grouppolicy.h -*-c++-*- // -// Copyright 1999-2002, 2005 Daniel Burrows +// Copyright 1999-2002, 2005, 2007 Daniel Burrows // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -268,9 +268,12 @@ public: { pkg_matcher *matcher; std::wstring tree_name; + bool passthrough; - match_pair(pkg_matcher *_matcher, const std::wstring &_tree_name) - :matcher(_matcher), tree_name(_tree_name) + match_pair(pkg_matcher *_matcher, + const std::wstring &_tree_name, + bool _passthrough) + :matcher(_matcher), tree_name(_tree_name), passthrough(_passthrough) { } }; |