-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improved consistency between breaking and non-breaking updates #14259
base: master
Are you sure you want to change the base?
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
src/cargo/ops/cargo_update.rs
Outdated
// In case of `--breaking` (or precise upgrades, coming in | ||
// #14140), we want to keep all packages unchanged that didn't | ||
// get upgraded. | ||
|| (opts.breaking && !upgrades.contains_key(&(p.name(), p.source_id()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an important change that has been discussed here: #14140 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To put another way, there is concern with using keep
like this and resolving this is a blocker for moving forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious what the actual concern is, though. We are only modifying keep
in the case of breaking or precise updates, and we have quite extensive test coverage of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this is not put in to_avoid is that those require PackageIds, i.e. they require a version. When doing upgrades, we don't have any versions, only version requirements.
In general converting from a requirement to a version is not possible and converting to a set of versions requires scanning all the versions on the index. But in this case keep
is only called on versions that are in the lock file. I think we already scan all the versions in the lock file to construct to_avoid
, so I'd rather see this check done there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed this PR so it no longer changes keep
, but instead builds up what it needs in to_avoid
. Please review!
5cb1f15
to
98ccf0f
Compare
@@ -49,7 +62,11 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> { | |||
Ok(()) | |||
} | |||
|
|||
pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> { | |||
pub fn update_lockfile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ensuring more consistent output messages between breaking and non-breaking updates, as well as better error messages, as we are now running the same ops::update_lockfile in either case.
Reusing ops::update_lockfile
is one way of improving these. Are there alternative designs we could use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could duplicate update_lockfile
and modify it to fit our needs, but the approach in this PR seems better to me. A significant chunk of the function is now conditional on breaking updates:
if opts.breaking {} else {}
Quoting from the first link:
If this PR is related to this comment, its not clear. It doesn't talk about about the error case mentioned in that comment or give a justification for why this is the approach to go. |
e2162b7
to
66bc2fe
Compare
I have updated the PR description with more context. Not sure what else to add. If you think it needs more, let me know. |
That is what I am wanting you to talk about. This is supposed to change behavior related to one of the tasks in a direction that I have serious doubs about. I'd like the intended behavior changes enumerated and why those behaviors were selected, not an explanation for what this unblocks. |
src/cargo/ops/cargo_update.rs
Outdated
let spec = PackageIdSpec::new(name.to_string()) | ||
.with_url(source_id.url().clone()) | ||
.with_version(matching_dep.version().clone().into()); | ||
let spec = format!("{spec}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that just spec.to_string()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
I have added to the description something about whether or not to error if there is nothing to do. |
This PR isn't really related to the task list at all. The only purpose of this PR is to factor out any change to |
66bc2fe
to
324ad02
Compare
@epage Could you take a look at #14140 (comment), please? I believe it will unblock this PR as well as #14140. |
☔ The latest upstream changes (presumably #14471) made this pull request unmergeable. Please resolve the merge conflicts. |
Related to #12425.
This is ensuring more consistent output messages between breaking and non-breaking updates, as well as better error messages, as we are now running the same
ops::update_lockfile
in either case.See how the the tests changed for examples. This becomes even more important after adding support for breaking precise updates in #14140, and this PR is necessary to unblock that PR. Here's why:
Some of the duplicated existing precise tests with the unstable feature enabled are not passing without this PR. In other words, we would be changing the behaviour of the non-breaking precise update.
Some invocations are silently finishing rather than reporting an error such as this:
Requested as a separate PR here and here.
This PR does not introduce an error message if there is nothing to update. Instead, it adds more output, as demonstrated by the test
update_breaking_specific_packages_that_wont_update
:Whether or not to throw an error is still an item on the TODO list here.