diff --git a/master_changes.md b/master_changes.md index aef29e1f5d8..f8e7ba1eccb 100644 --- a/master_changes.md +++ b/master_changes.md @@ -56,6 +56,8 @@ users) ## Var/Option ## Update / Upgrade + * [BUG] Fix a regression on `opam upgrade ` upgrading unrelated packages [#6373 @AltGr] + * [BUG] Fix a regression on `opam upgrade --all ` not upgrading the whole switch [#6373 @kit-ty-kate] ## Tree @@ -162,6 +164,7 @@ users) * Extend the tests on opam admin to include packages using builtin global variables [#6331 @kit-ty-kate] * Extend the tests on opam admin check by including all the arguments [#6331 @kit-ty-kate @rjbou] * Add double pinning test in case of opam/opam opam file [#6343 @rjbou] + * Add a test to ensure `opam upgrade ` will not upgrade unrelated things [#6373 @kit-ty-kate] ### Engine diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index 2b37a6f6fcc..801e250faa0 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -113,27 +113,16 @@ let compute_upgrade_t | Some nv -> not (OpamPackage.Set.mem nv (Lazy.force t.available_packages))) atoms in - let criteria = if to_install = [] then `Upgrade else `Default in - if all then - names, - OpamSolution.resolve t Upgrade - ~requested:packages - ~reinstall:(Lazy.force t.reinstall) - (OpamSolver.request - ~install:to_install - ~upgrade:to_upgrade - ~deprequest:(OpamFormula.to_atom_formula formula) - ~all:[] - ~criteria ()) - else names, OpamSolution.resolve t Upgrade ~requested:packages + ?reinstall:(if all then Some (Lazy.force t.reinstall) else None) (OpamSolver.request ~install:to_install ~upgrade:to_upgrade ~deprequest:(OpamFormula.to_atom_formula formula) - ~criteria + ?all:(if all then Some [] else None) + ~criteria:(if all then `Upgrade else `Default) ()) let print_requested requested formula = diff --git a/tests/reftests/upgrade.test b/tests/reftests/upgrade.test index 29d809de5ae..343ab53c479 100644 --- a/tests/reftests/upgrade.test +++ b/tests/reftests/upgrade.test @@ -384,3 +384,83 @@ Done. # Packages matching: name-match(quux) & installed # Name # Installed files quux ${BASEDIR}/OPAM/upgrading/lib/quux ${BASEDIR}/OPAM/upgrading/lib/quux/fichier +### ::::::::::::::::::::::: +### : Make sure opam upgrade only tries to upgrade and not anything else +### ::::::::::::::::::::::: +### opam upgrade +Already up-to-date. +Nothing to do. +### +opam-version: "2.0" +### +opam-version: "2.0" +### +opam-version: "2.0" +depends: "foo" +### +opam-version: "2.0" +### opam upgrade --show foo +The following actions would be performed: +=== upgrade 1 package + - upgrade foo 3 to 4 +### opam upgrade --show -a foo +The following actions would be performed: +=== upgrade 3 packages + - upgrade bar 2 to 3 + - upgrade baz 1 to 2 [uses foo] + - upgrade foo 3 to 4 +### opam upgrade --show bar +The following actions would be performed: +=== upgrade 1 package + - upgrade bar 2 to 3 +### opam upgrade --show -a bar +The following actions would be performed: +=== upgrade 3 packages + - upgrade bar 2 to 3 + - upgrade baz 1 to 2 [uses foo] + - upgrade foo 3 to 4 +### opam upgrade --show baz +The following actions would be performed: +=== upgrade 1 package + - upgrade baz 1 to 2 +### opam upgrade --show -a baz +The following actions would be performed: +=== upgrade 3 packages + - upgrade bar 2 to 3 + - upgrade baz 1 to 2 + - upgrade foo 3 to 4 [required by baz] +### opam upgrade --show uninstalled +uninstalled is not installed. Install it? [Y/n] y +The following actions would be performed: +=== install 1 package + - install uninstalled 1 +### opam upgrade --show -a uninstalled +uninstalled is not installed. Install it? [Y/n] y +The following actions would be performed: +=== upgrade 3 packages + - upgrade bar 2 to 3 + - upgrade baz 1 to 2 [uses foo] + - upgrade foo 3 to 4 +=== install 1 package + - install uninstalled 1 +### opam upgrade --show +The following actions would be performed: +=== upgrade 3 packages + - upgrade bar 2 to 3 + - upgrade baz 1 to 2 + - upgrade foo 3 to 4 +### opam upgrade baz +The following actions will be performed: +=== upgrade 1 package + - upgrade baz 1 to 2 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed baz.1 +-> installed baz.2 +Done. +### opam upgrade --show foo +The following actions would be performed: +=== recompile 1 package + - recompile baz 2 [uses foo] +=== upgrade 1 package + - upgrade foo 3 to 4