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

Add cargo update --breaking #13979

Merged
merged 4 commits into from
Jun 7, 2024
Merged

Add cargo update --breaking #13979

merged 4 commits into from
Jun 7, 2024

Conversation

torhovland
Copy link
Contributor

@torhovland torhovland commented May 29, 2024

Related to #12425.

There are two kinds of manifest mutations here. In upgrade_manifests we have to mutate cargo::core::manifest::Manifest so that resolve_ws does what it needs to do, and outputs a correct lock file. Then, in write_manifest_upgrades we mutate cargo::util::toml_mut::manifest::Manifest, because that is how we can preserve the existing formatting in the manifest files on disk.

Some of the code here is copied from cargo-edit.

Comparison with cargo upgrade

Running on the Cargo source itself gives the following:

❯ cargo upgrade --dry-run --incompatible allow --compatible ignore 
    Updating 'https://github.com/rust-lang/crates.io-index' index
    Checking benchsuite's dependencies
    Checking capture's dependencies
    Checking cargo's dependencies
name               old req compatible latest  new req note      
====               ======= ========== ======  ======= ====      
anstream           0.6.13  0.6.14     0.6.14  0.6.13  compatible
anstyle            1.0.6   1.0.7      1.0.7   1.0.6   compatible
anyhow             1.0.82  1.0.86     1.0.86  1.0.82  compatible
itertools          0.12.1  0.12.1     0.13.0  0.13.0            
libc               0.2.154 0.2.155    0.2.155 0.2.154 compatible
opener             0.7.0   0.7.1      0.7.1   0.7.0   compatible
openssl            0.10.57 0.10.64    0.10.64 0.10.57 compatible
openssl-sys        =0.9.92 0.9.92     0.9.102 =0.9.92 pinned    
pulldown-cmark     0.10.3  0.10.3     0.11.0  0.11.0            
security-framework 2.10.0  2.11.0     2.11.0  2.10.0  compatible
semver             1.0.22  1.0.23     1.0.23  1.0.22  compatible
serde              1.0.199 1.0.203    1.0.203 1.0.199 compatible
serde-untagged     0.1.5   0.1.6      0.1.6   0.1.5   compatible
serde_json         1.0.116 1.0.117    1.0.117 1.0.116 compatible
tar                0.4.40  0.4.41     0.4.41  0.4.40  compatible
thiserror          1.0.59  1.0.61     1.0.61  1.0.59  compatible
toml               0.8.12  0.8.14     0.8.14  0.8.12  compatible
toml_edit          0.22.12 0.22.14    0.22.14 0.22.12 compatible
unicode-width      0.1.12  0.1.13     0.1.13  0.1.12  compatible
    Checking cargo-credential's dependencies
    Checking cargo-credential-1password's dependencies
    Checking cargo-credential-libsecret's dependencies
    Checking cargo-credential-macos-keychain's dependencies
    Checking cargo-credential-wincred's dependencies
    Checking cargo-platform's dependencies
    Checking cargo-test-macro's dependencies
    Checking cargo-test-support's dependencies
    Checking cargo-util's dependencies
    Checking cargo-util-schemas's dependencies
    Checking crates-io's dependencies
    Checking home's dependencies
    Checking mdman's dependencies
    Checking resolver-tests's dependencies
    Checking rustfix's dependencies
    Checking semver-check's dependencies
    Checking xtask-build-man's dependencies
    Checking xtask-bump-check's dependencies
    Checking xtask-stale-label's dependencies
note: Re-run with `--pinned` to upgrade pinned version requirements
note: Re-run with `--verbose` to show all dependencies
  local: cargo
  unchanged: annotate-snippets, base64, bytesize, cargo-credential, cargo-credential-libsecret, cargo-credential-macos-keychain, cargo-credential-wincred, cargo-platform, cargo-test-macro, cargo-test-support, cargo-util, cargo-util-schemas, cargo_metadata, clap, color-print, core-foundation, crates-io, criterion, curl, curl-sys, filetime, flate2, git2, git2-curl, gix, glob, handlebars, hex, hmac, home, http-auth, humantime, ignore, im-rc, indexmap, jobserver, lazycell, libgit2-sys, libloading, memchr, miow, os_info, pasetors, pathdiff, percent-encoding, pkg-config, proptest, rand, regex, rusqlite, rustfix, same-file, serde-value, serde_ignored, sha1, sha2, shell-escape, similar, snapbox, supports-hyperlinks, supports-unicode, tempfile, time, tracing, tracing-chrome, tracing-subscriber, unicase, unicode-xid, url, varisat, walkdir, windows-sys
warning: aborting upgrade due to dry run

❯ target/debug/cargo update --breaking --dry-run -Zunstable-options
    Updating crates.io index
   Upgrading itertools ^0.12.1 -> ^0.13.0
   Upgrading pulldown-cmark ^0.10.3 -> ^0.11.0
    Updating crates.io index
     Locking 3 packages to latest compatible versions
    Updating itertools v0.12.1 -> v0.13.0
    Updating pulldown-cmark v0.10.3 -> v0.11.0
    Updating pulldown-cmark-escape v0.10.0 -> v0.11.0
warning: not updating any files due to dry run

In both cases we see an upgrade of itertools to ^0.13.0 and pulldown-cmark to ^0.11.0.

The diff to the manifest (when it isn't a dry run) is as follows:

--- a/Cargo.toml
+++ b/Cargo.toml
@@ -57,7 +57,7 @@ humantime = "2.1.0"
 ignore = "0.4.22"
 im-rc = "15.1.0"
 indexmap = "2.2.6"
-itertools = "0.12.1"
+itertools = "0.13.0"
 jobserver = "0.1.31"
 lazycell = "1.3.0"
 libc = "0.2.154"
@@ -74,7 +74,7 @@ pathdiff = "0.2.1"
 percent-encoding = "2.3.1"
 pkg-config = "0.3.30"
 proptest = "1.4.0"
-pulldown-cmark = { version = "0.10.3", default-features = false, features = ["html"] }
+pulldown-cmark = { version = "0.11.0", default-features = false, features = ["html"] }
 rand = "0.8.5"
 regex = "1.10.4"
 rusqlite = { version = "0.31.0", features = ["bundled"] }

TODO

  • In the case of --incompatible, we also need to let update_lockfile use upgrades in order to only update the incompatible dependencies.
  • Testing all the different cases of package sources, version requirements, pinned versions, renamed dependencies, inherited workspace dependencies, multiple versions of the same dependency, selecting a subset --package, etc.
  • Passing tests.
  • Implement suggestions from reviews.
  • The preservation of formatting in manifest files should be improved.
  • Compare with cargo upgrade.

@rustbot
Copy link
Collaborator

rustbot commented May 29, 2024

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-manifest Area: Cargo.toml issues A-testing-cargo-itself Area: cargo's tests Command-update S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 29, 2024
@ehuss
Copy link
Contributor

ehuss commented May 29, 2024

r? epage
If you don't mind.

@rustbot rustbot assigned epage and unassigned ehuss May 29, 2024
tests/testsuite/update.rs Outdated Show resolved Hide resolved
tests/testsuite/update.rs Outdated Show resolved Hide resolved
tests/testsuite/update.rs Outdated Show resolved Hide resolved
tests/testsuite/update.rs Outdated Show resolved Hide resolved
src/cargo/util/toml/mod.rs Outdated Show resolved Hide resolved
@epage
Copy link
Contributor

epage commented May 29, 2024

When this is ready for review, what I expect to see for the commits

  1. The refactor to create cargo_update.rs
  2. Tests
  3. Feature with test updates

tests/testsuite/update.rs Outdated Show resolved Hide resolved
@rustbot rustbot added the A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. label May 30, 2024
@bors
Copy link
Collaborator

bors commented Jun 2, 2024

☔ The latest upstream changes (presumably #13980) made this pull request unmergeable. Please resolve the merge conflicts.

@torhovland torhovland changed the title Add cargo update --incompatible Add cargo update --breaking Jun 3, 2024
@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation Command-new labels Jun 3, 2024
src/cargo/ops/cargo_update.rs Outdated Show resolved Hide resolved
src/cargo/ops/cargo_update.rs Outdated Show resolved Hide resolved
src/cargo/ops/cargo_update.rs Outdated Show resolved Hide resolved
src/cargo/ops/cargo_update.rs Outdated Show resolved Hide resolved
@torhovland torhovland force-pushed the issue-12425 branch 2 times, most recently from 3a6142f to 61202d5 Compare June 6, 2024 09:25
@epage
Copy link
Contributor

epage commented Jun 7, 2024

Thanks for all of the work you put into this!

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 7, 2024

📌 Commit 031b410 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 7, 2024
@bors
Copy link
Collaborator

bors commented Jun 7, 2024

⌛ Testing commit 031b410 with merge fb123c6...

@bors
Copy link
Collaborator

bors commented Jun 7, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing fb123c6 to master...

@bors bors merged commit fb123c6 into rust-lang:master Jun 7, 2024
21 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 8, 2024
Update cargo

8 commits in 34a6a87d8a2330d8c9d578f927489689328a652d..b1feb75d062444e2cee8b3d2aaa95309d65e9ccd
2024-06-04 15:31:01 +0000 to 2024-06-07 20:16:17 +0000
- Keep lints updated (rust-lang/cargo#14030)
- test(lints): Ensure unused optional dep fires for shadowed dep (rust-lang/cargo#14028)
- Add `cargo update --breaking` (rust-lang/cargo#13979)
- Add tooling to document lints (rust-lang/cargo#14025)
- Rename --out-dir to --artifact-dir (rust-lang/cargo#13809)
- fix(lints): Add unknown_lints to lints list (rust-lang/cargo#14024)
- docs(contrib): Suggest atomic commits with separate test commits (rust-lang/cargo#14014)
- test(semver): track the behavior of `--precise <prerelease>` (rust-lang/cargo#14013)

r? ghost
@rustbot rustbot added this to the 1.81.0 milestone Jun 8, 2024
@torhovland torhovland deleted the issue-12425 branch June 9, 2024 16:29
epage added a commit to epage/cargo that referenced this pull request Jun 11, 2024
This is a follow up to rust-lang#13979 to try to clarify things in prep for users
testing this.
epage added a commit to epage/cargo that referenced this pull request Jun 12, 2024
This is a follow up to rust-lang#13979 to try to clarify things in prep for users
testing this.
bors added a commit that referenced this pull request Jun 12, 2024
docs: Iterate on --breaking docs

This is a follow up to #13979 to try to clarify things in prep for users testing this.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jun 28, 2024
Update cargo

8 commits in 34a6a87d8a2330d8c9d578f927489689328a652d..b1feb75d062444e2cee8b3d2aaa95309d65e9ccd
2024-06-04 15:31:01 +0000 to 2024-06-07 20:16:17 +0000
- Keep lints updated (rust-lang/cargo#14030)
- test(lints): Ensure unused optional dep fires for shadowed dep (rust-lang/cargo#14028)
- Add `cargo update --breaking` (rust-lang/cargo#13979)
- Add tooling to document lints (rust-lang/cargo#14025)
- Rename --out-dir to --artifact-dir (rust-lang/cargo#13809)
- fix(lints): Add unknown_lints to lints list (rust-lang/cargo#14024)
- docs(contrib): Suggest atomic commits with separate test commits (rust-lang/cargo#14014)
- test(semver): track the behavior of `--precise <prerelease>` (rust-lang/cargo#14013)

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-dependency-resolution Area: dependency resolution and the resolver A-documenting-cargo-itself Area: Cargo's documentation A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-manifest Area: Cargo.toml issues A-testing-cargo-itself Area: cargo's tests Command-add Command-clean Command-fetch Command-fix Command-install Command-metadata Command-new Command-package Command-remove Command-tree Command-update Command-vendor S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants