diff options
author | 2011-02-26 21:22:37 +0000 | |
---|---|---|
committer | 2011-02-26 21:22:37 +0000 | |
commit | dc6cdcbdc1430403fb52ad4baf859d09b5bed1c4 (patch) | |
tree | 54eb5c530f87fda06c5476e144fcab59f352dc90 | |
parent | 0c8eeda99a0bbef95e7729369ee293f526cd76a0 (diff) | |
download | paludis-dc6cdcbdc1430403fb52ad4baf859d09b5bed1c4.tar.gz paludis-dc6cdcbdc1430403fb52ad4baf859d09b5bed1c4.tar.xz |
Put repo mask info directly in the mask
-rw-r--r-- | doc/api/cplusplus/examples/example_mask.cc | 6 | ||||
-rw-r--r-- | paludis/mask.hh | 20 | ||||
-rw-r--r-- | paludis/repositories/e/e_mask.cc | 31 | ||||
-rw-r--r-- | paludis/repositories/e/e_mask.hh | 8 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild_id.cc | 16 | ||||
-rw-r--r-- | python/additional_tests.cc | 1 | ||||
-rw-r--r-- | python/mask.cc | 37 | ||||
-rwxr-xr-x | python/mask_TEST.py | 4 | ||||
-rw-r--r-- | ruby/mask.cc | 2 | ||||
-rw-r--r-- | ruby/package_id_TEST.rb | 2 | ||||
-rwxr-xr-x | src/clients/cave/cmd_display_resolution.cc | 5 | ||||
-rw-r--r-- | src/clients/cave/cmd_print_id_masks.cc | 4 | ||||
-rw-r--r-- | src/clients/cave/cmd_show.cc | 28 |
13 files changed, 112 insertions, 52 deletions
diff --git a/doc/api/cplusplus/examples/example_mask.cc b/doc/api/cplusplus/examples/example_mask.cc index fe98d6fa9..c9fd67a33 100644 --- a/doc/api/cplusplus/examples/example_mask.cc +++ b/doc/api/cplusplus/examples/example_mask.cc @@ -49,7 +49,11 @@ namespace void visit(const RepositoryMask & mask) { cout << left << setw(30) << " Class:" << " " << "RepositoryMask" << endl; - cout << left << setw(30) << " Mask key:" << " " << mask.mask_key_name() << endl; + cout << left << setw(30) << " Mask file:" << " " << mask.mask_file() << endl; + if (! mask.comment().empty()) + cout << left << setw(30) << " Comment:" << " " << mask.comment() << endl; + if (! mask.token().empty()) + cout << left << setw(30) << " Token:" << " " << mask.token() << endl; } void visit(const UnsupportedMask & mask) diff --git a/paludis/mask.hh b/paludis/mask.hh index 90dfce4a2..ed4370820 100644 --- a/paludis/mask.hh +++ b/paludis/mask.hh @@ -160,12 +160,26 @@ namespace paludis { public: /** - * Fetch the raw name of a metadata key explaining the mask. May - * return a zero pointer, if no more information is available. + * An associated comment. Might be empty. * * \since 0.59 */ - virtual const std::string mask_key_name() const = 0; + virtual const std::string comment() const = 0; + + /** + * An associated token, for Environment::unmasked_by_user. Might be empty. + * + * \since 0.59 + */ + virtual const std::string token() const = 0; + + /** + * The file whence the mask originates. + * + * \since 0.59 + */ + virtual const FSPath mask_file() const = 0; + }; /** diff --git a/paludis/repositories/e/e_mask.cc b/paludis/repositories/e/e_mask.cc index a2ff30ac8..93662169c 100644 --- a/paludis/repositories/e/e_mask.cc +++ b/paludis/repositories/e/e_mask.cc @@ -143,19 +143,24 @@ namespace paludis { const char key; const std::string description; - const std::string mask_key_name; + const std::string comment; + const std::string token; + const FSPath mask_file; - Imp(const char k, const std::string & d, const std::string & m) : + Imp(const char k, const std::string & d, const std::string & c, const std::string & t, const FSPath & f) : key(k), description(d), - mask_key_name(m) + comment(c), + token(t), + mask_file(f) { } }; } -ERepositoryMask::ERepositoryMask(const char k, const std::string & d, const std::string & m) : - _imp(k, d, m) +ERepositoryMask::ERepositoryMask(const char k, const std::string & d, const std::string & c, + const std::string & t, const FSPath & f) : + _imp(k, d, c, t, f) { } @@ -176,9 +181,21 @@ ERepositoryMask::description() const } const std::string -ERepositoryMask::mask_key_name() const +ERepositoryMask::comment() const { - return _imp->mask_key_name; + return _imp->comment; +} + +const std::string +ERepositoryMask::token() const +{ + return _imp->token; +} + +const FSPath +ERepositoryMask::mask_file() const +{ + return _imp->mask_file; } namespace diff --git a/paludis/repositories/e/e_mask.hh b/paludis/repositories/e/e_mask.hh index c550fa864..7ba03ffba 100644 --- a/paludis/repositories/e/e_mask.hh +++ b/paludis/repositories/e/e_mask.hh @@ -65,12 +65,16 @@ namespace paludis Pimp<ERepositoryMask> _imp; public: - ERepositoryMask(const char, const std::string &, const std::string &); + ERepositoryMask(const char, const std::string & description, + const std::string & comment, const std::string & token, const FSPath &); ~ERepositoryMask(); virtual char key() const; const std::string description() const; - const std::string mask_key_name() const; + + virtual const std::string comment() const; + virtual const std::string token() const; + virtual const FSPath mask_file() const; }; } diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc index acfa9bf18..3bc861985 100644 --- a/paludis/repositories/e/ebuild_id.cc +++ b/paludis/repositories/e/ebuild_id.cc @@ -570,11 +570,15 @@ EbuildID::need_masks_added() const { /* repo unless user */ if (_imp->repository_mask->value()) - add_mask(std::make_shared<ERepositoryMask>('R', "repository", _imp->repository_mask->raw_name())); + add_mask(std::make_shared<ERepositoryMask>('R', "repository", + _imp->repository_mask->value()->comment() ? join(_imp->repository_mask->value()->comment()->begin(), + _imp->repository_mask->value()->comment()->end(), " ") : "", "", _imp->repository_mask->value()->mask_file())); /* profile unless user */ if (_imp->profile_mask->value()) - add_mask(std::make_shared<ERepositoryMask>('P', "profile", _imp->profile_mask->raw_name())); + add_mask(std::make_shared<ERepositoryMask>('P', "profile", + _imp->profile_mask->value()->comment() ? join(_imp->profile_mask->value()->comment()->begin(), + _imp->profile_mask->value()->comment()->end(), " ") : "", "", _imp->profile_mask->value()->mask_file())); /* user */ std::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(shared_from_this(), false)); @@ -587,7 +591,9 @@ EbuildID::need_masks_added() const if (_imp->repository_mask->value()) add_overridden_mask(std::make_shared<OverriddenMask>( make_named_values<OverriddenMask>( - n::mask() = std::make_shared<ERepositoryMask>('r', "repository (overridden)", _imp->repository_mask->raw_name()), + n::mask() = std::make_shared<ERepositoryMask>('r', "repository (overridden)", + _imp->repository_mask->value()->comment() ? join(_imp->repository_mask->value()->comment()->begin(), + _imp->repository_mask->value()->comment()->end(), " ") : "", "", _imp->repository_mask->value()->mask_file()), n::override_reason() = mro_overridden_by_user ))); @@ -595,7 +601,9 @@ EbuildID::need_masks_added() const if (_imp->profile_mask->value()) add_overridden_mask(std::make_shared<OverriddenMask>( make_named_values<OverriddenMask>( - n::mask() = std::make_shared<ERepositoryMask>('p', "profile (overridden)", _imp->profile_mask->raw_name()), + n::mask() = std::make_shared<ERepositoryMask>('p', "profile (overridden)", + _imp->profile_mask->value()->comment() ? join(_imp->profile_mask->value()->comment()->begin(), + _imp->profile_mask->value()->comment()->end(), " ") : "", "", _imp->profile_mask->value()->mask_file()), n::override_reason() = mro_overridden_by_user ))); diff --git a/python/additional_tests.cc b/python/additional_tests.cc index 6b8fafe99..89d4958b4 100644 --- a/python/additional_tests.cc +++ b/python/additional_tests.cc @@ -120,7 +120,6 @@ namespace mask void test_repository_mask(RepositoryMask & m) { test_mask(m); - m.mask_key_name(); } void test_unsupported_mask(UnsupportedMask & m) diff --git a/python/mask.cc b/python/mask.cc index 60ef4a597..1687b788c 100644 --- a/python/mask.cc +++ b/python/mask.cc @@ -214,7 +214,38 @@ struct RepositoryMaskWrapper : else throw PythonMethodNotImplemented("RepositoryMask", "description"); } + + virtual const std::string comment() const + { + Lock l(get_mutex()); + + if (bp::override f = get_override("comment")) + return f(); + else + throw PythonMethodNotImplemented("RepositoryMask", "comment"); + } + + virtual const std::string token() const + { + Lock l(get_mutex()); + + if (bp::override f = get_override("token")) + return f(); + else + throw PythonMethodNotImplemented("RepositoryMask", "token"); + } + + virtual const FSPath mask_file() const + { + Lock l(get_mutex()); + + if (bp::override f = get_override("mask_file")) + return f(); + else + throw PythonMethodNotImplemented("RepositoryMask", "mask_file"); + } }; + struct UnsupportedMaskWrapper : UnsupportedMask, bp::wrapper<UnsupportedMask> @@ -426,12 +457,6 @@ void expose_mask() "Can be subclassed in Python.", bp::init<>() ) - .def("mask_key_name", bp::pure_virtual(&RepositoryMask::mask_key_name), - "mask_key_name() -> string\n" - "Fetch the name of a metadata key explaining the mask. May return None,\n" - "if no more information is available." - ) - .def("key", bp::pure_virtual(&Mask::key), "key() -> string\n" "A single character key, which can be used by clients if they need\n" diff --git a/python/mask_TEST.py b/python/mask_TEST.py index 833b9c221..f38a2dad3 100755 --- a/python/mask_TEST.py +++ b/python/mask_TEST.py @@ -72,7 +72,6 @@ class TestCase_01_Masks(unittest.TestCase): package_mask_path = os.path.realpath(os.path.join(os.getcwd(), "mask_TEST_dir/testrepo/profiles/package.mask")) - self.assertEquals(m.mask_key_name(), "repository_mask") def test_04_unsupported_mask(self): q = Selection.RequireExactlyOne(Generator.Matches( @@ -135,9 +134,6 @@ class TestCase_02_Masks_subclassing(unittest.TestCase): def description(self): return "test" - def mask_key_name(self): - return "monkey" - test_repository_mask(TestRepositoryMask()) def test_04_unsupported_mask(self): diff --git a/ruby/mask.cc b/ruby/mask.cc index 0cac96e19..93ca902bb 100644 --- a/ruby/mask.cc +++ b/ruby/mask.cc @@ -215,8 +215,6 @@ namespace * A RepositoryMask is a Mask that signifies that a PackageID has been marked as masked by a Repository. */ c_repository_mask = rb_define_class_under(paludis_module(), "RepositoryMask", c_mask); - rb_define_method(c_repository_mask, "mask_key_name", - RUBY_FUNC_CAST((&MaskMetadataKey<RepositoryMask,&RepositoryMask::mask_key_name>::fetch)), 0); /* * Document-class: Paludis::UnsupportedMask diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb index 5e5992ab3..46a0c46ee 100644 --- a/ruby/package_id_TEST.rb +++ b/ruby/package_id_TEST.rb @@ -181,7 +181,6 @@ module Paludis assert_equal 1, masks.length mask = masks.first assert_kind_of RepositoryMask, mask - assert_equal "repository_mask", mask.mask_key_name end def test_hash @@ -246,7 +245,6 @@ module Paludis def test_repository_mask_info_keys assert_kind_of MetadataRepositoryMaskInfoKey, pid_testrepo["repository_mask"] assert_kind_of RepositoryMaskInfo, pid_testrepo["repository_mask"].value - assert pid_testrepo["repository_mask"].value.mask_file =~ %r[package_id_TEST_dir/testrepo/profiles/package.mask$] assert_equal ["this is", "a test"], pid_testrepo["repository_mask"].value.comment assert_nil pid_testrepo["profile_mask"].value end diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc index 2a60e5b8f..f76b8fcdb 100755 --- a/src/clients/cave/cmd_display_resolution.cc +++ b/src/clients/cave/cmd_display_resolution.cc @@ -1034,9 +1034,8 @@ namespace void visit(const RepositoryMask & m) const { cout << fuc(fs_masked_by(), fv<'i'>(indent), fv<'c'>(colour), fv<'d'>(m.description())); - MaskedByKeyVisitor v{env, id, indent + " "}; - if (! m.mask_key_name().empty()) - (*id->find_metadata(m.mask_key_name()))->accept(v); + if (! m.comment().empty()) + cout << fuc(fs_mask_by_repo_line(), fv<'i'>(indent + " "), fv<'s'>(m.comment())); } void visit(const UnacceptedMask & m) const diff --git a/src/clients/cave/cmd_print_id_masks.cc b/src/clients/cave/cmd_print_id_masks.cc index b81be8b91..135c67e7f 100644 --- a/src/clients/cave/cmd_print_id_masks.cc +++ b/src/clients/cave/cmd_print_id_masks.cc @@ -113,9 +113,9 @@ namespace return std::make_pair(m.unaccepted_key_name(), ""); } - const std::pair<std::string, std::string> visit(const RepositoryMask & m) const + const std::pair<std::string, std::string> visit(const RepositoryMask &) const { - return std::make_pair(m.mask_key_name(), ""); + return std::make_pair("", ""); } const std::pair<std::string, std::string> visit(const UnsupportedMask &) const diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc index 47e44b513..db633ded7 100644 --- a/src/clients/cave/cmd_show.cc +++ b/src/clients/cave/cmd_show.cc @@ -1089,22 +1089,20 @@ namespace void visit(const RepositoryMask & m) { - if (! m.mask_key_name().empty()) - { - InfoDisplayer i(env, cmdline, indent, false, make_null_shared_ptr(), make_null_shared_ptr(), false, out); - (*id->find_metadata(m.mask_key_name()))->accept(i); - } - else - { - out << fuc( - (cmdline.a_raw_names.specified() ? fs_metadata_value_raw() : fs_metadata_value_human()), - fv<'s'>(cmdline.a_raw_names.specified() ? stringify(m.key()) : "by " + m.description()), - fv<'v'>(""), - fv<'i'>(std::string(indent, ' ')), - fv<'b'>(""), - fv<'p'>("") + out << fuc( + (cmdline.a_raw_names.specified() ? fs_metadata_value_raw() : fs_metadata_value_human()), + fv<'s'>(cmdline.a_raw_names.specified() ? stringify(m.key()) : "by " + m.description()), + fv<'v'>(stringify(m.mask_file())), + fv<'i'>(std::string(indent, ' ')), + fv<'b'>(""), + fv<'p'>("") + ); + + if (! m.comment().empty()) + out << fuc(fs_metadata_continued_value(), + fv<'v'>(m.comment()), + fv<'i'>(std::string(indent, ' ')) ); - } } }; |