Commit 2940332b authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Fix previous new-freeze patch for older containers versions

containers-0.4.x didn't include the mergeWithKey function, so we use a
less efficient method in the 0.4.x case.
parent b01171ba
{-# LANGUAGE NamedFieldPuns, RecordWildCards #-}
{-# LANGUAGE CPP, NamedFieldPuns, RecordWildCards #-}
-- | cabal-install CLI command: freeze
--
......@@ -180,6 +180,7 @@ projectFreezeConstraints plan =
:: Map PackageName [(UserConstraint, ConstraintSource)]
-> Map PackageName [(UserConstraint, ConstraintSource)]
deleteLocalPackagesVersionConstraints =
#if MIN_VERSION_containers(0,5,0)
Map.mergeWithKey
(\_pkgname () constraints ->
case filter (not . isVersionConstraint . fst) constraints of
......@@ -187,6 +188,15 @@ projectFreezeConstraints plan =
constraints' -> Just constraints')
(const Map.empty) id
localPackages
#else
Map.mapMaybeWithKey
(\pkgname constraints ->
if pkgname `Map.member` localPackages
then case filter (not . isVersionConstraint . fst) constraints of
[] -> Nothing
constraints' -> Just constraints'
else Just constraints)
#endif
isVersionConstraint UserConstraintVersion{} = True
isVersionConstraint _ = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment