aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-13 18:02:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-15 16:37:35 +0100
commit823833906c161846a9079d2f8104efefcaf263db (patch)
tree0c51471f5d6cafd7bd4d9ebb08dd40963e10bfda
parente2e29a928e6d9f70ad62fc58dff28e83568b3a1c (diff)
downloadpaludis-823833906c161846a9079d2f8104efefcaf263db.tar.gz
paludis-823833906c161846a9079d2f8104efefcaf263db.tar.xz
Don't bother loading empty dependencies
-rw-r--r--paludis/repositories/e/depend_rdepend_TEST.cc4
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc50
-rw-r--r--paludis/repositories/e/ebuild_id.cc44
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc10
4 files changed, 72 insertions, 36 deletions
diff --git a/paludis/repositories/e/depend_rdepend_TEST.cc b/paludis/repositories/e/depend_rdepend_TEST.cc
index 26440c7..f8e67b4 100644
--- a/paludis/repositories/e/depend_rdepend_TEST.cc
+++ b/paludis/repositories/e/depend_rdepend_TEST.cc
@@ -171,7 +171,7 @@ TEST_P(DependRdependTest, Works)
if (special)
EXPECT_EQ("the/depend", v_id->run_dependencies_key()->pretty_print_value(UnformattedPrettyPrinter(), { }));
else
- EXPECT_EQ("", v_id->run_dependencies_key()->pretty_print_value(UnformattedPrettyPrinter(), { }));
+ EXPECT_FALSE(v_id->run_dependencies_key());
}
{
@@ -189,7 +189,7 @@ TEST_P(DependRdependTest, Works)
QualifiedPackageName("cat/eapi" + eapi + "ronly")) |
filter::InstalledAtRoot(root))]->begin());
- EXPECT_EQ("", v_id->build_dependencies_key()->pretty_print_value(UnformattedPrettyPrinter(), { }));
+ EXPECT_FALSE(v_id->build_dependencies_key());
EXPECT_EQ("the/rdepend", v_id->run_dependencies_key()->pretty_print_value(UnformattedPrettyPrinter(), { }));
}
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index ca614ea..f5c2f2d 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -340,10 +340,14 @@ EInstalledRepositoryID::need_keys_added() const
{
if ((_imp->dir / vars->dependencies()->name()).stat().exists())
{
- _imp->keys->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->dependencies()->name(),
- vars->dependencies()->description(), file_contents(_imp->dir / vars->dependencies()->name()),
- EInstalledRepositoryIDData::get_instance()->build_dependencies_labels, mkt_dependencies);
- add_metadata_key(_imp->keys->dependencies);
+ std::string v(file_contents(_imp->dir / vars->dependencies()->name()));
+ if (! v.empty())
+ {
+ _imp->keys->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->dependencies()->name(),
+ vars->dependencies()->description(), v,
+ EInstalledRepositoryIDData::get_instance()->build_dependencies_labels, mkt_dependencies);
+ add_metadata_key(_imp->keys->dependencies);
+ }
}
}
else
@@ -351,29 +355,43 @@ EInstalledRepositoryID::need_keys_added() const
if (! vars->build_depend()->name().empty())
if ((_imp->dir / vars->build_depend()->name()).stat().exists())
{
- _imp->keys->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->build_depend()->name(),
- vars->build_depend()->description(), file_contents(_imp->dir / vars->build_depend()->name()),
- EInstalledRepositoryIDData::get_instance()->build_dependencies_labels, mkt_dependencies);
- add_metadata_key(_imp->keys->build_dependencies);
+ std::string v(file_contents(_imp->dir / vars->build_depend()->name()));
+ if (! v.empty())
+ {
+ _imp->keys->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->build_depend()->name(),
+ vars->build_depend()->description(), v,
+ EInstalledRepositoryIDData::get_instance()->build_dependencies_labels, mkt_dependencies);
+ add_metadata_key(_imp->keys->build_dependencies);
+ }
}
if (! vars->run_depend()->name().empty())
if ((_imp->dir / vars->run_depend()->name()).stat().exists())
{
- _imp->keys->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->run_depend()->name(),
- vars->run_depend()->description(), file_contents(_imp->dir / vars->run_depend()->name()),
- EInstalledRepositoryIDData::get_instance()->run_dependencies_labels, mkt_dependencies);
- add_metadata_key(_imp->keys->run_dependencies);
+ std::string v(file_contents(_imp->dir / vars->run_depend()->name()));
+ if (! v.empty())
+ {
+ _imp->keys->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->run_depend()->name(),
+ vars->run_depend()->description(), v,
+ EInstalledRepositoryIDData::get_instance()->run_dependencies_labels, mkt_dependencies);
+ add_metadata_key(_imp->keys->run_dependencies);
+ }
}
if (! vars->pdepend()->name().empty())
+ {
if ((_imp->dir / vars->pdepend()->name()).stat().exists())
{
- _imp->keys->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->pdepend()->name(),
- vars->pdepend()->description(), file_contents(_imp->dir / vars->pdepend()->name()),
- EInstalledRepositoryIDData::get_instance()->post_dependencies_labels, mkt_dependencies);
- add_metadata_key(_imp->keys->post_dependencies);
+ std::string v(file_contents(_imp->dir / vars->pdepend()->name()));
+ if (! v.empty())
+ {
+ _imp->keys->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), vars->pdepend()->name(),
+ vars->pdepend()->description(), v,
+ EInstalledRepositoryIDData::get_instance()->post_dependencies_labels, mkt_dependencies);
+ add_metadata_key(_imp->keys->post_dependencies);
+ }
}
+ }
}
if (! vars->restrictions()->name().empty())
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 17da030..99a1c92 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -952,40 +952,52 @@ EbuildID::load_long_description(const std::string & r, const std::string & h, co
void
EbuildID::load_dependencies(const std::string & r, const std::string & h, const std::string & v) const
{
- Lock l(_imp->mutex);
- _imp->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
- EbuildIDData::get_instance()->raw_dependencies_labels, mkt_dependencies);
- add_metadata_key(_imp->dependencies);
+ if (! v.empty())
+ {
+ Lock l(_imp->mutex);
+ _imp->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
+ EbuildIDData::get_instance()->raw_dependencies_labels, mkt_dependencies);
+ add_metadata_key(_imp->dependencies);
+ }
}
void
EbuildID::load_build_depend(const std::string & r, const std::string & h, const std::string & v,
bool rewritten) const
{
- Lock l(_imp->mutex);
- _imp->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
- EbuildIDData::get_instance()->build_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies);
- add_metadata_key(_imp->build_dependencies);
+ if (! v.empty())
+ {
+ Lock l(_imp->mutex);
+ _imp->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
+ EbuildIDData::get_instance()->build_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies);
+ add_metadata_key(_imp->build_dependencies);
+ }
}
void
EbuildID::load_run_depend(const std::string & r, const std::string & h, const std::string & v,
bool rewritten) const
{
- Lock l(_imp->mutex);
- _imp->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
- EbuildIDData::get_instance()->run_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies);
- add_metadata_key(_imp->run_dependencies);
+ if (! v.empty())
+ {
+ Lock l(_imp->mutex);
+ _imp->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
+ EbuildIDData::get_instance()->run_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies);
+ add_metadata_key(_imp->run_dependencies);
+ }
}
void
EbuildID::load_post_depend(const std::string & r, const std::string & h, const std::string & v,
bool rewritten) const
{
- Lock l(_imp->mutex);
- _imp->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
- EbuildIDData::get_instance()->post_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies);
- add_metadata_key(_imp->post_dependencies);
+ if (! v.empty())
+ {
+ Lock l(_imp->mutex);
+ _imp->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v,
+ EbuildIDData::get_instance()->post_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies);
+ add_metadata_key(_imp->post_dependencies);
+ }
}
void
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index ec6f356..6af0d41 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -505,7 +505,10 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
* ebuild env isn't modified for DEPEND=RDEPEND */
PackageID::MetadataConstIterator m(package_id->find_metadata(var));
if (m == package_id->end_metadata())
- throw InternalError(PALUDIS_HERE, "oops. can't find key '" + var + "'");
+ {
+ /* no key is the same as empty */
+ return "O0;";
+ }
const MetadataSpecTreeKey<DependencySpecTree> * mm(
visitor_cast<const MetadataSpecTreeKey<DependencySpecTree> >(**m));
@@ -525,7 +528,10 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
* a local description so that descriptions carry on working for installed stuff. */
PackageID::MetadataConstIterator m(package_id->find_metadata(var));
if (m == package_id->end_metadata())
- throw InternalError(PALUDIS_HERE, "oops. can't find key '" + var + "'");
+ {
+ /* no key is the same as empty */
+ return "O0;";
+ }
const MetadataSpecTreeKey<PlainTextSpecTree> * mm(
visitor_cast<const MetadataSpecTreeKey<PlainTextSpecTree> >(**m));