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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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 @@ -56,6 +56,8 @@ users)
## Var/Option

## Update / Upgrade
* [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 @@ -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 <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 @@ -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 <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 +440 to +443
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
Loading