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

Print information about updated packages #1931

Merged
merged 1 commit into from
Aug 28, 2015
Merged

Print information about updated packages #1931

merged 1 commit into from
Aug 28, 2015

Conversation

thirtythreeforty
Copy link
Contributor

Compare #1621. Like that pull request, this one solves #984.

I have rewritten most of @pyfisch's logic to account for @alexcrichton's comments. Specifically, this code will correctly handle adding/removing multiple versions of one package, as well as several packages with different sources, but the same name.

The output looks like this:

[georgev@desertvoice cargo]$ cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating libc v0.1.8 -> v0.1.10
    Updating memchr v0.1.3 -> v0.1.5
    Updating num v0.1.26 -> v0.1.27
    Updating rand v0.3.9 -> v0.3.10
    Updating rustc-serialize v0.3.15 -> v0.3.16

Comments welcome.

r? @alexcrichton

@thirtythreeforty
Copy link
Contributor Author

Rats, CI fails. I'll have to patch all the tests for the new blurbs.

if removed.len() == 1 && added.len() == 1 {
try!(print_change("Updating", format!("{} v{} -> v{}",
removed[0].name(),
removed[0].version(),
Copy link
Member

Choose a reason for hiding this comment

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

Another part of package ids is the source it comes from (e.g. foo from crates.io is different than foo from github). In addition to indicating the source, updates of git repositories probably want to print out the SHA that was updated to instead of the revision as that's the "precise" notion there. You should be able to access this through the precise field of the SourceId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, that shouldn't be hard. How would you like the SourceId displayed in the Git and the non-Git cases?

Copy link
Member

Choose a reason for hiding this comment

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

Falling back to the normal Display implementation should be good enough

@alexcrichton
Copy link
Member

Thanks for picking this up @thirtythreeforty, looking good!

We do also modify the lockfile in the case that the manifest was modified and then cargo build was re-run, and that's another possible case where we could print what's being updated/removed, but it may also be safe to avoid doing so in that situation because it was manually required anyway.

Also, to ensure that this scales well, could you try running this over Servo? If you check out servo and run cargo update in components/servo then something should happen (I'm not quite sure what), but it'd also be good to make sure that it doesn't keep your cpus too too warm.

@thirtythreeforty
Copy link
Contributor Author

Here's the output from Servo:

[georgev@desertvoice servo]$ ~/Code/cargo/target/debug/cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/servo/rust-png`
    Updating git repository `https://github.com/pcwalton/ipc-channel`
    Updating git repository `https://github.com/TyOverby/bincode`
    Updating git repository `https://github.com/servo/rust-tenacious`
    Updating git repository `https://github.com/servo/rust-azure`
    Updating git repository `https://github.com/ecoal95/rust-offscreen-rendering-context`
    Updating git repository `https://github.com/servo/rust-layers`
    Updating git repository `https://github.com/servo/io-surface-rs`
    Updating git repository `https://github.com/servo/skia`
    Updating git repository `https://github.com/servo/core-text-rs`
    Updating git repository `https://github.com/servo/rust-egl`
    Updating git repository `https://github.com/servo/rust-freetype`
    Updating git repository `https://github.com/servo/libfreetype2`
    Updating git repository `https://github.com/servo/libexpat`
    Updating git repository `https://github.com/servo/rust-glx`
    Updating git repository `https://github.com/servo/rust-mozjs`
    Updating git repository `https://github.com/servo/rust-selectors`
    Updating git repository `https://github.com/servo/mozjs`
    Updating git repository `https://github.com/servo/rust-stb-image`
    Updating git repository `https://github.com/servo/glutin`
    Updating git repository `https://github.com/aweinstock314/rust-clipboard`
    Updating git repository `https://github.com/servo/rust-fontconfig`
    Updating git repository `https://github.com/servo/libfontconfig`
    Updating git repository `https://github.com/libheartbeats/heartbeats-simple-rust.git`
    Updating git repository `https://github.com/libheartbeats/heartbeats-simple-sys.git`
    Updating git repository `https://github.com/tomaka/clock_ticks`
    Updating git repository `https://github.com/jgraham/webdriver-rust.git`
    Updating aster v0.4.1 -> v0.4.3
    Updating azure v0.1.0 -> v0.1.0
    Updating bincode v0.4.0 -> v0.4.0
      Adding bitflags v0.1.1
      Adding block v0.1.0
    Updating clipboard v0.0.2 -> v0.0.3
      Adding clipboard-win v1.5.1
    Removing clipboard-win v1.4.0
    Updating gcc v0.3.12 -> v0.3.13
    Updating getopts v0.2.11 -> v0.2.13
      Adding gl_generator v0.0.26
      Adding heapsize_plugin v0.0.1
    Updating html5ever v0.2.1 -> v0.2.3
    Updating html5ever_macros v0.2.0 -> v0.2.1
    Updating httparse v0.1.5 -> v0.1.6
    Updating hyper v0.6.8 -> v0.6.10
    Updating kernel32-sys v0.1.3 -> v0.1.4
      Adding khronos_api v0.0.8
    Updating layers v0.1.0 -> v0.1.0
    Updating libc v0.1.8 -> v0.1.10
    Updating memchr v0.1.3 -> v0.1.5
    Updating num v0.1.25 -> v0.1.27
    Updating objc v0.1.5 -> v0.1.6
      Adding objc-foundation v0.0.1
      Adding objc_id v0.0.1
    Updating offscreen_gl_context v0.1.0 -> v0.1.0
    Updating rand v0.3.9 -> v0.3.10
    Updating rustc-serialize v0.3.15 -> v0.3.16
    Updating serde v0.5.1 -> v0.5.2
    Updating serde_codegen v0.5.0 -> v0.5.1
    Updating solicit v0.4.1 -> v0.4.2
    Updating tendril v0.1.4 -> v0.1.5
      Adding unicase v1.0.0
    Updating url v0.2.36 -> v0.2.37
    Updating user32-sys v0.1.1 -> v0.1.2
    Updating webdriver v0.2.2 -> v0.2.3
    Updating winapi v0.2.1 -> v0.2.2

@thirtythreeforty
Copy link
Contributor Author

The Removing clipboard-win and Adding clipboard-win lines are confusing without sources. With sources added (by simply using the Display impl for SourceId), they become:

    Removing clipboard-win v1.4.0 (https://github.com/DoumanAsh/clipboard-win#e9f01b5b)
      Adding clipboard-win v1.5.1

The lack of source on the second line is still a bit confusing, but I suppose it's easy enough to figure out that it's from the crate registry.

@alexcrichton
Copy link
Member

Yeah we've got a pretty strong convention of not printing the registry URL for registry packages, so I think it'll quickly become common knowledge that "no source" means "crates.io".

Also, thanks for generating that! Did it take an overly long time to generate or was it nice and speedy? (make sure you're using a --release build to test)

@thirtythreeforty
Copy link
Contributor Author

thirtythreeforty commented Aug 25, 2015 via email

@alexcrichton
Copy link
Member

Perfect, sounds good to me!

@thirtythreeforty
Copy link
Contributor Author

OK, that commit should address your feedback. (I knew &Vec<T> was wrong, I just wanted to see if you'd catch it 😇.)

The tests should all still fail because the test cases need to be rewritten to account for the extra info. I'll do that and squash everything once you and I are happy with the main implementation.

Here's the new result for Servo:

[georgev@desertvoice servo]$ ~/Code/cargo/target/debug/cargo update
    Updating git repository `https://github.com/servo/rust-png`
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/pcwalton/ipc-channel`
    Updating git repository `https://github.com/servo/rust-mozjs`
    Updating git repository `https://github.com/servo/rust-selectors`
    Updating git repository `https://github.com/servo/rust-layers`
    Updating git repository `https://github.com/servo/rust-azure`
    Updating git repository `https://github.com/TyOverby/bincode`
    Updating git repository `https://github.com/servo/mozjs`
    Updating git repository `https://github.com/servo/skia`
    Updating git repository `https://github.com/servo/rust-glx`
    Updating git repository `https://github.com/servo/rust-egl`
    Updating git repository `https://github.com/servo/io-surface-rs`
    Updating git repository `https://github.com/servo/libexpat`
    Updating git repository `https://github.com/servo/libfreetype2`
    Updating git repository `https://github.com/servo/rust-freetype`
    Updating git repository `https://github.com/servo/core-text-rs`
    Updating git repository `https://github.com/servo/rust-tenacious`
    Updating git repository `https://github.com/ecoal95/rust-offscreen-rendering-context`
    Updating git repository `https://github.com/servo/rust-stb-image`
    Updating git repository `https://github.com/tomaka/clock_ticks`
    Updating git repository `https://github.com/servo/rust-fontconfig`
    Updating git repository `https://github.com/servo/libfontconfig`
    Updating git repository `https://github.com/libheartbeats/heartbeats-simple-rust.git`
    Updating git repository `https://github.com/libheartbeats/heartbeats-simple-sys.git`
    Updating git repository `https://github.com/servo/glutin`
    Updating git repository `https://github.com/aweinstock314/rust-clipboard`
    Updating git repository `https://github.com/jgraham/webdriver-rust.git`
    Updating aster v0.4.1 -> v0.4.3
    Updating azure #53e7b7d0 -> #e4831b3d
    Updating bincode #5bc43b85 -> #c1d94fe8
      Adding bitflags v0.1.1
      Adding block v0.1.0
    Updating clipboard #701fa10b -> #b0092c86
    Removing clipboard-win v1.4.0 (https://github.com/DoumanAsh/clipboard-win#e9f01b5b)
      Adding clipboard-win v1.5.1
    Updating gcc v0.3.12 -> v0.3.13
    Updating getopts v0.2.11 -> v0.2.13
      Adding gl_generator v0.0.26
      Adding heapsize_plugin v0.0.1
    Updating html5ever v0.2.1 -> v0.2.3
    Updating html5ever_macros v0.2.0 -> v0.2.1
    Updating httparse v0.1.5 -> v0.1.6
    Updating hyper v0.6.8 -> v0.6.10
    Updating kernel32-sys v0.1.3 -> v0.1.4
      Adding khronos_api v0.0.8
    Updating layers #c4fa5652 -> #2fcdaf62
    Updating libc v0.1.8 -> v0.1.10
    Updating memchr v0.1.3 -> v0.1.5
    Updating num v0.1.25 -> v0.1.27
    Updating objc v0.1.5 -> v0.1.6
      Adding objc-foundation v0.0.1
      Adding objc_id v0.0.1
    Updating offscreen_gl_context #9efc32eb -> #9704865b
    Updating rand v0.3.9 -> v0.3.10
    Updating rustc-serialize v0.3.15 -> v0.3.16
    Updating serde v0.5.1 -> v0.5.2
    Updating serde_codegen v0.5.0 -> v0.5.1
    Updating solicit v0.4.1 -> v0.4.2
    Updating tendril v0.1.4 -> v0.1.5
      Adding unicase v1.0.0
    Updating url v0.2.36 -> v0.2.37
    Updating user32-sys v0.1.1 -> v0.1.2
    Updating webdriver #22658948 -> #5008a3d0
    Updating winapi v0.2.1 -> v0.2.2

Note the # in front of the commit hash, which I found other Cargo code already doing. It's not idiomatic Git, though (which prepends a g to the shorthash). I figured it would be better to be internally consistent. Nitpicky I know, but somebody has to be.

if removed.len() == 1 && added.len() == 1 {
if removed[0].source_id().is_git() {
try!(print_change("Updating", format!("{} #{} -> #{}",
removed[0].name(),
Copy link
Member

Choose a reason for hiding this comment

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

This may want to just be removed[0] as that'll print out the git source this came from as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing that makes the update line look like this:

    Updating offscreen_gl_context v0.1.0 (https://github.com/ecoal95/rust-offscreen-rendering-context#9efc32eb) -> #9704865b

Which I don't think is better, personally.

Copy link
Member

Choose a reason for hiding this comment

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

Hm yeah it can get long sometimes, but I think it's better than not printing it because there's real contextual information (e.g. foo from a git repo is different than foo from crates.io is different than foo from a path source)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very well, I see your point.

@alexcrichton
Copy link
Member

Ok, looks good to me, thanks @thirtythreeforty! There's some failing tests but with those fixed and a squash I think this is good to go

@thirtythreeforty
Copy link
Contributor Author

Thanks for the review! Just squashed with all the tests fixed.

@alexcrichton
Copy link
Member

@bors: r+ 492b582

Thanks!

bors added a commit that referenced this pull request Aug 28, 2015
Compare #1621.  Like that pull request, this one solves #984.

I have rewritten most of @pyfisch's logic to account for @alexcrichton's comments.  Specifically, this code will correctly handle adding/removing multiple versions of one package, as well as several packages with different sources, but the same name.

The output looks like this:

```
[georgev@desertvoice cargo]$ cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating libc v0.1.8 -> v0.1.10
    Updating memchr v0.1.3 -> v0.1.5
    Updating num v0.1.26 -> v0.1.27
    Updating rand v0.3.9 -> v0.3.10
    Updating rustc-serialize v0.3.15 -> v0.3.16
```

Comments welcome.

r? @alexcrichton
@bors
Copy link
Contributor

bors commented Aug 28, 2015

⌛ Testing commit 492b582 with merge 1c27185...

@bors
Copy link
Contributor

bors commented Aug 28, 2015

@bors bors merged commit 492b582 into rust-lang:master Aug 28, 2015
@thirtythreeforty thirtythreeforty deleted the printinfo branch August 28, 2015 16:42
@thirtythreeforty
Copy link
Contributor Author

Glad to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants