Skip to content

Commit

Permalink
maint: Move solver::libsolv::repo_info to solver::repo_info
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Aug 1, 2024
1 parent bc89383 commit 0b09415
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ set(
# Solver generic interface
${LIBMAMBA_SOURCE_DIR}/solver/helpers.cpp
${LIBMAMBA_SOURCE_DIR}/solver/problems_graph.cpp
${LIBMAMBA_SOURCE_DIR}/solver/repo_info.cpp
# Solver libsolv implementation
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/database.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/helpers.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/matcher.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/parameters.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/repo_info.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/solver.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/unsolvable.cpp
# Artifacts validation
Expand Down Expand Up @@ -323,12 +323,12 @@ set(
${LIBMAMBA_INCLUDE_DIR}/mamba/specs/version_spec.hpp
# Solver generic interface
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/problems_graph.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/repo_info.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/request.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/solution.hpp
# Solver libsolv implementation
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/database.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/parameters.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/repo_info.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/solver.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/unsolvable.hpp
# Artifacts validation
Expand Down
6 changes: 3 additions & 3 deletions libmamba/include/mamba/core/package_database_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define MAMBA_CORE_PACKAGE_DATABASE_LOADER_HPP

#include "mamba/core/error_handling.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/channel.hpp"

namespace mamba
Expand All @@ -28,12 +28,12 @@ namespace mamba
const Context& ctx,
solver::libsolv::Database& db,
const SubdirData& subdir
) -> expected_t<solver::libsolv::RepoInfo>;
) -> expected_t<solver::RepoInfo>;

auto load_installed_packages_in_database(
const Context& ctx,
solver::libsolv::Database& db,
const PrefixData& prefix
) -> solver::libsolv::RepoInfo;
) -> solver::RepoInfo;
}
#endif
2 changes: 1 addition & 1 deletion libmamba/include/mamba/solver/libsolv/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "mamba/core/error_handling.hpp"
#include "mamba/solver/libsolv/parameters.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/channel.hpp"
#include "mamba/specs/package_info.hpp"
#include "mamba/util/loop_control.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ extern "C"
using Repo = struct s_Repo;
}

namespace mamba::solver::libsolv
namespace mamba::solver
{
class Database;
namespace libsolv
{
class Database;
}

/**
* A libsolv repository descriptor.
Expand Down Expand Up @@ -50,15 +53,15 @@ namespace mamba::solver::libsolv

[[nodiscard]] auto package_count() const -> std::size_t;

[[nodiscard]] auto priority() const -> Priorities;
[[nodiscard]] auto priority() const -> libsolv::Priorities;

private:

::Repo* m_ptr = nullptr; // This is a view managed by libsolv pool

explicit RepoInfo(::Repo* repo);

friend class Database;
friend class mamba::solver::libsolv::Database;
friend auto operator==(RepoInfo lhs, RepoInfo rhs) -> bool;
};

Expand Down
6 changes: 3 additions & 3 deletions libmamba/src/api/channel_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "mamba/core/prefix_data.hpp"
#include "mamba/core/subdirdata.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/package_info.hpp"

namespace mamba
Expand All @@ -24,7 +24,7 @@ namespace mamba
ChannelContext& channel_context,
solver::libsolv::Database& pool,
const fs::u8path& pkgs_dir
) -> solver::libsolv::RepoInfo
) -> solver::RepoInfo
{
if (!fs::exists(pkgs_dir))
{
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace mamba
}

load_subdir_in_database(ctx, pool, subdir)
.transform([&](solver::libsolv::RepoInfo&& repo)
.transform([&](solver::RepoInfo&& repo)
{ pool.set_repo_priority(repo, priorities[i]); })
.or_else(
[&](const auto&)
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "mamba/core/package_database_loader.hpp"
#include "mamba/core/prefix_data.hpp"
#include "mamba/core/transaction.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/libsolv/solver.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/solver/request.hpp"

namespace mamba
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/repoquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "mamba/core/package_database_loader.hpp"
#include "mamba/core/prefix_data.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/util/string.hpp"

namespace mamba
Expand Down
8 changes: 4 additions & 4 deletions libmamba/src/core/package_database_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "mamba/core/subdirdata.hpp"
#include "mamba/core/virtual_packages.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/util/build.hpp"
#include "mamba/util/string.hpp"

Expand Down Expand Up @@ -54,7 +54,7 @@ namespace mamba

auto
load_subdir_in_database(const Context& ctx, solver::libsolv::Database& db, const SubdirData& subdir)
-> expected_t<solver::libsolv::RepoInfo>
-> expected_t<solver::RepoInfo>
{
const auto expected_cache_origin = solver::libsolv::RepodataOrigin{
/* .url= */ util::rsplit(subdir.metadata().url(), "/", 1).front(),
Expand Down Expand Up @@ -110,7 +110,7 @@ namespace mamba
}
)
.transform(
[&](solver::libsolv::RepoInfo&& repo) -> solver::libsolv::RepoInfo
[&](solver::RepoInfo&& repo) -> solver::RepoInfo
{
if (!util::on_win)
{
Expand All @@ -134,7 +134,7 @@ namespace mamba
const Context& ctx,
solver::libsolv::Database& db,
const PrefixData& prefix
) -> solver::libsolv::RepoInfo
) -> solver::RepoInfo
{
// TODO(C++20): We could do a PrefixData range that returns packages without storing thems.
auto pkgs = prefix.sorted_records();
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/solver/libsolv/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "mamba/fs/filesystem.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/match_spec.hpp"
#include "mamba/util/random.hpp"
#include "solv-cpp/pool.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <string_view>
#include <type_traits>

#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "solv-cpp/repo.hpp"

namespace mamba::solver::libsolv
namespace mamba::solver
{
RepoInfo::RepoInfo(::Repo* repo)
: m_ptr(repo)
Expand All @@ -22,9 +22,9 @@ namespace mamba::solver::libsolv
return solv::ObjRepoViewConst(*m_ptr).name();
}

auto RepoInfo::priority() const -> Priorities
auto RepoInfo::priority() const -> libsolv::Priorities
{
static_assert(std::is_same_v<decltype(m_ptr->priority), Priorities::value_type>);
static_assert(std::is_same_v<decltype(m_ptr->priority), libsolv::Priorities::value_type>);
return { /* .priority= */ m_ptr->priority, /* .subpriority= */ m_ptr->subpriority };
}

Expand Down
2 changes: 1 addition & 1 deletion libmamba/tests/src/solver/test_problems_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "mamba/core/util.hpp"
#include "mamba/fs/filesystem.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/libsolv/solver.hpp"
#include "mamba/solver/libsolv/unsolvable.hpp"
#include "mamba/solver/problems_graph.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/package_info.hpp"
#include "mamba/util/string.hpp"

Expand Down
2 changes: 1 addition & 1 deletion libmambapy/src/libmambapy/bindings/solver_libsolv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/parameters.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/libsolv/solver.hpp"
#include "mamba/solver/libsolv/unsolvable.hpp"
#include "mamba/solver/repo_info.hpp"

#include "bind_utils.hpp"
#include "bindings.hpp"
Expand Down

0 comments on commit 0b09415

Please sign in to comment.