From 074da54d62fa163166abf95edc2e8e5763dd5566 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Fri, 3 Jan 2025 15:50:30 +0100 Subject: [PATCH] fix: Correctly populate lists of `MatchSpec` in `MTransaction`'s history Signed-off-by: Julien Jerphanion --- libmamba/src/core/transaction.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libmamba/src/core/transaction.cpp b/libmamba/src/core/transaction.cpp index 6daa990a12..4f4038f65b 100644 --- a/libmamba/src/core/transaction.cpp +++ b/libmamba/src/core/transaction.cpp @@ -177,13 +177,26 @@ namespace mamba [](const auto& pkg) { return explicit_spec(pkg); } ); + m_history_entry.update.reserve(pkgs_to_install.size()); + for (auto& pkg : pkgs_to_install) + { + m_history_entry.update.push_back(explicit_spec(pkg).str()); + } + m_history_entry.remove.reserve(pkgs_to_remove.size()); + for (auto& pkg : pkgs_to_remove) + { + m_history_entry.remove.push_back(explicit_spec(pkg).str()); + } + m_solution.actions.reserve(pkgs_to_install.size() + pkgs_to_remove.size()); + std::transform( std::move_iterator(pkgs_to_install.begin()), std::move_iterator(pkgs_to_install.end()), std::back_insert_iterator(m_solution.actions), [](specs::PackageInfo&& pkg) { return solver::Solution::Install{ std::move(pkg) }; } ); + std::transform( std::move_iterator(pkgs_to_remove.begin()), std::move_iterator(pkgs_to_remove.end()), @@ -191,17 +204,6 @@ namespace mamba [](specs::PackageInfo&& pkg) { return solver::Solution::Remove{ std::move(pkg) }; } ); - m_history_entry.remove.reserve(pkgs_to_remove.size()); - for (auto& pkg : pkgs_to_remove) - { - m_history_entry.remove.push_back(explicit_spec(pkg).str()); - } - m_history_entry.update.reserve(pkgs_to_install.size()); - for (auto& pkg : pkgs_to_install) - { - m_history_entry.update.push_back(explicit_spec(pkg).str()); - } - // if no action required, don't even start logging them if (!empty()) {