[paludis-commits] r4592 - in trunk: . doc/configuration paludis paludis/environments/paludis paludis/environments/portage paludis/repositories/e ruby

ciaranm at svn.pioto.org ciaranm at svn.pioto.org
Tue Apr 22 05:19:27 UTC 2008


Author: ciaranm
Date: 2008-04-22 05:19:26 +0000 (Tue, 22 Apr 2008)
New Revision: 4592

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/doc/configuration/sets.html.part.in
   trunk/paludis/environments/paludis/paludis_environment.cc
   trunk/paludis/environments/paludis/world.cc
   trunk/paludis/environments/portage/portage_environment.cc
   trunk/paludis/name.cc
   trunk/paludis/name_TEST.cc
   trunk/paludis/repositories/e/e_installed_repository.cc
   trunk/paludis/repositories/e/e_repository_sets.cc
   trunk/paludis/set_file.cc
   trunk/paludis/set_file.hh
   trunk/paludis/set_file.se
   trunk/paludis/set_file.sr
   trunk/paludis/set_file_TEST.cc
   trunk/paludis/set_file_TEST_setup.sh
   trunk/ruby/environment_TEST.rb
Log:
Implement foo* sets. Fixes: ticket:561


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/ChangeLog	2008-04-22 05:19:26 UTC (rev 4592)
@@ -5,6 +5,13 @@
 only listed in SVN log. For a summary of what has changed between releases,
 see the NEWS file. This file is occasionally pruned to ChangeLog.old.bz2.
 
+2008-04-22 Ciaran McCreesh
+
+	* paludis/, doc/configuration/: Automatically create the set 'foo*',
+	which is like 'foo' but with all operators treated as '*' recursively.
+
+	+ Fixes: ticket:561
+
 2008-04-21 David Leverton
 
 	* doc/configuration/, paludis/, paludis/repositories/unpackaged/,

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/NEWS	2008-04-22 05:19:26 UTC (rev 4592)
@@ -16,6 +16,9 @@
       should be added manually if appropriate.  The special "ununused" set no
       longer exists.
 
+    * If 'foo' is a user defined set, we automatically create 'foo*' which is
+      like 'foo' but with all operators treated as '*' recursively.
+
 0.26.0_pre2:
     * paludis now supports ${root} in environment.conf.  This can be
       used when defining the "world" key, so that the configuration

Modified: trunk/doc/configuration/sets.html.part.in
===================================================================
--- trunk/doc/configuration/sets.html.part.in	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/doc/configuration/sets.html.part.in	2008-04-22 05:19:26 UTC (rev 4592)
@@ -53,3 +53,8 @@
     <dd>Like <code>?</code>, but considers the slot part of the specification (if any) in addition to the name part.</dd>
 </dl>
 
+<p>If the set <code>foo</code> exists and is not a builtin set, the special set <code>foo*</code> is automatically
+generated by Paludis. The <code>foo*</code> set is like the <code>foo</code> set, except that it behaves as if every
+operator is a <code>*</code>. In addition, any set names inside that set are treated as if they were
+<code>setname*</code>, so that the operator behaviour override is recursive.</p>
+

Modified: trunk/paludis/environments/paludis/paludis_environment.cc
===================================================================
--- trunk/paludis/environments/paludis/paludis_environment.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/environments/paludis/paludis_environment.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -341,48 +341,52 @@
 }
 
 tr1::shared_ptr<SetSpecTree::ConstItem>
-PaludisEnvironment::local_set(const SetName & s) const
+PaludisEnvironment::local_set(const SetName & ss) const
 {
     using namespace tr1::placeholders;
 
-    Context context("When looking for package set '" + stringify(s) + "' in paludis environment:");
+    Context context("When looking for package set '" + stringify(ss) + "' in paludis environment:");
 
     Lock l(_imp->sets_mutex);
 
-    std::map<SetName, tr1::shared_ptr<SetSpecTree::ConstItem> >::const_iterator i(_imp->sets.find(s));
+    std::map<SetName, tr1::shared_ptr<SetSpecTree::ConstItem> >::const_iterator i(_imp->sets.find(ss));
     if (i != _imp->sets.end())
         return i->second;
 
+    std::pair<SetName, SetFileSetOperatorMode> s(find_base_set_name_and_suffix_mode(ss));
+
     FSEntry dir(FSEntry(_imp->config->config_dir()) / "sets");
-    tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(s, stringify(s) + ".conf"));
+    tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(ss, stringify(s.first) + ".conf"));
 
-    if ((dir / (stringify(s) + ".bash")).exists())
+    if ((dir / (stringify(s.first) + ".bash")).exists())
     {
         SetFile f(SetFileParams::create()
-                .file_name(dir / (stringify(s) + ".bash"))
+                .file_name(dir / (stringify(s.first) + ".bash"))
                 .type(sft_paludis_bash)
                 .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions() + updso_allow_wildcards))
                 .tag(tag)
+                .set_operator_mode(s.second)
                 .environment(this));
 
-        _imp->sets.insert(std::make_pair(s, f.contents()));
+        _imp->sets.insert(std::make_pair(ss, f.contents()));
         return f.contents();
     }
-    else if ((dir / (stringify(s) + ".conf")).exists())
+    else if ((dir / (stringify(s.first) + ".conf")).exists())
     {
         SetFile f(SetFileParams::create()
-                .file_name(dir / (stringify(s) + ".conf"))
+                .file_name(dir / (stringify(s.first) + ".conf"))
                 .type(sft_paludis_conf)
                 .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions() + updso_allow_wildcards))
                 .tag(tag)
+                .set_operator_mode(s.second)
                 .environment(this));
 
-        _imp->sets.insert(std::make_pair(s, f.contents()));
+        _imp->sets.insert(std::make_pair(ss, f.contents()));
         return f.contents();
     }
     else
     {
-        _imp->sets.insert(std::make_pair(s, tr1::shared_ptr<SetSpecTree::ConstItem>()));
+        _imp->sets.insert(std::make_pair(ss, tr1::shared_ptr<SetSpecTree::ConstItem>()));
         return tr1::shared_ptr<SetSpecTree::ConstItem>();
     }
 }

Modified: trunk/paludis/environments/paludis/world.cc
===================================================================
--- trunk/paludis/environments/paludis/world.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/environments/paludis/world.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -116,6 +116,7 @@
             .type(sft_simple)
             .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
             .tag(tr1::shared_ptr<DepTag>())
+            .set_operator_mode(sfsmo_natural)
             .environment(_imp->env));
     world.add(n);
     world.rewrite();
@@ -144,6 +145,7 @@
                 .type(sft_simple)
                 .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                 .tag(tr1::shared_ptr<DepTag>())
+                .set_operator_mode(sfsmo_natural)
                 .environment(_imp->env));
 
         world.remove(n);
@@ -167,6 +169,7 @@
                     .type(sft_simple)
                     .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                     .tag(tag)
+                    .set_operator_mode(sfsmo_natural)
                     .environment(_imp->env));
             return world.contents();
         }

Modified: trunk/paludis/environments/portage/portage_environment.cc
===================================================================
--- trunk/paludis/environments/portage/portage_environment.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/environments/portage/portage_environment.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -795,6 +795,7 @@
             .type(sft_simple)
             .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
             .tag(tr1::shared_ptr<DepTag>())
+            .set_operator_mode(sfsmo_natural)
             .environment(this));
     world.add(s);
     world.rewrite();
@@ -816,6 +817,7 @@
                 .type(sft_simple)
                 .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                 .tag(tr1::shared_ptr<DepTag>())
+                .set_operator_mode(sfsmo_natural)
                 .environment(this));
 
         world.remove(s);
@@ -841,6 +843,7 @@
                 .type(sft_simple)
                 .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                 .tag(tag)
+                .set_operator_mode(sfsmo_natural)
                 .environment(this));
         return world.contents();
     }

Modified: trunk/paludis/name.cc
===================================================================
--- trunk/paludis/name.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/name.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -388,6 +388,13 @@
         if (s.empty())
             break;
 
+        if (s.length() > 1 && '*' == s[s.length() - 1] && '*' != s[s.length() - 2])
+        {
+            Context c("When validating set name '" + s + "':");
+            validate(s.substr(0, s.length() - 1));
+            return;
+        }
+
         if ('-' == s[0] || '.' == s[0])
             break;
 

Modified: trunk/paludis/name_TEST.cc
===================================================================
--- trunk/paludis/name_TEST.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/name_TEST.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -1,7 +1,7 @@
 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
 
 /*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 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
@@ -343,7 +343,27 @@
         }
     } test_keyword_name_validation;
 
+    struct SetNameValidationTest : public TestCase
+    {
+        SetNameValidationTest() : TestCase("validation") { }
 
-
+        void run()
+        {
+            SetName k("set0_-");
+            SetName k1("set0_-");
+            SetName k2("set0*");
+            TEST_CHECK_THROWS(k = SetName(""), NameError);
+            TEST_CHECK_THROWS(k = SetName("!!!"), NameError);
+            TEST_CHECK_THROWS(k = SetName("~"), NameError);
+            TEST_CHECK_THROWS(k = SetName("-"), NameError);
+            TEST_CHECK_THROWS(k = SetName("f?oo"), NameError);
+            TEST_CHECK_THROWS(k = SetName("*"), NameError);
+            TEST_CHECK_THROWS(k = SetName("?"), NameError);
+            TEST_CHECK_THROWS(k = SetName("*set"), NameError);
+            TEST_CHECK_THROWS(k = SetName("set**"), NameError);
+            TEST_CHECK_THROWS(k = SetName("set*?"), NameError);
+            TEST_CHECK_THROWS(k = SetName("set?"), NameError);
+        }
+    } test_set_name_validator;
 }
 

Modified: trunk/paludis/repositories/e/e_installed_repository.cc
===================================================================
--- trunk/paludis/repositories/e/e_installed_repository.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/repositories/e/e_installed_repository.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -253,6 +253,7 @@
                     .type(sft_simple)
                     .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                     .tag(tag)
+                    .set_operator_mode(sfsmo_natural)
                     .environment(_imp->params.environment));
             return world.contents();
         }

Modified: trunk/paludis/repositories/e/e_repository_sets.cc
===================================================================
--- trunk/paludis/repositories/e/e_repository_sets.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/repositories/e/e_repository_sets.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -90,28 +90,31 @@
 }
 
 tr1::shared_ptr<SetSpecTree::ConstItem>
-ERepositorySets::package_set(const SetName & s) const
+ERepositorySets::package_set(const SetName & ss) const
 {
     using namespace tr1::placeholders;
 
-    if ("system" == s.data())
+    std::pair<SetName, SetFileSetOperatorMode> s(find_base_set_name_and_suffix_mode(ss));
+
+    if ("system" == s.first.data())
         throw InternalError(PALUDIS_HERE, "system set should've been handled by ERepository");
-    else if ("security" == s.data())
+    else if ("security" == s.first.data())
         return security_set(false);
-    else if ("insecurity" == s.data())
+    else if ("insecurity" == s.first.data())
         return security_set(true);
-    else if ((_imp->params.setsdir / (stringify(s) + ".conf")).exists())
+    else if ((_imp->params.setsdir / (stringify(s.first) + ".conf")).exists())
     {
-        tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(s, stringify(_imp->e_repository->name())));
+        tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(ss, stringify(_imp->e_repository->name())));
 
-        FSEntry ff(_imp->params.setsdir / (stringify(s) + ".conf"));
-        Context context("When loading package set '" + stringify(s) + "' from '" + stringify(ff) + "':");
+        FSEntry ff(_imp->params.setsdir / (stringify(s.first) + ".conf"));
+        Context context("When loading package set '" + stringify(s.first) + "' from '" + stringify(ff) + "':");
 
         SetFile f(SetFileParams::create()
                 .file_name(ff)
                 .environment(_imp->environment)
                 .type(sft_paludis_conf)
                 .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+                .set_operator_mode(s.second)
                 .tag(tag));
 
         return f.contents();

Modified: trunk/paludis/set_file.cc
===================================================================
--- trunk/paludis/set_file.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/set_file.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -188,11 +188,31 @@
                 tokens.insert(tokens.begin(), "*");
             }
 
-            if ("*" == tokens.at(0))
+            if ("*" == tokens.at(0) || ((sfsmo_star == params.set_operator_mode) &&
+                        ("?" == tokens.at(0) || "?:" == tokens.at(0))))
             {
                 if (std::string::npos == tokens.at(1).find('/'))
                 {
-                    tr1::shared_ptr<NamedSetDepSpec> spec(new NamedSetDepSpec(SetName(tokens.at(1))));
+                    tr1::shared_ptr<NamedSetDepSpec> spec;
+                    switch (params.set_operator_mode)
+                    {
+                        case sfsmo_natural:
+                            spec.reset(new NamedSetDepSpec(SetName(tokens.at(1))));
+                            break;
+
+                        case sfsmo_star:
+                            {
+                                std::pair<SetName, SetFileSetOperatorMode> s(find_base_set_name_and_suffix_mode(SetName(tokens.at(1))));
+                                spec.reset(new NamedSetDepSpec(SetName(stringify(s.first) + "*")));
+                            }
+                            break;
+
+                        case last_sfsmo:
+                            break;
+                    }
+                    if (! spec)
+                        throw InternalError(PALUDIS_HERE, "Bad params.set_name_suffix");
+
                     result->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, NamedSetDepSpec> >(
                                 new TreeLeaf<SetSpecTree, NamedSetDepSpec>(spec)));
                 }
@@ -570,3 +590,14 @@
     return _imp->handler->remove(p);
 }
 
+std::pair<SetName, SetFileSetOperatorMode>
+paludis::find_base_set_name_and_suffix_mode(const SetName & s)
+{
+    Context context("When working out whether '" + stringify(s) + "' has operators:");
+    std::string ss(stringify(s));
+    if (ss.length() >= 2 && '*' == ss[ss.length() - 1])
+        return std::make_pair(SetName(ss.substr(0, ss.length() - 1)), sfsmo_star);
+    else
+        return std::make_pair(s, sfsmo_natural);
+}
+

Modified: trunk/paludis/set_file.hh
===================================================================
--- trunk/paludis/set_file.hh	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/set_file.hh	2008-04-22 05:19:26 UTC (rev 4592)
@@ -1,7 +1,7 @@
 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
 
 /*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 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
@@ -119,6 +119,16 @@
              */
             void remove(const std::string &);
     };
+
+    /**
+     * Split a SetName into a SetName and a SetFileSetOperatorMode.
+     *
+     * \see SetName
+     * \ingroup g_repository
+     * \since 0.26
+     */
+    std::pair<SetName, SetFileSetOperatorMode> find_base_set_name_and_suffix_mode(const SetName &)
+        PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
 }
 
 #endif

Modified: trunk/paludis/set_file.se
===================================================================
--- trunk/paludis/set_file.se	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/set_file.se	2008-04-22 05:19:26 UTC (rev 4592)
@@ -19,5 +19,20 @@
 END
 }
 
+make_enum_SetFileSetOperatorMode()
+{
+    prefix sfsmo
 
+    key sfsmo_natural              "Do not change operators"
+    key sfsmo_star                 "Change operators to * and make set names end in *"
 
+    doxygen_comment << "END"
+        /**
+         * Whether to change operators and set name suffixes.
+         *
+         * \see SetFile
+         * \ingroup g_repository
+         */
+END
+}
+

Modified: trunk/paludis/set_file.sr
===================================================================
--- trunk/paludis/set_file.sr	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/set_file.sr	2008-04-22 05:19:26 UTC (rev 4592)
@@ -7,6 +7,7 @@
     key parser "tr1::function<PackageDepSpec (const std::string &)>"
     key tag "tr1::shared_ptr<const DepTag>"
     key environment "const Environment *"
+    key set_operator_mode SetFileSetOperatorMode
 
     allow_named_args
 

Modified: trunk/paludis/set_file_TEST.cc
===================================================================
--- trunk/paludis/set_file_TEST.cc	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/set_file_TEST.cc	2008-04-22 05:19:26 UTC (rev 4592)
@@ -75,6 +75,7 @@
                     .type(sft_simple)
                     .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                     .tag(tr1::shared_ptr<DepTag>())
+                    .set_operator_mode(sfsmo_natural)
                     .environment(0));
 
             {
@@ -138,6 +139,7 @@
                     .type(sft_paludis_conf)
                     .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
                     .tag(tr1::shared_ptr<DepTag>())
+                    .set_operator_mode(sfsmo_natural)
                     .environment(0));
 
             {
@@ -190,5 +192,44 @@
             return false;
         }
     } test_paludis_conf;
+
+    struct OverrideTest : TestCase
+    {
+        OverrideTest() : TestCase("operator overrides") { }
+
+        void run()
+        {
+            using namespace tr1::placeholders;
+
+            SetFile f(SetFileParams::create()
+                    .file_name(FSEntry("set_file_TEST_dir/override"))
+                    .type(sft_paludis_conf)
+                    .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+                    .tag(tr1::shared_ptr<DepTag>())
+                    .set_operator_mode(sfsmo_natural)
+                    .environment(0));
+
+            {
+                SetSpecStringifier p;
+                f.contents()->accept(p);
+                TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( >=bar/bar-1.23 set set2* ) ");
+            }
+
+            SetFile fstar(SetFileParams::create()
+                    .file_name(FSEntry("set_file_TEST_dir/override"))
+                    .type(sft_paludis_conf)
+                    .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+                    .tag(tr1::shared_ptr<DepTag>())
+                    .set_operator_mode(sfsmo_star)
+                    .environment(0));
+
+            {
+                SetSpecStringifier p;
+                fstar.contents()->accept(p);
+                TEST_CHECK_STRINGIFY_EQUAL(p.s.str(), "( foo/foo >=bar/bar-1.23 >=baz/baz-1.23 set* set2* ) ");
+            }
+
+        }
+    } test_overrides;
 }
 

Modified: trunk/paludis/set_file_TEST_setup.sh
===================================================================
--- trunk/paludis/set_file_TEST_setup.sh	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/paludis/set_file_TEST_setup.sh	2008-04-22 05:19:26 UTC (rev 4592)
@@ -25,3 +25,11 @@
   # the end
 END
 
+cat <<"END" > override
+? foo/foo
+* >=bar/bar-1.23
+? >=baz/baz-1.23
+* set
+* set2*
+END
+

Modified: trunk/ruby/environment_TEST.rb
===================================================================
--- trunk/ruby/environment_TEST.rb	2008-04-21 10:09:42 UTC (rev 4591)
+++ trunk/ruby/environment_TEST.rb	2008-04-22 05:19:26 UTC (rev 4592)
@@ -2,7 +2,7 @@
 # vim: set sw=4 sts=4 et tw=80 :
 
 #
-# Copyright (c) 2006, 2007 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
 # Copyright (c) 2007 Richard Brown
 #
 # This file is part of the Paludis package manager. Paludis is free software;
@@ -285,7 +285,7 @@
 
         def test_package_set_error
             assert_raise SetNameError do
-                env.set('broken*')
+                env.set('broken#')
             end
         end
     end
@@ -301,7 +301,7 @@
 
         def test_package_set_error
             assert_raise SetNameError do
-                env.set('broken*')
+                env.set('broken#')
             end
         end
     end



More information about the paludis-commits mailing list