aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2017-01-16 13:03:26 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2017-01-16 13:56:45 -0800
commit6b0e48f888cf983f6a3e3640c8e2e76a0826632f (patch)
tree47cc378051c6e260f58e149e6f012b264ad20c44
parente023360dbf9b38671dbccbafdfdd26fb87c1c21b (diff)
downloadpaludis-6b0e48f888cf983f6a3e3640c8e2e76a0826632f.tar.gz
paludis-6b0e48f888cf983f6a3e3640c8e2e76a0826632f.tar.xz
paludis: c++11-ify repository iteration
Add a `repositories` in `Environment` which provides an iterator range for the repositories, allowing C++11 style range based iteration.
-rw-r--r--paludis/environment.hh5
-rw-r--r--paludis/environment_implementation.cc35
-rw-r--r--paludis/fuzzy_finder.cc6
-rw-r--r--paludis/generator.cc16
-rw-r--r--paludis/hooker.cc15
-rw-r--r--paludis/match_package.cc11
-rw-r--r--paludis/package_id.cc4
-rw-r--r--paludis/repositories/accounts/accounts_repository_store.cc23
-rw-r--r--paludis/repositories/e/e_installed_repository.cc10
-rw-r--r--paludis/repositories/e/vdb_repository.cc23
-rw-r--r--paludis/repositories/repository/repository_repository_store.cc4
-rw-r--r--paludis/resolver/destination_utils.cc19
-rw-r--r--paludis/resolver/find_replacing_helper.cc30
-rw-r--r--paludis/resolver/find_repository_for_helper.cc36
-rw-r--r--paludis/resolver/package_id_comparator_with_promotion.cc4
-rw-r--r--src/clients/cave/cmd_find_candidates.cc5
-rw-r--r--src/clients/cave/cmd_info.cc5
-rw-r--r--src/clients/cave/cmd_print_categories.cc10
-rw-r--r--src/clients/cave/cmd_print_packages.cc10
-rw-r--r--src/clients/cave/cmd_print_unused_distfiles.cc7
-rw-r--r--src/clients/cave/cmd_sync.cc11
21 files changed, 127 insertions, 162 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh
index cb25fc6..494e9fd 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -37,6 +37,7 @@
#include <paludis/notifier_callback-fwd.hh>
#include <paludis/filter-fwd.hh>
+#include <paludis/util/iterator_range.hh>
#include <paludis/util/options-fwd.hh>
#include <paludis/util/tribool-fwd.hh>
#include <paludis/util/visitor.hh>
@@ -707,6 +708,10 @@ namespace paludis
virtual RepositoryConstIterator end_repositories() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ IteratorRange<RepositoryConstIterator> repositories() const {
+ return {begin_repositories(), end_repositories()};
+ }
+
///\}
};
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index e6894f1..0f50018 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -279,9 +279,8 @@ EnvironmentImplementation::_need_sets() const
if (_imp->loaded_sets)
return;
- for (auto r(begin_repositories()), r_end(end_repositories()) ;
- r != r_end ; ++r)
- (*r)->populate_sets();
+ for (const auto & repository : repositories())
+ repository->populate_sets();
populate_sets();
populate_standard_sets();
@@ -374,10 +373,9 @@ EnvironmentImplementation::add_repository(int importance, const std::shared_ptr<
const std::shared_ptr<const Repository>
EnvironmentImplementation::fetch_repository(const RepositoryName & name) const
{
- for (RepositoryConstIterator r(begin_repositories()), r_end(end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->name() == name)
- return *r;
+ for (const auto & repository : repositories())
+ if (repository->name() == name)
+ return repository;
throw NoSuchRepositoryError(name);
}
@@ -385,10 +383,9 @@ EnvironmentImplementation::fetch_repository(const RepositoryName & name) const
const std::shared_ptr<Repository>
EnvironmentImplementation::fetch_repository(const RepositoryName & name)
{
- for (RepositoryConstIterator r(begin_repositories()), r_end(end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->name() == name)
- return *r;
+ for (const auto & repository : repositories())
+ if (repository->name() == name)
+ return repository;
throw NoSuchRepositoryError(name);
}
@@ -396,9 +393,8 @@ EnvironmentImplementation::fetch_repository(const RepositoryName & name)
bool
EnvironmentImplementation::has_repository_named(const RepositoryName & name) const
{
- for (RepositoryConstIterator r(begin_repositories()), r_end(end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->name() == name)
+ for (const auto & repository : repositories())
+ if (repository->name() == name)
return true;
return false;
@@ -585,9 +581,9 @@ EnvironmentImplementation::more_important_than(const RepositoryName & lhs, const
{
std::map<std::string, int> rank;
int x(0);
- for (auto r(begin_repositories()), r_end(end_repositories()) ;
- r != r_end ; ++r)
- rank.insert(std::make_pair(stringify((*r)->name()), ++x));
+
+ for (const auto & repository : repositories())
+ rank.insert(std::make_pair(stringify(repository->name()), ++x));
std::map<std::string, int>::const_iterator l(rank.find(stringify(lhs)));
if (l == rank.end())
@@ -628,10 +624,9 @@ EnvironmentImplementation::expand_licence(
result->insert(t);
- for (auto r(begin_repositories()), r_end(end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : repositories())
{
- auto l((*r)->maybe_expand_licence_nonrecursively(t));
+ auto l(repository->maybe_expand_licence_nonrecursively(t));
if (l)
for (auto i(l->begin()), i_end(l->end()) ;
i != i_end ; ++i)
diff --git a/paludis/fuzzy_finder.cc b/paludis/fuzzy_finder.cc
index 7a6caf1..0768298 100644
--- a/paludis/fuzzy_finder.cc
+++ b/paludis/fuzzy_finder.cc
@@ -209,9 +209,9 @@ FuzzyRepositoriesFinder::FuzzyRepositoriesFinder(const Environment & e, const st
}
}
- for (auto r(e.begin_repositories()), r_end(e.end_repositories()) ; r != r_end ; ++r)
- if (distance_calculator.distance_with(tolower_0_cost(stringify((*r)->name()))) <= threshold)
- _imp->candidates.push_back((*r)->name());
+ for (const auto & repository : e.repositories())
+ if (distance_calculator.distance_with(tolower_0_cost(stringify(repository->name()))) <= threshold)
+ _imp->candidates.push_back(repository->name());
}
FuzzyRepositoriesFinder::~FuzzyRepositoriesFinder() = default;
diff --git a/paludis/generator.cc b/paludis/generator.cc
index a37b2f1..561e6d1 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -343,16 +343,15 @@ namespace
{
if (spec.installed_at_path_ptr())
{
- for (auto i(env->begin_repositories()),
- i_end(env->end_repositories()) ; i != i_end ; ++i)
+ for (const auto & repository : env->repositories())
{
- if (! (*i)->installed_root_key())
+ if (! repository->installed_root_key())
continue;
- if ((*i)->installed_root_key()->parse_value() != *spec.installed_at_path_ptr())
+ if (repository->installed_root_key()->parse_value() != *spec.installed_at_path_ptr())
continue;
- result->insert((*i)->name());
+ result->insert(repository->name());
}
}
else
@@ -683,10 +682,9 @@ namespace
const RepositoryContentMayExcludes &) const override
{
std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
- for (auto i(env->begin_repositories()),
- i_end(env->end_repositories()) ; i != i_end ; ++i)
- if ((*i)->some_ids_might_support_action(SupportsActionTest<A_>()))
- result->insert((*i)->name());
+ for (const auto & repository : env->repositories())
+ if (repository->some_ids_might_support_action(SupportsActionTest<A_>()))
+ result->insert(repository->name());
return result;
}
diff --git a/paludis/hooker.cc b/paludis/hooker.cc
index efd461f..a000bf7 100644
--- a/paludis/hooker.cc
+++ b/paludis/hooker.cc
@@ -738,19 +738,18 @@ Hooker::perform_hook(
switch (hook.output_dest)
{
case hod_stdout:
- for (auto r(_imp->env->begin_repositories()),
- r_end(_imp->env->end_repositories()) ; r != r_end ; ++r)
- result.max_exit_status() = std::max(result.max_exit_status(),
- ((*r)->perform_hook(hook, optional_output_manager)).max_exit_status());
+ for (const auto & repository : _imp->env->repositories())
+ result.max_exit_status() = std::max(result.max_exit_status(), (repository->perform_hook(hook, optional_output_manager)).max_exit_status());
continue;
case hod_grab:
- for (auto r(_imp->env->begin_repositories()),
- r_end(_imp->env->end_repositories()) ; r != r_end ; ++r)
+ for (const auto & repository : _imp->env->repositories())
{
- HookResult tmp((*r)->perform_hook(hook, optional_output_manager));
+ HookResult tmp(repository->perform_hook(hook, optional_output_manager));
if (tmp.max_exit_status() > result.max_exit_status())
+ {
result = tmp;
+ }
else if (! tmp.output().empty())
{
if (hook.validate_value(tmp.output()))
@@ -759,8 +758,10 @@ Hooker::perform_hook(
return tmp;
}
else
+ {
Log::get_instance()->message("hook.bad_output", ll_warning, lc_context)
<< "Hook returned invalid output: '" << tmp.output() << "'";
+ }
}
}
continue;
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index 36c25ce..790252b 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -189,16 +189,15 @@ paludis::match_package_with_maybe_changes(
return false;
bool ok(false);
- for (auto d(env.begin_repositories()), d_end(env.end_repositories()) ;
- d != d_end ; ++d)
+ for (const auto & repository : env.repositories())
{
- if (! (*d)->destination_interface())
+ if (! repository->destination_interface())
continue;
- if (! (*d)->installed_root_key())
+ if (! repository->installed_root_key())
continue;
- if ((*d)->installed_root_key()->parse_value() != spec.installable_to_path_ptr()->path())
+ if (repository->installed_root_key()->parse_value() != spec.installable_to_path_ptr()->path())
continue;
- if (! (*d)->destination_interface()->is_suitable_destination_for(id))
+ if (! repository->destination_interface()->is_suitable_destination_for(id))
continue;
ok = true;
diff --git a/paludis/package_id.cc b/paludis/package_id.cc
index abc0157..550136c 100644
--- a/paludis/package_id.cc
+++ b/paludis/package_id.cc
@@ -174,8 +174,8 @@ PackageIDComparator::PackageIDComparator(const Environment * const e) :
_imp()
{
unsigned c(0);
- for (auto r(e->begin_repositories()), r_end(e->end_repositories()) ; r != r_end ; ++r)
- _imp->m.insert(std::make_pair((*r)->name(), ++c));
+ for (const auto & repository : e->repositories())
+ _imp->m.insert(std::make_pair(repository->name(), ++c));
}
PackageIDComparator::PackageIDComparator(const PackageIDComparator & other) :
diff --git a/paludis/repositories/accounts/accounts_repository_store.cc b/paludis/repositories/accounts/accounts_repository_store.cc
index 9508192..8368db4 100644
--- a/paludis/repositories/accounts/accounts_repository_store.cc
+++ b/paludis/repositories/accounts/accounts_repository_store.cc
@@ -100,37 +100,36 @@ AccountsRepositoryStore::_load(const RepositoryName & repository_name)
{
Context context("When loading data for AccountsRepository:");
- for (auto r(_imp->env->begin_repositories()), r_end(_imp->env->end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : _imp->env->repositories())
{
- Context r_context("When loading data for repository '" + stringify((*r)->name()) + "':");
+ Context r_context("When loading data for repository '" + stringify(repository->name()) + "':");
- Repository::MetadataConstIterator k_iter((*r)->find_metadata("accounts_repository_data_location"));
- if (k_iter == (*r)->end_metadata())
+ Repository::MetadataConstIterator k_iter(repository->find_metadata("accounts_repository_data_location"));
+ if (k_iter == repository->end_metadata())
{
- Log::get_instance()->message("accounts.no_key_from_repository", ll_debug, lc_context) <<
- "Repository " << (*r)->name() << " defines no accounts_repository_data_location key";
+ Log::get_instance()->message("accounts.no_key_from_repository", ll_debug, lc_context)
+ << "Repository " << repository->name() << " defines no accounts_repository_data_location key";
continue;
}
const MetadataValueKey<FSPath> * k(visitor_cast<const MetadataValueKey<FSPath> >(**k_iter));
if (! k)
{
- Log::get_instance()->message("accounts.bad_key_from_repository", ll_warning, lc_context) <<
- "Repository " << (*r)->name() << " defines an accounts_repository_data_location key, but it is not an FSPath key";
+ Log::get_instance()->message("accounts.bad_key_from_repository", ll_warning, lc_context)
+ << "Repository " << repository->name() << " defines an accounts_repository_data_location key, but it is not an FSPath key";
continue;
}
FSPath dir(k->parse_value());
if (! dir.stat().is_directory_or_symlink_to_directory())
{
- Log::get_instance()->message("accounts.empty_key_from_repository", ll_warning, lc_context) <<
- "Repository " << (*r)->name() << " has accounts_repository_data_location " << dir << ", but this is not a directory";
+ Log::get_instance()->message("accounts.empty_key_from_repository", ll_warning, lc_context)
+ << "Repository " << repository->name() << " has accounts_repository_data_location " << dir << ", but this is not a directory";
continue;
}
std::shared_ptr<Set<std::string> > r_set(std::make_shared<Set<std::string>>());
- r_set->insert(stringify((*r)->name()));
+ r_set->insert(stringify(repository->name()));
std::shared_ptr<LiteralMetadataStringSetKey> r_key(std::make_shared<LiteralMetadataStringSetKey>("defined_by", "Defined by repository", mkt_internal, r_set));
_load_one(repository_name, r_key, dir);
}
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 395985d..883e7f1 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -308,14 +308,12 @@ EInstalledRepository::perform_info(
/* try to find an info_vars file from any repo */
if (! i)
{
- for (auto r(_imp->params.environment()->begin_repositories()), r_end(_imp->params.environment()->end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : _imp->params.environment()->repositories())
{
- Repository::MetadataConstIterator m((*r)->find_metadata("info_vars"));
- if ((*r)->end_metadata() != m)
+ Repository::MetadataConstIterator m(repository->find_metadata("info_vars"));
+ if (repository->end_metadata() != m)
{
- const MetadataCollectionKey<Set<std::string> > * const mm(
- visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**m));
+ const MetadataCollectionKey<Set<std::string>> * const mm(visitor_cast<const MetadataCollectionKey<Set<std::string>>>(**m));
if (mm)
{
i = mm->parse_value();
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index bcdb7e0..c6535d9 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -1100,41 +1100,38 @@ VDBRepository::perform_updates()
std::cout << std::endl << "Checking for updates (package moves etc):" << std::endl;
std::map<FSPath, std::time_t, FSPathComparator> update_timestamps;
- for (auto r(_imp->params.environment()->begin_repositories()),
- r_end(_imp->params.environment()->end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : _imp->params.environment()->repositories())
{
- Context context_2("When performing updates from '" + stringify((*r)->name()) + "':");
+ Context context_2("When performing updates from '" + stringify(repository->name()) + "':");
try
{
- if (0 == stringify((*r)->name()).compare(0, 2, "x-"))
+ if (0 == stringify(repository->name()).compare(0, 2, "x-"))
{
/* ticket:897. not really the best solution, but it'll do for now. */
continue;
}
- Repository::MetadataConstIterator k_iter((*r)->find_metadata("e_updates_location"));
- if (k_iter == (*r)->end_metadata())
+ Repository::MetadataConstIterator k_iter(repository->find_metadata("e_updates_location"));
+ if (k_iter == repository->end_metadata())
{
- Log::get_instance()->message("e.vdb.updates.no_key", ll_debug, lc_context) <<
- "Repository " << (*r)->name() << " defines no e_updates_location key";
+ Log::get_instance()->message("e.vdb.updates.no_key", ll_debug, lc_context) << "Repository " << repository->name() << " defines no e_updates_location key";
continue;
}
const MetadataValueKey<FSPath> * k(visitor_cast<const MetadataValueKey<FSPath> >(**k_iter));
if (! k)
{
- Log::get_instance()->message("e.vdb.udpates.bad_key", ll_warning, lc_context) <<
- "Repository " << (*r)->name() << " defines an e_updates_location key, but it is not an FSPath key";
+ Log::get_instance()->message("e.vdb.udpates.bad_key", ll_warning, lc_context)
+ << "Repository " << repository->name() << " defines an e_updates_location key, but it is not an FSPath key";
continue;
}
FSPath dir(k->parse_value());
if (! dir.stat().is_directory_or_symlink_to_directory())
{
- Log::get_instance()->message("e.vdb.updates.bad_key", ll_warning, lc_context) <<
- "Repository " << (*r)->name() << " has e_updates_location " << dir << ", but this is not a directory";
+ Log::get_instance()->message("e.vdb.updates.bad_key", ll_warning, lc_context)
+ << "Repository " << repository->name() << " has e_updates_location " << dir << ", but this is not a directory";
continue;
}
diff --git a/paludis/repositories/repository/repository_repository_store.cc b/paludis/repositories/repository/repository_repository_store.cc
index bf8fe41..32dc7a6 100644
--- a/paludis/repositories/repository/repository_repository_store.cc
+++ b/paludis/repositories/repository/repository_repository_store.cc
@@ -81,8 +81,8 @@ RepositoryRepositoryStore::~RepositoryRepositoryStore() = default;
void
RepositoryRepositoryStore::_populate()
{
- for (auto r(_imp->env->begin_repositories()), r_end(_imp->env->end_repositories()) ; r != r_end ; ++r)
- _populate_one((*r)->name());
+ for (const auto & repository : _imp->env->repositories())
+ _populate_one(repository->name());
}
void
diff --git a/paludis/resolver/destination_utils.cc b/paludis/resolver/destination_utils.cc
index 6f741ab..de25a35 100644
--- a/paludis/resolver/destination_utils.cc
+++ b/paludis/resolver/destination_utils.cc
@@ -65,17 +65,16 @@ namespace
struct BinaryDestinationGeneratorHandler :
AllGeneratorHandlerBase
{
- std::shared_ptr<const RepositoryNameSet> repositories(
- const Environment * const env,
- const RepositoryContentMayExcludes &) const override
+ std::shared_ptr<const RepositoryNameSet>
+ repositories(const Environment * const env,
+ const RepositoryContentMayExcludes &) const override
{
- using namespace std::placeholders;
- std::shared_ptr<RepositoryNameSet> result(std::make_shared<RepositoryNameSet>());
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ;
- r != r_end ; ++r)
- if (! (*r)->installed_root_key())
- if ((*r)->destination_interface())
- result->insert((*r)->name());
+ auto result(std::make_shared<RepositoryNameSet>());
+
+ for (const auto & repository : env->repositories())
+ if (! repository->installed_root_key())
+ if (repository->destination_interface())
+ result->insert(repository->name());
return result;
}
diff --git a/paludis/resolver/find_replacing_helper.cc b/paludis/resolver/find_replacing_helper.cc
index 98c8696..f1d4cb9 100644
--- a/paludis/resolver/find_replacing_helper.cc
+++ b/paludis/resolver/find_replacing_helper.cc
@@ -68,12 +68,10 @@ FindReplacingHelper::set_one_binary_per_slot(bool value)
}
const std::shared_ptr<const PackageIDSequence>
-FindReplacingHelper::operator() (
- const std::shared_ptr<const PackageID> & id,
- const std::shared_ptr<const Repository> & repo) const
+FindReplacingHelper::operator()(const std::shared_ptr<const PackageID> & id,
+ const std::shared_ptr<const Repository> & repo) const
{
- Context context("When working out what is replaced by '" + stringify(*id) +
- "' when it is installed to '" + stringify(repo->name()) + "':");
+ Context context("When working out what is replaced by '" + stringify(*id) + "' when it is installed to '" + stringify(repo->name()) + "':");
std::set<RepositoryName> repos;
@@ -81,15 +79,9 @@ FindReplacingHelper::operator() (
{
const auto & dest_root = repo->installed_root_key()->parse_value();
- for (auto r(_imp->env->begin_repositories()), r_end(_imp->env->end_repositories()) ;
- r != r_end ; ++r)
- {
- const auto repository = *r;
-
- if (repository->installed_root_key() &&
- repository->installed_root_key()->parse_value() == dest_root)
+ for (const auto & repository : _imp->env->repositories())
+ if (repository->installed_root_key() && repository->installed_root_key()->parse_value() == dest_root)
repos.insert(repository->name());
- }
}
else
repos.insert(repo->name());
@@ -97,14 +89,10 @@ FindReplacingHelper::operator() (
std::shared_ptr<PackageIDSequence> result(std::make_shared<PackageIDSequence>());
for (const auto & r : repos)
{
- std::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::AllVersionsUnsorted(
- generator::Package(id->name()) & generator::InRepository(r))]);
- for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
- i != i_end ; ++i)
- {
- if ((*i)->version() == id->version() || (same_slot(*i, id) && (_imp->one_binary_per_slot || repo->installed_root_key())))
- result->push_back(*i);
- }
+ std::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::AllVersionsUnsorted(generator::Package(id->name()) & generator::InRepository(r))]);
+ for (const auto & package : *ids)
+ if (package->version() == id->version() || (same_slot(package, id) && (_imp->one_binary_per_slot || repo->installed_root_key())))
+ result->push_back(package);
}
return result;
diff --git a/paludis/resolver/find_repository_for_helper.cc b/paludis/resolver/find_repository_for_helper.cc
index 5843039..18432d8 100644
--- a/paludis/resolver/find_repository_for_helper.cc
+++ b/paludis/resolver/find_repository_for_helper.cc
@@ -75,30 +75,28 @@ FindRepositoryForHelper::operator() (
{
std::shared_ptr<const Repository> result;
- for (auto r(_imp->env->begin_repositories()), r_end(_imp->env->end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : _imp->env->repositories())
{
switch (resolution->resolvent().destination_type())
{
case dt_install_to_slash:
- if ((! (*r)->installed_root_key()) ||
- ((*r)->installed_root_key()->parse_value() != _imp->env->system_root_key()->parse_value()))
+ if ((!repository->installed_root_key()) || (repository->installed_root_key()->parse_value() != _imp->env->system_root_key()->parse_value()))
continue;
break;
case dt_install_to_chroot:
if (_imp->chroot_path) {
- if ((! (*r)->installed_root_key()) || ((*r)->installed_root_key()->parse_value() != *_imp->chroot_path))
+ if ((!repository->installed_root_key()) || (repository->installed_root_key()->parse_value() != *_imp->chroot_path))
continue;
}
else {
- if ((! (*r)->installed_root_key()) || ((*r)->installed_root_key()->parse_value() == _imp->env->system_root_key()->parse_value()))
+ if ((!repository->installed_root_key()) || (repository->installed_root_key()->parse_value() == _imp->env->system_root_key()->parse_value()))
continue;
}
break;
case dt_create_binary:
- if ((*r)->installed_root_key())
+ if (repository->installed_root_key())
continue;
break;
@@ -106,26 +104,22 @@ FindRepositoryForHelper::operator() (
break;
}
- if ((*r)->destination_interface() &&
- (*r)->destination_interface()->is_suitable_destination_for(decision.origin_id()))
+ if (repository->destination_interface() && repository->destination_interface()->is_suitable_destination_for(decision.origin_id()))
{
if (result)
{
- if (is_fake(*r) && ! is_fake(result))
- {
- }
- else if (is_fake(result) && ! is_fake(*r))
- {
- result = *r;
- }
+ if (is_fake(repository) && ! is_fake(result))
+ ;
+ else if (is_fake(result) && ! is_fake(repository))
+ result = repository;
else
- throw ConfigurationError("For '" + stringify(*decision.origin_id())
- + "' with destination type " + stringify(resolution->resolvent().destination_type())
- + ", don't know whether to install to ::" + stringify(result->name())
- + " or ::" + stringify((*r)->name()));
+ throw ConfigurationError("For '" + stringify(*decision.origin_id()) + "' with destination type " + stringify(resolution->resolvent().destination_type()) +
+ ", don't know whether to install to ::" + stringify(result->name()) + " or ::" + stringify(repository->name()));
}
else
- result = *r;
+ {
+ result = repository;
+ }
}
}
diff --git a/paludis/resolver/package_id_comparator_with_promotion.cc b/paludis/resolver/package_id_comparator_with_promotion.cc
index 8baa353..d9b8d94 100644
--- a/paludis/resolver/package_id_comparator_with_promotion.cc
+++ b/paludis/resolver/package_id_comparator_with_promotion.cc
@@ -50,8 +50,8 @@ PackageIDComparatorWithPromotion::PackageIDComparatorWithPromotion(const Environ
_imp()
{
unsigned c(0);
- for (auto r(e->begin_repositories()), r_end(e->end_repositories()) ; r != r_end ; ++r)
- _imp->m.insert(std::make_pair((*r)->name(), ++c));
+ for (const auto & repository : e->repositories())
+ _imp->m.insert(std::make_pair(repository->name(), ++c));
}
PackageIDComparatorWithPromotion::PackageIDComparatorWithPromotion(const PackageIDComparatorWithPromotion & other) :
diff --git a/src/clients/cave/cmd_find_candidates.cc b/src/clients/cave/cmd_find_candidates.cc
index 684a923..6c8500c 100644
--- a/src/clients/cave/cmd_find_candidates.cc
+++ b/src/clients/cave/cmd_find_candidates.cc
@@ -209,9 +209,8 @@ FindCandidatesCommand::run_hosted(
step("Searching repositories");
RepositoryNames repository_names;
- for (Environment::RepositoryConstIterator r(env->begin_repositories()),
- r_end(env->end_repositories()) ; r != r_end ; ++r)
- repository_names.insert((*r)->name());
+ for (const auto & repository : env->repositories())
+ repository_names.insert(repository->name());
step("Searching categories");
diff --git a/src/clients/cave/cmd_info.cc b/src/clients/cave/cmd_info.cc
index 72a755e..f01a9b3 100644
--- a/src/clients/cave/cmd_info.cc
+++ b/src/clients/cave/cmd_info.cc
@@ -403,9 +403,8 @@ InfoCommand::run(
do_about(cmdline, env);
do_env(cmdline, env);
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ;
- r != r_end ; ++r)
- do_one_repository(cmdline, env, *r);
+ for (const auto & repository : env->repositories())
+ do_one_repository(cmdline, env, repository);
if (cmdline.begin_parameters() == cmdline.end_parameters())
{
diff --git a/src/clients/cave/cmd_print_categories.cc b/src/clients/cave/cmd_print_categories.cc
index f276933..87526fd 100644
--- a/src/clients/cave/cmd_print_categories.cc
+++ b/src/clients/cave/cmd_print_categories.cc
@@ -95,12 +95,10 @@ PrintCategoriesCommand::run(
throw args::DoHelp("print-categories takes no parameters");
std::set<CategoryNamePart> categories;
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : env->repositories())
{
if (cmdline.a_repository.specified())
- if (cmdline.a_repository.end_args() == std::find(cmdline.a_repository.begin_args(),
- cmdline.a_repository.end_args(), stringify((*r)->name())))
+ if (cmdline.a_repository.end_args() == std::find(cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify(repository->name())))
continue;
if (cmdline.a_containing.specified())
@@ -108,13 +106,13 @@ PrintCategoriesCommand::run(
for (args::StringSetArg::ConstIterator p(cmdline.a_containing.begin_args()), p_end(cmdline.a_containing.end_args()) ;
p != p_end ; ++p)
{
- std::shared_ptr<const CategoryNamePartSet> cats((*r)->category_names_containing_package(PackageNamePart(*p), { }));
+ std::shared_ptr<const CategoryNamePartSet> cats(repository->category_names_containing_package(PackageNamePart(*p), { }));
std::copy(cats->begin(), cats->end(), std::inserter(categories, categories.begin()));
}
}
else
{
- std::shared_ptr<const CategoryNamePartSet> cats((*r)->category_names({ }));
+ std::shared_ptr<const CategoryNamePartSet> cats(repository->category_names({ }));
std::copy(cats->begin(), cats->end(), std::inserter(categories, categories.begin()));
}
}
diff --git a/src/clients/cave/cmd_print_packages.cc b/src/clients/cave/cmd_print_packages.cc
index 278f2e4..b765ea2 100644
--- a/src/clients/cave/cmd_print_packages.cc
+++ b/src/clients/cave/cmd_print_packages.cc
@@ -94,15 +94,13 @@ PrintPackagesCommand::run(
std::set<QualifiedPackageName> all_packages;
- for (auto r(env->begin_repositories()), r_end(env->end_repositories());
- r != r_end; ++r)
+ for (const auto & repository : env->repositories())
{
if (cmdline.a_repository.specified())
- if (cmdline.a_repository.end_args() == std::find(
- cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify((*r)->name())))
+ if (cmdline.a_repository.end_args() == std::find(cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify(repository->name())))
continue;
- std::shared_ptr<const CategoryNamePartSet> categories((*r)->category_names({ }));
+ std::shared_ptr<const CategoryNamePartSet> categories(repository->category_names({}));
for (CategoryNamePartSet::ConstIterator c(categories->begin()), c_end(categories->end());
c != c_end; ++c)
{
@@ -111,7 +109,7 @@ PrintPackagesCommand::run(
cmdline.a_category.begin_args(), cmdline.a_category.end_args(), stringify(*c)))
continue;
- std::shared_ptr<const QualifiedPackageNameSet> packages((*r)->package_names(*c, { }));
+ std::shared_ptr<const QualifiedPackageNameSet> packages(repository->package_names(*c, { }));
std::copy(packages->begin(), packages->end(), std::inserter(all_packages, all_packages.begin()));
}
}
diff --git a/src/clients/cave/cmd_print_unused_distfiles.cc b/src/clients/cave/cmd_print_unused_distfiles.cc
index 6bea355..47a3753 100644
--- a/src/clients/cave/cmd_print_unused_distfiles.cc
+++ b/src/clients/cave/cmd_print_unused_distfiles.cc
@@ -188,11 +188,10 @@ PrintUnusedDistfilesCommand::run(
std::set<FSPath, FSPathComparator> distdirs;
- for (auto repo(env->begin_repositories()), end(env->end_repositories()) ;
- repo != end ; ++repo)
+ for (const auto & repository : env->repositories())
{
- auto distdir_metadata((*repo)->find_metadata("distdir"));
- if (distdir_metadata != (*repo)->end_metadata())
+ auto distdir_metadata(repository->find_metadata("distdir"));
+ if (distdir_metadata != repository->end_metadata())
{
auto path_key(visitor_cast<const MetadataValueKey<FSPath>>(**distdir_metadata));
if (path_key)
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 5ca1f9d..cf31017 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -382,9 +382,8 @@ SyncCommand::run(
repos.insert(n);
}
else
- for (auto p(env->begin_repositories()), p_end(env->end_repositories()) ;
- p != p_end ; ++p)
- repos.insert((*p)->name());
+ for (const auto & repository : env->repositories())
+ repos.insert(repository->name());
if (1 == repos.size())
cmdline.a_sequential.set_specified(args::aos_weak);
@@ -400,10 +399,10 @@ SyncCommand::run(
retcode |= sync_these(env, cmdline, repos);
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ; r != r_end ; ++r)
+ for (const auto & repository : env->repositories())
{
- (*r)->invalidate();
- (*r)->purge_invalid_cache();
+ repository->invalidate();
+ repository->purge_invalid_cache();
}
if (0 != env->perform_hook(Hook("sync_all_post")