Skip to content

Commit

Permalink
Merge pull request #6373 from AltGr/noupgall
Browse files Browse the repository at this point in the history
Fix regression on 'opam upgrade <package>' upgrading unrelated things
  • Loading branch information
kit-ty-kate authored Feb 10, 2025
2 parents 747e736 + 15ed387 commit d0d22d8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 14 deletions.
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ users)

## Update / Upgrade
* [BUG] Do not show the not-up-to-date message with packages tagged with avoid-version [#6273 @kit-ty-kate - fix #6271]
* [BUG] Fix a regression on `opam upgrade <package>` upgrading unrelated packages [#6373 @AltGr]
* [BUG] Fix a regression on `opam upgrade --all <uninstalled-pkg>` not upgrading the whole switch [#6373 @kit-ty-kate]

## Tree

Expand Down Expand Up @@ -171,6 +173,7 @@ users)
* Make sure `download.test` does not fail due to a checksum collision in the download cache [#6378 @kit-ty-kate]
* Add a test showing the behaviour of `opam upgrade` with packages flagged with `avoid-version`/`deprecated` [#6273 @kit-ty-kate]
* Add a test showing the behaviour when a pin depend is unpinned [#6380 @rjbou]
* Add a test to ensure `opam upgrade <pkg>` will not upgrade unrelated things [#6373 @kit-ty-kate]

### Engine

Expand Down
17 changes: 3 additions & 14 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
80 changes: 80 additions & 0 deletions tests/reftests/upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,83 @@ Done.

<><> avoid-version.3 installed successfully <><><><><><><><><><><><><><><><><><>
=> Note: This package is deprecated.
### :::::::::::::::::::::::
### : Make sure opam upgrade <pkg> only tries to upgrade <pkg> and not anything else
### :::::::::::::::::::::::
### opam upgrade
Already up-to-date.
Nothing to do.
### <pkg:foo.4>
opam-version: "2.0"
### <pkg:bar.3>
opam-version: "2.0"
### <pkg:baz.2>
opam-version: "2.0"
depends: "foo"
### <pkg:uninstalled.1>
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

0 comments on commit d0d22d8

Please sign in to comment.