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

Fix regression on 'opam upgrade <package>' upgrading unrelated things #6373

Merged
merged 4 commits into from
Feb 10, 2025
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
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
Comment on lines +486 to +489
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link the origin of the regression ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same commit

=== 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