Skip to content

Commit

Permalink
Allow to upgrade to a hidden-version package if a hidden-version pack…
Browse files Browse the repository at this point in the history
…age is already installed
  • Loading branch information
kit-ty-kate authored and rjbou committed Mar 23, 2021
1 parent bbad80d commit 16eacf9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
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

0 comments on commit 16eacf9

Please sign in to comment.