Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to upgrade to a hidden-version package if a hidden-version package is already installed #4525

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ New option/command/subcommand are prefixed with ◈.

## Solver
* Fix Cudf preprocessing [#4534 @AltGr]
* Allow to upgrade to a hidden-version package if a hidden-version package is already installed [#4525 @kit-ty-kate]

## Client
*
Expand Down
4 changes: 2 additions & 2 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ let compute_upgrade_t
if OpamPackage.Set.exists
(fun nv ->
OpamFormula.check atom nv &&
not (OpamFile.OPAM.has_flag Pkgflag_AvoidVersion
(OpamSwitchState.opam t nv)))
(not (OpamFile.OPAM.has_flag Pkgflag_AvoidVersion (OpamSwitchState.opam t nv)) ||
OpamSwitchState.can_upgrade_to_avoid_version (OpamPackage.name nv) t))
(Lazy.force t.available_packages)
then atom
else (n, None)
Expand Down
9 changes: 8 additions & 1 deletion src/state/opamSwitchState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,12 @@ let get_conflicts st packages opams_map =
(fun package -> OpamPackageVar.resolve_switch ~package st)
packages opams_map

let can_upgrade_to_avoid_version name st =
OpamPackage.Set.exists (fun pkg ->
OpamPackage.Name.equal (OpamPackage.name pkg) name &&
OpamFile.OPAM.has_flag Pkgflag_AvoidVersion (OpamPackage.Map.find pkg st.opams)
) st.installed

let universe st
?(test=OpamStateConfig.(!r.build_test))
?(doc=OpamStateConfig.(!r.build_doc))
Expand Down Expand Up @@ -913,7 +919,8 @@ let universe st
in
let avoid_versions =
OpamPackage.Map.fold (fun nv opam acc ->
if OpamFile.OPAM.has_flag Pkgflag_AvoidVersion opam
if OpamFile.OPAM.has_flag Pkgflag_AvoidVersion opam &&
not (can_upgrade_to_avoid_version (OpamFile.OPAM.name opam) st)
then OpamPackage.Set.add nv acc else acc)
st.opams
OpamPackage.Set.empty
Expand Down
3 changes: 3 additions & 0 deletions src/state/opamSwitchState.mli
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ val unavailable_reason:
'a switch_state -> ?default:string -> name * OpamFormula.version_formula ->
string

(** Returns whether or not the package can be upgraded to a version tagged with avoid-version *)
val can_upgrade_to_avoid_version : OpamPackage.Name.t -> 'a switch_state -> bool

(** Handle a cache of the opam files of installed packages *)
module Installed_cache: sig
type t = OpamFile.OPAM.t OpamPackage.Map.t
Expand Down