maint: Consistently name `Database` objects (#3831)

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
This commit is contained in:
Julien Jerphanion 2025-02-20 14:01:45 +01:00 committed by GitHub
parent e2fcd6066f
commit 148a25c44d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 166 additions and 146 deletions

View File

@ -30,7 +30,7 @@ namespace mamba
auto load_channels(
Context& ctx,
ChannelContext& channel_context,
solver::libsolv::Database& pool,
solver::libsolv::Database& database,
MultiPackageCache& package_caches
) -> expected_t<void, mamba_aggregated_error>;

View File

@ -23,7 +23,7 @@ namespace mamba
};
[[nodiscard]] auto make_repoquery(
solver::libsolv::Database& pool,
solver::libsolv::Database& database,
QueryType type,
QueryResultFormat format,
const std::vector<std::string>& queries,

View File

@ -22,17 +22,17 @@ namespace mamba
class Database;
}
void add_spdlog_logger_to_database(solver::libsolv::Database& db);
void add_spdlog_logger_to_database(solver::libsolv::Database& database);
auto load_subdir_in_database( //
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const SubdirData& subdir
) -> expected_t<solver::libsolv::RepoInfo>;
auto load_installed_packages_in_database(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const PrefixData& prefix
) -> solver::libsolv::RepoInfo;
}

View File

@ -94,12 +94,14 @@ namespace mamba
using Database = solver::libsolv::Database;
[[nodiscard]] static auto find(Database& db, const std::vector<std::string>& queries)
[[nodiscard]] static auto find(Database& database, const std::vector<std::string>& queries)
-> QueryResult;
[[nodiscard]] static auto whoneeds(Database& db, std::string query, bool tree) -> QueryResult;
[[nodiscard]] static auto whoneeds(Database& database, std::string query, bool tree)
-> QueryResult;
[[nodiscard]] static auto depends(Database& db, std::string query, bool tree) -> QueryResult;
[[nodiscard]] static auto depends(Database& database, std::string query, bool tree)
-> QueryResult;
};
/********************

View File

@ -37,7 +37,7 @@ namespace mamba
MTransaction(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
std::vector<specs::PackageInfo> pkgs_to_remove,
std::vector<specs::PackageInfo> pkgs_to_install,
MultiPackageCache& caches
@ -45,7 +45,7 @@ namespace mamba
MTransaction(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const solver::Request& request,
solver::Solution solution,
MultiPackageCache& caches
@ -54,7 +54,7 @@ namespace mamba
// Only use if the packages have been solved previously already.
MTransaction(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
std::vector<specs::PackageInfo> packages,
MultiPackageCache& caches
);
@ -93,7 +93,7 @@ namespace mamba
MTransaction create_explicit_transaction_from_urls(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const std::vector<std::string>& urls,
MultiPackageCache& package_caches,
std::vector<detail::other_pkg_mgr_spec>& other_specs
@ -101,7 +101,7 @@ namespace mamba
MTransaction create_explicit_transaction_from_lockfile(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const fs::u8path& env_lockfile_path,
const std::vector<std::string>& categories,
MultiPackageCache& package_caches,

View File

@ -133,8 +133,8 @@ namespace mamba::solver::libsolv
*/
class Impl
{
[[nodiscard]] static auto get(Database& pool) -> solv::ObjPool&;
[[nodiscard]] static auto get(const Database& pool) -> const solv::ObjPool&;
[[nodiscard]] static auto get(Database& database) -> solv::ObjPool&;
[[nodiscard]] static auto get(const Database& database) -> const solv::ObjPool&;
friend class Solver;
friend class UnSolvable;

View File

@ -22,12 +22,12 @@ namespace mamba::solver::libsolv
using Outcome = std::variant<Solution, UnSolvable>;
[[nodiscard]] auto solve(Database& pool, Request&& request) -> expected_t<Outcome>;
[[nodiscard]] auto solve(Database& pool, const Request& request) -> expected_t<Outcome>;
[[nodiscard]] auto solve(Database& database, Request&& request) -> expected_t<Outcome>;
[[nodiscard]] auto solve(Database& database, const Request& request) -> expected_t<Outcome>;
private:
auto solve_impl(Database& pool, const Request& request) -> expected_t<Outcome>;
auto solve_impl(Database& database, const Request& request) -> expected_t<Outcome>;
};
}
#endif

View File

@ -39,22 +39,23 @@ namespace mamba::solver::libsolv
auto operator=(UnSolvable&&) -> UnSolvable&;
[[nodiscard]] auto problems(Database& pool) const -> std::vector<std::string>;
[[nodiscard]] auto problems(Database& database) const -> std::vector<std::string>;
[[nodiscard]] auto problems_to_str(Database& pool) const -> std::string;
[[nodiscard]] auto problems_to_str(Database& database) const -> std::string;
[[nodiscard]] auto all_problems_to_str(Database& pool) const -> std::string;
[[nodiscard]] auto all_problems_to_str(Database& database) const -> std::string;
[[nodiscard]] auto problems_graph(const Database& pool) const -> ProblemsGraph;
[[nodiscard]] auto problems_graph(const Database& database) const -> ProblemsGraph;
auto explain_problems_to( //
Database& pool,
Database& database,
std::ostream& out,
const ProblemsMessageFormat& format
) const -> std::ostream&;
[[nodiscard]] auto
explain_problems(Database& pool, const ProblemsMessageFormat& format) const -> std::string;
explain_problems(Database& database, const ProblemsMessageFormat& format) const
-> std::string;
private:

View File

@ -22,7 +22,7 @@ namespace mamba
auto create_repo_from_pkgs_dir(
const Context& ctx,
ChannelContext& channel_context,
solver::libsolv::Database& pool,
solver::libsolv::Database& database,
const fs::u8path& pkgs_dir
) -> solver::libsolv::RepoInfo
{
@ -46,7 +46,7 @@ namespace mamba
}
prefix_data.load_single_record(repodata_record_json);
}
return load_installed_packages_in_database(ctx, pool, prefix_data);
return load_installed_packages_in_database(ctx, database, prefix_data);
}
void create_subdirs(
@ -125,7 +125,7 @@ namespace mamba
auto load_channels_impl(
Context& ctx,
ChannelContext& channel_context,
solver::libsolv::Database& pool,
solver::libsolv::Database& database,
MultiPackageCache& package_caches,
bool is_retry
) -> expected_t<void, mamba_aggregated_error>
@ -196,7 +196,7 @@ namespace mamba
if (!packages.empty())
{
pool.add_repo_from_packages(packages, "packages");
database.add_repo_from_packages(packages, "packages");
}
expected_t<void> download_res;
@ -227,7 +227,7 @@ namespace mamba
LOG_INFO << "Creating repo from pkgs_dir for offline";
for (const auto& c : ctx.pkgs_dirs)
{
create_repo_from_pkgs_dir(ctx, channel_context, pool, c);
create_repo_from_pkgs_dir(ctx, channel_context, database, c);
}
}
std::string prev_channel;
@ -247,9 +247,9 @@ namespace mamba
continue;
}
load_subdir_in_database(ctx, pool, subdir)
load_subdir_in_database(ctx, database, subdir)
.transform([&](solver::libsolv::RepoInfo&& repo)
{ pool.set_repo_priority(repo, priorities[i]); })
{ database.set_repo_priority(repo, priorities[i]); })
.or_else(
[&](const auto&)
{
@ -279,7 +279,8 @@ namespace mamba
if (!ctx.offline && !is_retry)
{
LOG_WARNING << "Encountered malformed repodata.json cache. Redownloading.";
return load_channels_impl(ctx, channel_context, pool, package_caches, true);
bool retry = true;
return load_channels_impl(ctx, channel_context, database, package_caches, retry);
}
error_list.emplace_back(
"Could not load repodata. Cache corrupted?",
@ -295,11 +296,12 @@ namespace mamba
auto load_channels(
Context& ctx,
ChannelContext& channel_context,
solver::libsolv::Database& pool,
solver::libsolv::Database& database,
MultiPackageCache& package_caches
) -> expected_t<void, mamba_aggregated_error>
{
return load_channels_impl(ctx, channel_context, pool, package_caches, false);
bool retry = false;
return load_channels_impl(ctx, channel_context, database, package_caches, retry);
}
void init_channels(Context& context, ChannelContext& channel_context)

View File

@ -36,6 +36,7 @@ namespace mamba
auto channel_context = ChannelContext::make_conda_compatible(ctx);
bool remove_prefix_on_failure = false;
bool create_env = true;
if (!ctx.dry_run)
{
@ -105,7 +106,7 @@ namespace mamba
channel_context,
lockfile_path,
config.at("categories").value<std::vector<std::string>>(),
true,
create_env,
remove_prefix_on_failure
);
}
@ -113,11 +114,24 @@ namespace mamba
{
if (use_explicit)
{
install_explicit_specs(ctx, channel_context, create_specs, true, remove_prefix_on_failure);
install_explicit_specs(
ctx,
channel_context,
create_specs,
create_env,
remove_prefix_on_failure
);
}
else
{
install_specs(ctx, channel_context, config, create_specs, true, remove_prefix_on_failure);
install_specs(
ctx,
channel_context,
config,
create_specs,
create_env,
remove_prefix_on_failure
);
}
}
}

View File

@ -419,13 +419,7 @@ namespace mamba
solver::libsolv::Database db{ channel_context.params() };
add_spdlog_logger_to_database(db);
// functions implied in 'and_then' coding-styles must return the same type
// which limits this syntax
/*auto exp_prefix_data = load_channels(pool, package_caches)
.and_then([&ctx](const auto&) { return
PrefixData::create(ctx.prefix_params.target_prefix); } ) .map_error([](const
mamba_error& err) { throw std::runtime_error(err.what());
});*/
auto exp_load = load_channels(ctx, channel_context, db, package_caches);
if (!exp_load)
{
@ -467,6 +461,7 @@ namespace mamba
if (retry_clean_cache && !is_retry)
{
ctx.local_repodata_ttl = 2;
bool retry = true;
return install_specs_impl(
ctx,
channel_context,
@ -474,7 +469,7 @@ namespace mamba
raw_specs,
create_env,
remove_prefix_on_failure,
true
retry
);
}
if (freeze_installed)
@ -574,6 +569,7 @@ namespace mamba
bool remove_prefix_on_failure
)
{
auto is_retry = false;
return install_specs_impl(
ctx,
channel_context,
@ -581,14 +577,14 @@ namespace mamba
specs,
create_env,
remove_prefix_on_failure,
false
is_retry
);
}
namespace
{
// TransactionFunc: (Database& pool, MultiPackageCache& package_caches) -> MTransaction
// TransactionFunc: (Database& database, MultiPackageCache& package_caches) -> MTransaction
template <typename TransactionFunc>
void install_explicit_with_transaction(
Context& ctx,
@ -599,8 +595,8 @@ namespace mamba
bool remove_prefix_on_failure
)
{
solver::libsolv::Database db{ channel_context.params() };
add_spdlog_logger_to_database(db);
solver::libsolv::Database database{ channel_context.params() };
add_spdlog_logger_to_database(database);
init_channels(ctx, channel_context);
// Some use cases provide a list of explicit specs, but an empty
@ -619,12 +615,12 @@ namespace mamba
MultiPackageCache pkg_caches(ctx.pkgs_dirs, ctx.validation_params);
load_installed_packages_in_database(ctx, db, prefix_data);
load_installed_packages_in_database(ctx, database, prefix_data);
std::vector<detail::other_pkg_mgr_spec> others;
// Note that the Transaction will gather the Solvables,
// so they must have been ready in the pool before this line
auto transaction = create_transaction(db, pkg_caches, others);
// so they must have been ready in the database's pool before this line
auto transaction = create_transaction(database, pkg_caches, others);
std::vector<LockFile> lock_pkgs;

View File

@ -136,9 +136,9 @@ namespace mamba
}
PrefixData& prefix_data = exp_prefix_data.value();
solver::libsolv::Database pool{ channel_context.params() };
add_spdlog_logger_to_database(pool);
load_installed_packages_in_database(ctx, pool, prefix_data);
solver::libsolv::Database database{ channel_context.params() };
add_spdlog_logger_to_database(database);
load_installed_packages_in_database(ctx, database, prefix_data);
const fs::u8path pkgs_dirs(ctx.prefix_params.root_prefix / "pkgs");
MultiPackageCache package_caches({ pkgs_dirs }, ctx.validation_params);
@ -175,7 +175,7 @@ namespace mamba
pkgs_to_remove.push_back(iter->second);
}
}
auto transaction = MTransaction(ctx, pool, pkgs_to_remove, {}, package_caches);
auto transaction = MTransaction(ctx, database, pkgs_to_remove, {}, package_caches);
return execute_transaction(transaction);
}
else
@ -190,14 +190,14 @@ namespace mamba
/* .strict_repo_priority= */ ctx.channel_priority == ChannelPriority::Strict,
};
auto outcome = solver::libsolv::Solver().solve(pool, request).value();
auto outcome = solver::libsolv::Solver().solve(database, request).value();
if (auto* unsolvable = std::get_if<solver::libsolv::UnSolvable>(&outcome))
{
if (ctx.output_params.json)
{
Console::instance().json_write(
{ { "success", false }, { "solver_problems", unsolvable->problems(pool) } }
);
Console::instance().json_write({ { "success", false },
{ "solver_problems",
unsolvable->problems(database) } });
}
throw mamba_error(
"Could not solve for environment specs",
@ -208,7 +208,7 @@ namespace mamba
Console::instance().json_write({ { "success", true } });
auto transaction = MTransaction(
ctx,
pool,
database,
request,
std::get<solver::Solution>(outcome),
package_caches

View File

@ -82,7 +82,7 @@ namespace mamba
}
auto make_repoquery(
solver::libsolv::Database& db,
solver::libsolv::Database& database,
QueryType type,
QueryResultFormat format,
const std::vector<std::string>& queries,
@ -93,7 +93,7 @@ namespace mamba
{
if (type == QueryType::Search)
{
auto res = Query::find(db, queries);
auto res = Query::find(database, queries);
switch (format)
{
case QueryResultFormat::Json:
@ -114,7 +114,7 @@ namespace mamba
throw std::invalid_argument("Only one query supported for 'depends'.");
}
auto res = Query::depends(
db,
database,
queries.front(),
/* tree= */ format == QueryResultFormat::Tree
|| format == QueryResultFormat::RecursiveTable
@ -141,7 +141,7 @@ namespace mamba
throw std::invalid_argument("Only one query supported for 'whoneeds'.");
}
auto res = Query::whoneeds(
db,
database,
queries.front(),
/* tree= */ format == QueryResultFormat::Tree
|| format == QueryResultFormat::RecursiveTable

View File

@ -28,9 +28,9 @@
namespace mamba
{
void add_spdlog_logger_to_database(solver::libsolv::Database& db)
void add_spdlog_logger_to_database(solver::libsolv::Database& database)
{
db.set_logger(
database.set_logger(
[logger = spdlog::get("libsolv")](solver::libsolv::LogLevel level, std::string_view msg)
{
switch (level)
@ -53,7 +53,7 @@ namespace mamba
}
auto
load_subdir_in_database(const Context& ctx, solver::libsolv::Database& db, const SubdirData& subdir)
load_subdir_in_database(const Context& ctx, solver::libsolv::Database& database, const SubdirData& subdir)
-> expected_t<solver::libsolv::RepoInfo>
{
const auto expected_cache_origin = solver::libsolv::RepodataOrigin{
@ -75,7 +75,7 @@ namespace mamba
auto maybe_repo = subdir.valid_solv_cache().and_then(
[&](fs::u8path&& solv_file)
{
return db.add_repo_from_native_serialization(
return database.add_repo_from_native_serialization(
solv_file,
expected_cache_origin,
subdir.channel_id(),
@ -96,7 +96,7 @@ namespace mamba
using PackageTypes = solver::libsolv::PackageTypes;
LOG_INFO << "Trying to load repo from json file " << repodata_json;
return db.add_repo_from_repodata_json(
return database.add_repo_from_repodata_json(
repodata_json,
util::rsplit(subdir.metadata().url(), "/", 1).front(),
subdir.channel_id(),
@ -114,7 +114,8 @@ namespace mamba
{
if (!util::on_win)
{
db.native_serialize_repo(repo, subdir.writable_solv_cache(), expected_cache_origin)
database
.native_serialize_repo(repo, subdir.writable_solv_cache(), expected_cache_origin)
.or_else(
[&](const auto& err)
{
@ -132,7 +133,7 @@ namespace mamba
auto load_installed_packages_in_database(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const PrefixData& prefix
) -> solver::libsolv::RepoInfo
{
@ -146,12 +147,12 @@ namespace mamba
// Not adding Pip dependency since it might needlessly make the installed/active environment
// broken if pip is not already installed (debatable).
auto repo = db.add_repo_from_packages(
auto repo = database.add_repo_from_packages(
pkgs,
"installed",
solver::libsolv::PipAsPythonDependency::No
);
db.set_installed_repo(repo);
database.set_installed_repo(repo);
return repo;
}
}

View File

@ -75,11 +75,11 @@ namespace mamba
}
};
auto database_latest_package(solver::libsolv::Database& db, specs::MatchSpec spec)
auto database_latest_package(solver::libsolv::Database& database, specs::MatchSpec spec)
-> std::optional<specs::PackageInfo>
{
auto out = std::optional<specs::PackageInfo>();
db.for_each_package_matching(
database.for_each_package_matching(
spec,
[&](auto pkg)
{
@ -99,7 +99,7 @@ namespace mamba
using DepGraph = typename QueryResult::dependency_graph;
using node_id = typename QueryResult::dependency_graph::node_id;
PoolWalker(solver::libsolv::Database& db);
PoolWalker(solver::libsolv::Database& database);
void walk(specs::PackageInfo pkg, std::size_t max_depth);
void walk(specs::PackageInfo pkg);
@ -122,8 +122,8 @@ namespace mamba
void reverse_walk_impl(node_id id);
};
PoolWalker::PoolWalker(solver::libsolv::Database& db)
: m_database(db)
PoolWalker::PoolWalker(solver::libsolv::Database& database)
: m_database(database)
{
}
@ -219,7 +219,7 @@ namespace mamba
}
}
auto Query::find(Database& db, const std::vector<std::string>& queries) -> QueryResult
auto Query::find(Database& database, const std::vector<std::string>& queries) -> QueryResult
{
QueryResult::dependency_graph g;
for (const auto& query : queries)
@ -227,7 +227,7 @@ namespace mamba
const auto ms = specs::MatchSpec::parse(query)
.or_else([](specs::ParseError&& err) { throw std::move(err); })
.value();
db.for_each_package_matching(
database.for_each_package_matching(
ms,
[&](specs::PackageInfo&& pkg) { g.add_node(std::move(pkg)); }
);
@ -240,16 +240,16 @@ namespace mamba
};
}
auto Query::whoneeds(Database& db, std::string query, bool tree) -> QueryResult
auto Query::whoneeds(Database& database, std::string query, bool tree) -> QueryResult
{
const auto ms = specs::MatchSpec::parse(query)
.or_else([](specs::ParseError&& err) { throw std::move(err); })
.value();
if (tree)
{
if (auto pkg = database_latest_package(db, ms))
if (auto pkg = database_latest_package(database, ms))
{
auto walker = PoolWalker(db);
auto walker = PoolWalker(database);
walker.reverse_walk(std::move(pkg).value());
return { QueryType::WhoNeeds, std::move(query), std::move(walker).graph() };
}
@ -257,7 +257,7 @@ namespace mamba
else
{
QueryResult::dependency_graph g;
db.for_each_package_depending_on(
database.for_each_package_depending_on(
ms,
[&](specs::PackageInfo&& pkg) { g.add_node(std::move(pkg)); }
);
@ -266,14 +266,14 @@ namespace mamba
return { QueryType::WhoNeeds, std::move(query), QueryResult::dependency_graph() };
}
auto Query::depends(Database& db, std::string query, bool tree) -> QueryResult
auto Query::depends(Database& database, std::string query, bool tree) -> QueryResult
{
const auto ms = specs::MatchSpec::parse(query)
.or_else([](specs::ParseError&& err) { throw std::move(err); })
.value();
if (auto pkg = database_latest_package(db, ms))
if (auto pkg = database_latest_package(database, ms))
{
auto walker = PoolWalker(db);
auto walker = PoolWalker(database);
if (tree)
{
walker.walk(std::move(pkg).value());

View File

@ -76,10 +76,11 @@ namespace mamba
}
// TODO duplicated function, consider moving it to Pool
auto database_has_package(solver::libsolv::Database& db, const specs::MatchSpec& spec) -> bool
auto database_has_package(solver::libsolv::Database& database, const specs::MatchSpec& spec)
-> bool
{
bool found = false;
db.for_each_package_matching(
database.for_each_package_matching(
spec,
[&](const auto&)
{
@ -110,14 +111,14 @@ namespace mamba
return out;
}
auto installed_python(const solver::libsolv::Database& db)
auto installed_python(const solver::libsolv::Database& database)
-> std::optional<specs::PackageInfo>
{
// TODO combine Repo and MatchSpec search API in Pool
auto out = std::optional<specs::PackageInfo>();
if (auto repo = db.installed_repo())
if (auto repo = database.installed_repo())
{
db.for_each_package_in_repo(
database.for_each_package_in_repo(
*repo,
[&](specs::PackageInfo&& pkg)
{
@ -134,7 +135,7 @@ namespace mamba
}
auto
find_python_version(const solver::Solution& solution, const solver::libsolv::Database& db)
find_python_version(const solver::Solution& solution, const solver::libsolv::Database& database)
-> std::pair<std::string, std::string>
{
// We need to find the python version that will be there after this
@ -144,7 +145,7 @@ namespace mamba
// version but keeping the current one.
// Could also be written in term of PrefixData.
std::string installed_py_ver = {};
if (auto pkg = installed_python(db))
if (auto pkg = installed_python(database))
{
installed_py_ver = pkg->version;
LOG_INFO << "Found python in installed packages " << installed_py_ver;
@ -168,7 +169,7 @@ namespace mamba
MTransaction::MTransaction(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
std::vector<specs::PackageInfo> pkgs_to_remove,
std::vector<specs::PackageInfo> pkgs_to_install,
MultiPackageCache& caches
@ -179,7 +180,7 @@ namespace mamba
for (const auto& pkg : pkgs_to_remove)
{
auto spec = explicit_spec(pkg);
if (!database_has_package(db, spec))
if (!database_has_package(database, spec))
{
not_found << "\n - " << spec.str();
}
@ -241,14 +242,14 @@ namespace mamba
ctx,
ctx.prefix_params.target_prefix,
ctx.prefix_params.relocate_prefix,
find_python_version(m_solution, db),
find_python_version(m_solution, database),
specs_to_install
);
}
MTransaction::MTransaction(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const solver::Request& request,
solver::Solution solution,
MultiPackageCache& caches
@ -295,7 +296,7 @@ namespace mamba
ctx,
ctx.prefix_params.target_prefix,
ctx.prefix_params.relocate_prefix,
find_python_version(m_solution, db),
find_python_version(m_solution, database),
std::move(requested_specs)
);
@ -311,7 +312,7 @@ namespace mamba
MTransaction::MTransaction(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
std::vector<specs::PackageInfo> packages,
MultiPackageCache& caches
)
@ -347,7 +348,7 @@ namespace mamba
ctx,
ctx.prefix_params.target_prefix,
ctx.prefix_params.relocate_prefix,
find_python_version(m_solution, db),
find_python_version(m_solution, database),
std::move(specs_to_install)
);
}
@ -1110,7 +1111,7 @@ namespace mamba
}
MTransaction
create_explicit_transaction_from_urls(const Context& ctx, solver::libsolv::Database& db, const std::vector<std::string>& urls, MultiPackageCache& package_caches, std::vector<detail::other_pkg_mgr_spec>&)
create_explicit_transaction_from_urls(const Context& ctx, solver::libsolv::Database& database, const std::vector<std::string>& urls, MultiPackageCache& package_caches, std::vector<detail::other_pkg_mgr_spec>&)
{
std::vector<specs::PackageInfo> specs_to_install = {};
specs_to_install.reserve(urls.size());
@ -1125,12 +1126,12 @@ namespace mamba
.value();
}
);
return MTransaction(ctx, db, {}, specs_to_install, package_caches);
return MTransaction(ctx, database, {}, specs_to_install, package_caches);
}
MTransaction create_explicit_transaction_from_lockfile(
const Context& ctx,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
const fs::u8path& env_lockfile_path,
const std::vector<std::string>& categories,
MultiPackageCache& package_caches,
@ -1194,7 +1195,7 @@ namespace mamba
);
}
return MTransaction{ ctx, db, std::move(conda_packages), package_caches };
return MTransaction{ ctx, database, std::move(conda_packages), package_caches };
}
} // namespace mamba

View File

@ -72,14 +72,14 @@ namespace mamba::solver::libsolv
return m_data->pool;
}
auto Database::Impl::get(Database& pool) -> solv::ObjPool&
auto Database::Impl::get(Database& database) -> solv::ObjPool&
{
return pool.pool();
return database.pool();
}
auto Database::Impl::get(const Database& pool) -> const solv::ObjPool&
auto Database::Impl::get(const Database& database) -> const solv::ObjPool&
{
return pool.pool();
return database.pool();
}
auto Database::channel_params() const -> const specs::ChannelResolveParams&

View File

@ -42,9 +42,9 @@ namespace mamba::solver::libsolv
return *m_solver;
}
auto UnSolvable::problems(Database& db) const -> std::vector<std::string>
auto UnSolvable::problems(Database& database) const -> std::vector<std::string>
{
auto& pool = Database::Impl::get(db);
auto& pool = Database::Impl::get(database);
std::vector<std::string> problems;
solver().for_each_problem_id([&](solv::ProblemId pb)
{ problems.emplace_back(solver().problem_to_string(pool, pb)); }
@ -52,9 +52,9 @@ namespace mamba::solver::libsolv
return problems;
}
auto UnSolvable::problems_to_str(Database& db) const -> std::string
auto UnSolvable::problems_to_str(Database& database) const -> std::string
{
auto& pool = Database::Impl::get(db);
auto& pool = Database::Impl::get(database);
std::stringstream problems;
problems << "Encountered problems while solving:\n";
solver().for_each_problem_id(
@ -64,9 +64,9 @@ namespace mamba::solver::libsolv
return problems.str();
}
auto UnSolvable::all_problems_to_str(Database& db) const -> std::string
auto UnSolvable::all_problems_to_str(Database& database) const -> std::string
{
auto& pool = Database::Impl::get(db);
auto& pool = Database::Impl::get(database);
std::stringstream problems;
solver().for_each_problem_id(
[&](solv::ProblemId pb)
@ -565,32 +565,32 @@ namespace mamba::solver::libsolv
}
}
auto UnSolvable::problems_graph(const Database& pool) const -> ProblemsGraph
auto UnSolvable::problems_graph(const Database& database) const -> ProblemsGraph
{
assert(m_solver != nullptr);
return ProblemsGraphCreator(Database::Impl::get(pool), *m_solver).problem_graph();
return ProblemsGraphCreator(Database::Impl::get(database), *m_solver).problem_graph();
}
auto UnSolvable::explain_problems_to(
Database& pool,
Database& database,
std::ostream& out,
const ProblemsMessageFormat& format
) const -> std::ostream&
{
out << "Could not solve for environment specs\n";
const auto pbs = problems_graph(pool);
const auto pbs = problems_graph(database);
const auto pbs_simplified = simplify_conflicts(pbs);
const auto cp_pbs = CompressedProblemsGraph::from_problems_graph(pbs_simplified);
print_problem_tree_msg(out, cp_pbs, format);
return out;
}
auto UnSolvable::explain_problems(Database& pool, const ProblemsMessageFormat& format) const
auto UnSolvable::explain_problems(Database& database, const ProblemsMessageFormat& format) const
-> std::string
{
std::stringstream ss;
explain_problems_to(pool, ss, format);
explain_problems_to(database, ss, format);
return ss.str();
}
}

View File

@ -288,7 +288,7 @@ namespace mamba::specs
);
}
void set_fallback_credential_from_db(CondaURL& url, const AuthenticationDataBase& db)
void set_fallback_credential_from_db(CondaURL& url, const AuthenticationDataBase& database)
{
if (!url.has_token() || !url.has_user() || !url.has_password())
{
@ -297,7 +297,7 @@ namespace mamba::specs
'/',
CondaURL::Credentials::Remove
);
if (auto it = db.find_weaken(key); it != db.end())
if (auto it = database.find_weaken(key); it != database.end())
{
set_fallback_credential_from_auth(url, it->second);
}

View File

@ -329,7 +329,7 @@ namespace
auto load_channels(
Context& ctx,
ChannelContext& channel_context,
solver::libsolv::Database& db,
solver::libsolv::Database& database,
MultiPackageCache& cache,
std::vector<std::string>&& channels
)
@ -353,7 +353,7 @@ namespace
for (auto& sub_dir : sub_dirs)
{
auto repo = load_subdir_in_database(ctx, db, sub_dir);
auto repo = load_subdir_in_database(ctx, database, sub_dir);
}
}

View File

@ -513,11 +513,11 @@ bind_submodule_impl(pybind11::module_ m)
py::class_<SubdirData>(m, "SubdirData")
.def(
"create_repo",
[](SubdirData& self, Context& context, solver::libsolv::Database& db
[](SubdirData& self, Context& context, solver::libsolv::Database& database
) -> solver::libsolv::RepoInfo
{
deprecated("Use libmambapy.load_subdir_in_database instead", "2.0");
return extract(load_subdir_in_database(context, db, self));
return extract(load_subdir_in_database(context, database, self));
},
py::arg("context"),
py::arg("db")

View File

@ -140,7 +140,10 @@ namespace mambapy
)
.def(
"add_repo_from_packages",
[](Database& db, py::iterable packages, std::string_view name, PipAsPythonDependency add)
[](Database& database,
py::iterable packages,
std::string_view name,
PipAsPythonDependency add)
{
// TODO(C++20): No need to copy in a vector, simply transform the input range.
auto pkg_infos = std::vector<specs::PackageInfo>();
@ -148,7 +151,7 @@ namespace mambapy
{
pkg_infos.push_back(pkg.cast<specs::PackageInfo>());
}
return db.add_repo_from_packages(pkg_infos, name, add);
return database.add_repo_from_packages(pkg_infos, name, add);
},
py::arg("packages"),
py::arg("name") = "",
@ -169,12 +172,12 @@ namespace mambapy
.def("package_count", &Database::package_count)
.def(
"packages_in_repo",
[](const Database& db, RepoInfo repo)
[](const Database& database, RepoInfo repo)
{
// TODO(C++20): When Database function are refactored to use range, take the
// opportunity here to make a Python iterator to avoid large alloc.
auto out = py::list();
db.for_each_package_in_repo(
database.for_each_package_in_repo(
repo,
[&](specs::PackageInfo&& pkg) { out.append(std::move(pkg)); }
);
@ -184,12 +187,12 @@ namespace mambapy
)
.def(
"packages_matching",
[](Database& db, const specs::MatchSpec& ms)
[](Database& database, const specs::MatchSpec& ms)
{
// TODO(C++20): When Database function are refactored to use range, take the
// opportunity here to make a Python iterator to avoid large alloc.
auto out = py::list();
db.for_each_package_matching(
database.for_each_package_matching(
ms,
[&](specs::PackageInfo&& pkg) { out.append(std::move(pkg)); }
);
@ -199,12 +202,12 @@ namespace mambapy
)
.def(
"packages_depending_on",
[](Database& db, const specs::MatchSpec& ms)
[](Database& database, const specs::MatchSpec& ms)
{
// TODO(C++20): When Database function are refactored to use range, take the
// opportunity here to make a Python iterator to avoid large alloc.
auto out = py::list();
db.for_each_package_depending_on(
database.for_each_package_depending_on(
ms,
[&](specs::PackageInfo&& pkg) { out.append(std::move(pkg)); }
);
@ -236,8 +239,8 @@ namespace mambapy
.def(py::init())
.def(
"solve",
[](Solver& self, Database& db, const solver::Request& request)
{ return self.solve(db, request); }
[](Solver& self, Database& database, const solver::Request& request)
{ return self.solve(database, request); }
)
.def("add_jobs", solver_job_v2_migrator)
.def("add_global_job", solver_job_v2_migrator)

View File

@ -43,11 +43,11 @@ namespace
return found;
};
auto database_latest_package(solver::libsolv::Database& db, specs::MatchSpec spec)
auto database_latest_package(solver::libsolv::Database& database, specs::MatchSpec spec)
-> std::optional<specs::PackageInfo>
{
auto out = std::optional<specs::PackageInfo>();
db.for_each_package_matching(
database.for_each_package_matching(
spec,
[&](auto pkg)
{
@ -75,12 +75,12 @@ update_self(Configuration& config, const std::optional<std::string>& version)
auto channel_context = ChannelContext::make_conda_compatible(ctx);
solver::libsolv::Database db{ channel_context.params() };
add_spdlog_logger_to_database(db);
solver::libsolv::Database database{ channel_context.params() };
add_spdlog_logger_to_database(database);
mamba::MultiPackageCache package_caches(ctx.pkgs_dirs, ctx.validation_params);
auto exp_loaded = load_channels(ctx, channel_context, db, package_caches);
auto exp_loaded = load_channels(ctx, channel_context, database, package_caches);
if (!exp_loaded)
{
throw exp_loaded.error();
@ -93,11 +93,11 @@ update_self(Configuration& config, const std::optional<std::string>& version)
.or_else([](specs::ParseError&& err) { throw std::move(err); })
.value();
auto latest_micromamba = database_latest_package(db, matchspec);
auto latest_micromamba = database_latest_package(database, matchspec);
if (!latest_micromamba.has_value())
{
if (database_has_package(db, specs::MatchSpec::parse("micromamba").value()))
if (database_has_package(database, specs::MatchSpec::parse("micromamba").value()))
{
Console::instance().print(
fmt::format("\nYour micromamba version ({}) is already up to date.", umamba::version())
@ -125,7 +125,7 @@ update_self(Configuration& config, const std::optional<std::string>& version)
);
ctx.download_only = true;
MTransaction t(ctx, db, { latest_micromamba.value() }, package_caches);
MTransaction t(ctx, database, { latest_micromamba.value() }, package_caches);
auto exp_prefix_data = PrefixData::create(ctx.prefix_params.root_prefix, channel_context);
if (!exp_prefix_data)
{