diff options
author | 2011-09-04 21:34:18 +0100 | |
---|---|---|
committer | 2011-09-04 21:34:18 +0100 | |
commit | c90d4dec7920a8d70949d8e2e71e704d2800d2c1 (patch) | |
tree | b27391f20de3e33d4bfe074e6a5f9592d4fb3465 | |
parent | 9a153e42f9703672b5a9de6d24d6a35697b05531 (diff) | |
download | paludis-c90d4dec7920a8d70949d8e2e71e704d2800d2c1.tar.gz paludis-c90d4dec7920a8d70949d8e2e71e704d2800d2c1.tar.xz |
PackageID::contents
28 files changed, 151 insertions, 4 deletions
diff --git a/paludis/package_id.hh b/paludis/package_id.hh index d035f0a06..d1a43d5f0 100644 --- a/paludis/package_id.hh +++ b/paludis/package_id.hh @@ -318,6 +318,16 @@ namespace paludis */ virtual void perform_action(Action &) const = 0; + /** + * The contents, if non-zero, contains the contents of a + * package. For installed packages, this means the files installed; + * for installable packages, this means the files that will be + * installed (if known, which it may be for some binary packages). + * + * \since 0.66 + */ + virtual const std::shared_ptr<const Contents> contents() const = 0; + ///\} ///\name Masks diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc index cd0db561a..88a80affe 100644 --- a/paludis/repositories/accounts/accounts_id.cc +++ b/paludis/repositories/accounts/accounts_id.cc @@ -553,3 +553,9 @@ AccountsID::perform_action(Action & action) const output_manager->succeeded(); } +const std::shared_ptr<const Contents> +AccountsID::contents() const +{ + return make_null_shared_ptr(); +} + diff --git a/paludis/repositories/accounts/accounts_id.hh b/paludis/repositories/accounts/accounts_id.hh index 32cfa696d..a310b0528 100644 --- a/paludis/repositories/accounts/accounts_id.hh +++ b/paludis/repositories/accounts/accounts_id.hh @@ -86,6 +86,8 @@ namespace paludis virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual void perform_action(Action &) const; + virtual const std::shared_ptr<const Contents> contents() const; + ///\} virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)); diff --git a/paludis/repositories/accounts/installed_accounts_id.cc b/paludis/repositories/accounts/installed_accounts_id.cc index 482eb113e..50580c4c1 100644 --- a/paludis/repositories/accounts/installed_accounts_id.cc +++ b/paludis/repositories/accounts/installed_accounts_id.cc @@ -354,3 +354,9 @@ InstalledAccountsID::perform_action(Action & action) const throw ActionFailedError("Unsupported action: " + action.simple_name()); } +const std::shared_ptr<const Contents> +InstalledAccountsID::contents() const +{ + return make_null_shared_ptr(); +} + diff --git a/paludis/repositories/accounts/installed_accounts_id.hh b/paludis/repositories/accounts/installed_accounts_id.hh index 89f4ae559..5328c2626 100644 --- a/paludis/repositories/accounts/installed_accounts_id.hh +++ b/paludis/repositories/accounts/installed_accounts_id.hh @@ -84,6 +84,8 @@ namespace paludis virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual void perform_action(Action &) const PALUDIS_ATTRIBUTE((noreturn)); + virtual const std::shared_ptr<const Contents> contents() const; + ///\} virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)); diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc index 62fb0de72..16bcea26d 100644 --- a/paludis/repositories/e/e_installed_repository_id.cc +++ b/paludis/repositories/e/e_installed_repository_id.cc @@ -867,6 +867,12 @@ EInstalledRepositoryID::contents_key() const return _imp->keys->contents; } +const std::shared_ptr<const Contents> +EInstalledRepositoryID::contents() const +{ + return contents_key()->parse_value(); +} + const std::shared_ptr<const MetadataTimeKey> EInstalledRepositoryID::installed_time_key() const { diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh index b4b091d85..8fa93bc66 100644 --- a/paludis/repositories/e/e_installed_repository_id.hh +++ b/paludis/repositories/e/e_installed_repository_id.hh @@ -112,6 +112,8 @@ namespace paludis virtual void can_drop_in_memory_cache() const; virtual void set_scm_revision(const std::string &) const PALUDIS_ATTRIBUTE((noreturn)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc index 135be592b..0a34b5779 100644 --- a/paludis/repositories/e/ebuild_id.cc +++ b/paludis/repositories/e/ebuild_id.cc @@ -1715,3 +1715,9 @@ EbuildID::set_scm_revision(const std::string & s) const } } +const std::shared_ptr<const Contents> +EbuildID::contents() const +{ + return make_null_shared_ptr(); +} + diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh index db04dab08..db76271e8 100644 --- a/paludis/repositories/e/ebuild_id.hh +++ b/paludis/repositories/e/ebuild_id.hh @@ -170,6 +170,8 @@ namespace paludis bool might_be_binary() const; virtual void set_scm_revision(const std::string &) const; + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc index 6191bf6b1..5fbc7aa43 100644 --- a/paludis/repositories/fake/fake_package_id.cc +++ b/paludis/repositories/fake/fake_package_id.cc @@ -1191,6 +1191,12 @@ FakePackageID::behaviours_set() return _imp->behaviours_set; } +const std::shared_ptr<const Contents> +FakePackageID::contents() const +{ + return make_null_shared_ptr(); +} + namespace paludis { template class FakeMetadataSpecTreeKey<LicenseSpecTree>; @@ -1203,3 +1209,4 @@ namespace paludis template class FakeMetadataCollectionKey<KeywordNameSet>; } + diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh index 3ba726f4a..59d5b9d1b 100644 --- a/paludis/repositories/fake/fake_package_id.hh +++ b/paludis/repositories/fake/fake_package_id.hh @@ -287,6 +287,8 @@ namespace paludis virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::shared_ptr<const Contents> contents() const; + }; } diff --git a/paludis/repositories/gemcutter/gemcutter_id.cc b/paludis/repositories/gemcutter/gemcutter_id.cc index eab00a585..ef426b04a 100644 --- a/paludis/repositories/gemcutter/gemcutter_id.cc +++ b/paludis/repositories/gemcutter/gemcutter_id.cc @@ -413,7 +413,14 @@ GemcutterID::slot_key() const return _imp->slot_key; } +const std::shared_ptr<const Contents> +GemcutterID::contents() const +{ + return make_null_shared_ptr(); +} + namespace paludis { template class Pimp<GemcutterID>; } + diff --git a/paludis/repositories/gemcutter/gemcutter_id.hh b/paludis/repositories/gemcutter/gemcutter_id.hh index 4c5e7c624..495b787ff 100644 --- a/paludis/repositories/gemcutter/gemcutter_id.hh +++ b/paludis/repositories/gemcutter/gemcutter_id.hh @@ -98,6 +98,8 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); std::size_t extra_hash_value() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } diff --git a/paludis/repositories/repository/repository_id.cc b/paludis/repositories/repository/repository_id.cc index def3dabc2..2e2789305 100644 --- a/paludis/repositories/repository/repository_id.cc +++ b/paludis/repositories/repository/repository_id.cc @@ -276,7 +276,14 @@ RepositoryID::slot_key() const return make_null_shared_ptr(); } +const std::shared_ptr<const Contents> +RepositoryID::contents() const +{ + return make_null_shared_ptr(); +} + namespace paludis { template class Pimp<RepositoryID>; } + diff --git a/paludis/repositories/repository/repository_id.hh b/paludis/repositories/repository/repository_id.hh index f66a985d4..71f439310 100644 --- a/paludis/repositories/repository/repository_id.hh +++ b/paludis/repositories/repository/repository_id.hh @@ -96,6 +96,8 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); std::size_t extra_hash_value() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/unavailable/unavailable_package_id.cc b/paludis/repositories/unavailable/unavailable_package_id.cc index fec87c479..6552c905e 100644 --- a/paludis/repositories/unavailable/unavailable_package_id.cc +++ b/paludis/repositories/unavailable/unavailable_package_id.cc @@ -300,7 +300,14 @@ UnavailablePackageID::slot_key() const return _imp->slot_key; } +const std::shared_ptr<const Contents> +UnavailablePackageID::contents() const +{ + return make_null_shared_ptr(); +} + namespace paludis { template class Pimp<UnavailablePackageID>; } + diff --git a/paludis/repositories/unavailable/unavailable_package_id.hh b/paludis/repositories/unavailable/unavailable_package_id.hh index 06cf4c9e2..c99c0eea5 100644 --- a/paludis/repositories/unavailable/unavailable_package_id.hh +++ b/paludis/repositories/unavailable/unavailable_package_id.hh @@ -110,6 +110,8 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); std::size_t extra_hash_value() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/unavailable/unavailable_repository_id.cc b/paludis/repositories/unavailable/unavailable_repository_id.cc index 9e054ea16..a3f0c2f19 100644 --- a/paludis/repositories/unavailable/unavailable_repository_id.cc +++ b/paludis/repositories/unavailable/unavailable_repository_id.cc @@ -409,7 +409,14 @@ UnavailableRepositoryID::slot_key() const return make_null_shared_ptr(); } +const std::shared_ptr<const Contents> +UnavailableRepositoryID::contents() const +{ + return make_null_shared_ptr(); +} + namespace paludis { template class Pimp<UnavailableRepositoryID>; } + diff --git a/paludis/repositories/unavailable/unavailable_repository_id.hh b/paludis/repositories/unavailable/unavailable_repository_id.hh index b958a14fa..7791d8341 100644 --- a/paludis/repositories/unavailable/unavailable_repository_id.hh +++ b/paludis/repositories/unavailable/unavailable_repository_id.hh @@ -110,6 +110,8 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); std::size_t extra_hash_value() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc index 5b44d7755..79ebe9a3e 100644 --- a/paludis/repositories/unpackaged/installed_id.cc +++ b/paludis/repositories/unpackaged/installed_id.cc @@ -604,6 +604,12 @@ InstalledUnpackagedID::contents_key() const return _imp->contents_key; } +const std::shared_ptr<const Contents> +InstalledUnpackagedID::contents() const +{ + return contents_key()->parse_value(); +} + const std::shared_ptr<const MetadataTimeKey> InstalledUnpackagedID::installed_time_key() const { diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh index 8d26fc400..fbb36a10f 100644 --- a/paludis/repositories/unpackaged/installed_id.hh +++ b/paludis/repositories/unpackaged/installed_id.hh @@ -86,6 +86,8 @@ namespace paludis const bool replace, const std::shared_ptr<const PackageID> & if_for_install_id, const std::shared_ptr<OutputManager> & output_manager) const; + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc index 9c72cf5bf..65ec5d20e 100644 --- a/paludis/repositories/unpackaged/unpackaged_id.cc +++ b/paludis/repositories/unpackaged/unpackaged_id.cc @@ -511,3 +511,9 @@ UnpackagedID::choices_key() const return _imp->choices_key; } +const std::shared_ptr<const Contents> +UnpackagedID::contents() const +{ + return make_null_shared_ptr(); +} + diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh index 415bd7ec4..71e948e2a 100644 --- a/paludis/repositories/unpackaged/unpackaged_id.hh +++ b/paludis/repositories/unpackaged/unpackaged_id.hh @@ -83,6 +83,8 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); virtual std::size_t extra_hash_value() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/paludis/repositories/unwritten/unwritten_id.cc b/paludis/repositories/unwritten/unwritten_id.cc index 068f55209..83e22f5e1 100644 --- a/paludis/repositories/unwritten/unwritten_id.cc +++ b/paludis/repositories/unwritten/unwritten_id.cc @@ -300,7 +300,14 @@ UnwrittenID::choices_key() const return _imp->choices_key; } +const std::shared_ptr<const Contents> +UnwrittenID::contents() const +{ + return make_null_shared_ptr(); +} + namespace paludis { template class Pimp<UnwrittenID>; } + diff --git a/paludis/repositories/unwritten/unwritten_id.hh b/paludis/repositories/unwritten/unwritten_id.hh index 985536139..a4a4f9238 100644 --- a/paludis/repositories/unwritten/unwritten_id.hh +++ b/paludis/repositories/unwritten/unwritten_id.hh @@ -122,6 +122,8 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); std::size_t extra_hash_value() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::shared_ptr<const Contents> contents() const; }; } } diff --git a/python/package_id.cc b/python/package_id.cc index 88ac8f93b..9f84efd4c 100644 --- a/python/package_id.cc +++ b/python/package_id.cc @@ -155,7 +155,6 @@ void expose_package_id() "installed (if known, which it may be for some binary packages)." ) - .def("installed_time_key", &PackageID::installed_time_key, "The installed_time_key, if not None, contains the time a package\n" "was installed. It affects dependency resolution if DepList is\n" @@ -187,6 +186,13 @@ void expose_package_id() "PackageDepSpec by using parse_user_package_dep_spec." ) + .def("contents", &PackageID::contents, + "The contents, if not None, contains the contents of a\n" + "package. For installed packages, this means the files installed;\n" + "for installable packages, this means the files that will be\n" + "installed (if known, which it may be for some binary packages)." + ) + .def("__eq__", &py_eq<PackageID>) .def("__ne__", &py_ne<PackageID>) diff --git a/ruby/package_id.cc b/ruby/package_id.cc index d661866a6..10d9fa12f 100644 --- a/ruby/package_id.cc +++ b/ruby/package_id.cc @@ -342,6 +342,35 @@ namespace } /* + * Document-method: contents + * + * call-seq: + * contents -> Contents + * + * Our Contents + */ + VALUE + package_id_contents(VALUE self) + { + std::shared_ptr<const PackageID> * self_ptr; + Data_Get_Struct(self, std::shared_ptr<const PackageID>, self_ptr); + try + { + auto contents((*self_ptr)->contents()); + if (! contents) + return Qnil; + else + return contents_to_value(contents); + } + catch (const std::exception & e) + { + exception_to_ruby_exception(e); + } + + return Qnil; + } + + /* * Document-method: masked? * * call-seq: @@ -558,6 +587,7 @@ namespace rb_define_method(c_package_id, "behaviours_key", RUBY_FUNC_CAST(( &KeyValue<MetadataCollectionKey<Set<std::string> >, &PackageID::behaviours_key>::fetch)), 0); rb_define_method(c_package_id, "uniquely_identifying_spec", RUBY_FUNC_CAST(&package_id_uniquely_identifying_spec), 0); + rb_define_method(c_package_id, "contents", RUBY_FUNC_CAST(&package_id_contents), 0); /* * Document-module: Paludis::PackageIDCanonicalForm diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb index d287c2435..4921baab0 100644 --- a/ruby/package_id_TEST.rb +++ b/ruby/package_id_TEST.rb @@ -302,9 +302,8 @@ module Paludis assert_nil pid_installed.long_description_key end - def test_contents_key - assert_kind_of MetadataContentsKey, pid_installed.contents_key - assert_kind_of Contents, pid_installed.contents_key.parse_value + def test_contents + assert_kind_of Contents, pid_installed.contents end def test_installed_time_key |