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 committed Feb 6, 2021
1 parent 6929b39 commit 9e433dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,21 @@ let compute_upgrade_t
then (n, None)
else
let atom = (n, Some (`Gt, nv.version)) in
let has_hidden_version nv =
OpamFile.OPAM.has_flag Pkgflag_HiddenVersion
(OpamSwitchState.opam t nv)
in
let hidden_version_already_installed pkg =
OpamPackage.Set.exists (fun nv ->
OpamPackage.Name.equal (OpamPackage.name nv) pkg &&
has_hidden_version nv
) t.installed
in
if OpamPackage.Set.exists
(fun nv ->
OpamFormula.check atom nv &&
not (OpamFile.OPAM.has_flag Pkgflag_HiddenVersion
(OpamSwitchState.opam t nv)))
(not (has_hidden_version nv) ||
hidden_version_already_installed (OpamPackage.name nv)))
(Lazy.force t.available_packages)
then atom
else (n, None)
Expand Down
12 changes: 11 additions & 1 deletion src/state/opamSwitchState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,19 @@ let universe st
(Lazy.force st.sys_packages)
OpamPackage.Set.empty
in
let has_hidden_version opam =
OpamFile.OPAM.has_flag Pkgflag_HiddenVersion opam
in
let hidden_version_already_installed name =
OpamPackage.Set.exists (fun pkg ->
OpamPackage.Name.equal (OpamPackage.name pkg) name &&
has_hidden_version (OpamPackage.Map.find pkg st.opams)
) st.installed
in
let hidden_versions =
OpamPackage.Map.fold (fun nv opam acc ->
if OpamFile.OPAM.has_flag Pkgflag_HiddenVersion opam
if has_hidden_version opam &&
not (hidden_version_already_installed (OpamFile.OPAM.name opam))
then OpamPackage.Set.add nv acc else acc)
st.opams
OpamPackage.Set.empty
Expand Down

0 comments on commit 9e433dd

Please sign in to comment.