Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPrint information about `update`d packages #1931
Conversation
rust-highfive
assigned
alexcrichton
Aug 24, 2015
This comment has been minimized.
This comment has been minimized.
|
Rats, CI fails. I'll have to patch all the tests for the new blurbs. |
alexcrichton
reviewed
Aug 25, 2015
| if removed.len() == 1 && added.len() == 1 { | ||
| try!(print_change("Updating", format!("{} v{} -> v{}", | ||
| removed[0].name(), | ||
| removed[0].version(), |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 25, 2015
Member
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
This comment has been minimized.
This comment has been minimized.
thirtythreeforty
Aug 25, 2015
Author
Contributor
Alright, that shouldn't be hard. How would you like the SourceId displayed in the Git and the non-Git cases?
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 25, 2015
Member
Falling back to the normal Display implementation should be good enough
alexcrichton
reviewed
Aug 25, 2015
| for package in removed.iter() { | ||
| try!(print_change("Removing", format!("{} v{}", | ||
| package.name(), | ||
| package.version()))); |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 25, 2015
Member
For these two it should be safe to just pass package as the thing-to-print as it'll cover the name/version automatically as well as including the source id.
alexcrichton
reviewed
Aug 25, 2015
| (dep.name(), dep.source_id()) | ||
| } | ||
|
|
||
| fn vec_subtract<'a, T>(a: &'a Vec<T>, b: &'a Vec<T>) -> Vec<T> |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 25, 2015
Member
&'a Vec<T> is typically taken as &[T], and in this case I don't think you need to connect the lifetimes together so it's probably ok to remove that annotation.
alexcrichton
reviewed
Aug 25, 2015
| } | ||
|
|
||
| // Sort the packages by their names. | ||
| let mut packages: Vec<(&'a str, &'a SourceId)> = |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 25, 2015
Member
You can probably omit the (&'a str, ...) here with a placeholder _ type variable
alexcrichton
reviewed
Aug 25, 2015
| // Sort the packages by their names. | ||
| let mut packages: Vec<(&'a str, &'a SourceId)> = | ||
| changes.keys().map(|x| *x).collect(); | ||
| packages.sort_by(|a, b| a.0.cmp(b.0)); |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 25, 2015
Member
Could this just call sort? That should naturally handle the orderings of names while also sorting by the sources next.
This comment has been minimized.
This comment has been minimized.
|
Thanks for picking this up @thirtythreeforty, looking good! We do also modify the lockfile in the case that the manifest was modified and then Also, to ensure that this scales well, could you try running this over Servo? If you check out servo and run |
This comment has been minimized.
This comment has been minimized.
|
Here's the output from Servo:
|
This comment has been minimized.
This comment has been minimized.
|
The
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. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
Initially it took a while to download and it did a ton of work (looked like it was compiling something?) when it was updating git repos, but subsequent runs are pretty quick and don't heat up the processor at all. Generating the list of changes takes no time at all, as far as I can tell.
|
This comment has been minimized.
This comment has been minimized.
|
Perfect, sounds good to me! |
This comment has been minimized.
This comment has been minimized.
|
OK, that commit should address your feedback. (I knew 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:
Note the |
alexcrichton
reviewed
Aug 26, 2015
| if removed.len() == 1 && added.len() == 1 { | ||
| if removed[0].source_id().is_git() { | ||
| try!(print_change("Updating", format!("{} #{} -> #{}", | ||
| removed[0].name(), |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 26, 2015
Member
This may want to just be removed[0] as that'll print out the git source this came from as well.
This comment has been minimized.
This comment has been minimized.
thirtythreeforty
Aug 26, 2015
Author
Contributor
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.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 27, 2015
Member
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)
This comment has been minimized.
This comment has been minimized.
alexcrichton
reviewed
Aug 26, 2015
| } else { | ||
| try!(print_change("Updating", format!("{} v{} -> v{}", | ||
| removed[0].name(), | ||
| removed[0].version(), |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Aug 26, 2015
Member
These two lines can be replaced with removed[0] as it'll print the same thing for registry sources and otherwise print contextual information for things like path sources
This comment has been minimized.
This comment has been minimized.
thirtythreeforty
Aug 26, 2015
Author
Contributor
Alright. I thought that it might be a little redundant to print that info for upgrades, but if the convention is to omit the source for registry packages, then it might be confusing to not specify that the package is from elsewhere.
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the review! Just squashed with all the tests fixed. |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Aug 28, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 492b582
into
rust-lang:master
Aug 28, 2015
thirtythreeforty
deleted the
thirtythreeforty:printinfo
branch
Aug 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Glad to help! |
thirtythreeforty commentedAug 24, 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:
Comments welcome.
r? @alexcrichton