mirror of https://github.com/mamba-org/mamba.git
unify channels of installed and removed packages written in history (#3892)
This commit is contained in:
parent
aeb417f617
commit
fb54852b92
|
@ -379,8 +379,27 @@ namespace mamba
|
|||
return true;
|
||||
}
|
||||
|
||||
TransactionRollback rollback;
|
||||
// Channels coming from the repodata (packages to install) don't have the same channel
|
||||
// format than packages coming from the prefix (packages to remove). We set all the channels
|
||||
// to be URL like (i.e. explicit). Below is a loop to fix the channel of the linked
|
||||
// packages (fix applied to the unlinked packages to avoid potential bugs). Ideally, this
|
||||
// should be normalised when reading the data.
|
||||
const auto fix_channel = [&](specs::PackageInfo& pkg)
|
||||
{
|
||||
auto unresolved_pkg_channel = mamba::specs::UnresolvedChannel::parse(pkg.channel).value();
|
||||
auto pkg_channel = mamba::specs::Channel::resolve(
|
||||
unresolved_pkg_channel,
|
||||
channel_context.params()
|
||||
)
|
||||
.value();
|
||||
auto channel_url = pkg_channel[0].platform_url(pkg.platform).str();
|
||||
pkg.channel = channel_url;
|
||||
};
|
||||
for_each_to_install(m_solution.actions, fix_channel);
|
||||
for_each_to_remove(m_solution.actions, fix_channel);
|
||||
for_each_to_omit(m_solution.actions, fix_channel);
|
||||
|
||||
TransactionRollback rollback;
|
||||
TransactionContext transaction_context(ctx.transaction_params(), m_py_versions, m_requested_specs);
|
||||
|
||||
const auto link = [&](const specs::PackageInfo& pkg)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import re
|
||||
|
||||
# Need to import everything to get fixtures
|
||||
from .helpers import * # noqa: F403
|
||||
from . import helpers
|
||||
|
||||
|
||||
def test_history(tmp_home, tmp_root_prefix):
|
||||
env_name = "myenv"
|
||||
helpers.create("-n", env_name, "python=3.8")
|
||||
helpers.install("-n", env_name, "xtl")
|
||||
helpers.uninstall("-n", env_name, "xtl")
|
||||
|
||||
effective_prefix = tmp_root_prefix / "envs" / env_name
|
||||
history_path = effective_prefix / "conda-meta" / "history"
|
||||
assert history_path.exists()
|
||||
with open(history_path) as f:
|
||||
history = f.read()
|
||||
assert len(re.findall(r"\+https:\/\/conda.anaconda.org\/conda-forge\/.+::xtl", history)) > 0
|
||||
assert len(re.findall(r"-https:\/\/conda.anaconda.org\/conda-forge\/.+::xtl", history)) > 0
|
Loading…
Reference in New Issue