Aleksey Kladov [Sat, 10 Mar 2018 13:23:05 +0000 (16:23 +0300)]
Reorganize subcommands as a separate submodule
Aleksey Kladov [Sat, 10 Mar 2018 13:16:00 +0000 (16:16 +0300)]
Move command_prelude to a separate file
Aleksey Kladov [Sat, 10 Mar 2018 13:13:51 +0000 (16:13 +0300)]
Introduce command_prelude module
Aleksey Kladov [Fri, 9 Mar 2018 10:18:32 +0000 (13:18 +0300)]
Make command-line arguments owned
Aleksey Kladov [Fri, 9 Mar 2018 08:03:36 +0000 (11:03 +0300)]
Validate that `jobs` argument is a number
Aleksey Kladov [Fri, 9 Mar 2018 07:43:00 +0000 (10:43 +0300)]
Unwind stack for cli errors
Aleksey Kladov [Thu, 8 Mar 2018 20:41:26 +0000 (23:41 +0300)]
Remove dead code
Aleksey Kladov [Thu, 8 Mar 2018 20:37:39 +0000 (23:37 +0300)]
Remove docopt dependency
Aleksey Kladov [Thu, 8 Mar 2018 20:33:52 +0000 (23:33 +0300)]
Fix after rebase
Aleksey Kladov [Thu, 8 Mar 2018 20:29:38 +0000 (23:29 +0300)]
Fix typo
Aleksey Kladov [Thu, 8 Mar 2018 20:26:52 +0000 (23:26 +0300)]
Remove dead code
Aleksey Kladov [Thu, 8 Mar 2018 20:24:27 +0000 (23:24 +0300)]
Fix `--explain`
Aleksey Kladov [Thu, 8 Mar 2018 20:19:27 +0000 (23:19 +0300)]
Support list subcommand
All tests are green :tada:
Aleksey Kladov [Thu, 8 Mar 2018 20:06:29 +0000 (23:06 +0300)]
Support aliases
Aleksey Kladov [Thu, 8 Mar 2018 19:40:28 +0000 (22:40 +0300)]
Fix more tests by updating error messages
Aleksey Kladov [Thu, 8 Mar 2018 19:36:27 +0000 (22:36 +0300)]
Unignore test which now passes
Aleksey Kladov [Thu, 8 Mar 2018 19:35:42 +0000 (22:35 +0300)]
Disable `cargo help -h`
Aleksey Kladov [Thu, 8 Mar 2018 19:33:10 +0000 (22:33 +0300)]
Fix verify-project command
Aleksey Kladov [Thu, 8 Mar 2018 19:28:58 +0000 (22:28 +0300)]
Support built-in aliases
Aleksey Kladov [Thu, 8 Mar 2018 19:24:16 +0000 (22:24 +0300)]
Support external subcommands
Aleksey Kladov [Thu, 8 Mar 2018 19:15:07 +0000 (22:15 +0300)]
Cleanup
Aleksey Kladov [Thu, 8 Mar 2018 19:06:02 +0000 (22:06 +0300)]
Restore global initialization
Aleksey Kladov [Thu, 8 Mar 2018 18:55:12 +0000 (21:55 +0300)]
Use exit code 1 for command line parsing errors
Note that while we use 101 in majority of cases, sometimes we use 1 as
well.
Aleksey Kladov [Thu, 8 Mar 2018 18:48:38 +0000 (21:48 +0300)]
Fix some trivially fixable tests
Aleksey Kladov [Thu, 8 Mar 2018 18:27:51 +0000 (21:27 +0300)]
Drop old commands
Aleksey Kladov [Thu, 8 Mar 2018 18:21:04 +0000 (21:21 +0300)]
Move the rest of the commands to clap
Aleksey Kladov [Thu, 8 Mar 2018 14:10:28 +0000 (17:10 +0300)]
Move uninstall to clap
Aleksey Kladov [Thu, 8 Mar 2018 13:56:36 +0000 (16:56 +0300)]
Move test to clap
Aleksey Kladov [Thu, 8 Mar 2018 11:12:00 +0000 (14:12 +0300)]
Move search to clap
Aleksey Kladov [Thu, 8 Mar 2018 10:31:21 +0000 (13:31 +0300)]
Don't copy-paste index argument
Aleksey Kladov [Thu, 8 Mar 2018 10:26:01 +0000 (13:26 +0300)]
Don't copy-paste package argument
Aleksey Kladov [Thu, 8 Mar 2018 10:16:17 +0000 (13:16 +0300)]
Move rustdoc to clap
Aleksey Kladov [Thu, 8 Mar 2018 10:05:49 +0000 (13:05 +0300)]
Move rustc to clap
Aleksey Kladov [Thu, 8 Mar 2018 09:36:31 +0000 (12:36 +0300)]
Move run to clap
Aleksey Kladov [Thu, 8 Mar 2018 09:05:42 +0000 (12:05 +0300)]
Move read-manifest to clap
Aleksey Kladov [Thu, 8 Mar 2018 08:49:31 +0000 (11:49 +0300)]
Move publish to clap
Aleksey Kladov [Wed, 7 Mar 2018 15:02:36 +0000 (18:02 +0300)]
Move pkgid to clap
Aleksey Kladov [Wed, 7 Mar 2018 14:54:10 +0000 (17:54 +0300)]
Move package to clap
Aleksey Kladov [Wed, 7 Mar 2018 14:40:33 +0000 (17:40 +0300)]
Move owner to clap
Aleksey Kladov [Wed, 7 Mar 2018 13:59:16 +0000 (16:59 +0300)]
Move new to clap
Aleksey Kladov [Wed, 7 Mar 2018 13:39:25 +0000 (16:39 +0300)]
Move metadata to clap
Aleksey Kladov [Wed, 7 Mar 2018 13:17:10 +0000 (16:17 +0300)]
Move login to clap
Aleksey Kladov [Wed, 7 Mar 2018 11:42:39 +0000 (14:42 +0300)]
Move locate-project to clap
Aleksey Kladov [Wed, 7 Mar 2018 11:31:39 +0000 (14:31 +0300)]
Move install to clap
Aleksey Kladov [Wed, 7 Mar 2018 10:02:35 +0000 (13:02 +0300)]
Specify frozen & locked for all commands simultaneously
Aleksey Kladov [Wed, 7 Mar 2018 09:53:59 +0000 (12:53 +0300)]
Move init to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:50:05 +0000 (11:50 +0300)]
Move git-checkout to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:35:17 +0000 (11:35 +0300)]
Move generate-lockfile to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:32:10 +0000 (11:32 +0300)]
Move fetch to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:22:46 +0000 (11:22 +0300)]
Move doc to clap
Aleksey Kladov [Wed, 7 Mar 2018 07:57:51 +0000 (10:57 +0300)]
Move clean to clap
Aleksey Kladov [Wed, 7 Mar 2018 07:10:45 +0000 (10:10 +0300)]
Move check to clap
Aleksey Kladov [Wed, 7 Mar 2018 06:46:16 +0000 (09:46 +0300)]
Temporarly ignore some tests
Aleksey Kladov [Tue, 6 Mar 2018 21:01:03 +0000 (00:01 +0300)]
Port bench and build to clap
bors [Thu, 8 Mar 2018 15:21:26 +0000 (15:21 +0000)]
Auto merge of #5150 - Eh2406:more_interning, r=alexcrichton
More interning
This is a small part of the unsuccessful last commit of #5121, this part removes `InternedString::new` from the innerest of loops.
This is mostly a resubmission of #5147, that I accidentally deleted while bors was testing. This one has new commits, so github will take the resubition.
Eh2406 [Thu, 8 Mar 2018 04:20:17 +0000 (23:20 -0500)]
intern links attribute
bors [Thu, 8 Mar 2018 04:02:02 +0000 (04:02 +0000)]
Auto merge of #5147 - Eh2406:restucture, r=alexcrichton
restructure `Activations` for better clone
This builds on the work in #5121 When we last met we had:
5000000 ticks in ~48 sec, 0r 104k ticks/sec
This small change brings us to:
5000000 ticks in ~21 sec, 0r 238k ticks/sec
Edit: sorry for the large diff only the last commit is new. The rest are from #5121
Eh2406 [Wed, 7 Mar 2018 17:57:48 +0000 (12:57 -0500)]
restructure `Activations` for better clone
bors [Wed, 7 Mar 2018 22:54:54 +0000 (22:54 +0000)]
Auto merge of #5121 - Eh2406:string_interning, r=alexcrichton
String interning
This builds on the work from #5118. This interns the strings in the part of resolver that gets cloned a lot.
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
1700000 ticks in ~(63 to 67) sec from #5118
After we got to
1700000 ticks in ~(42 to 45) sec
The interning code itself would be much better with a `leak` function that converts a `String` to a `&'static str`. Something like:
```rust
pub fn leek(s: String) -> &'static str {
let ptr = s.as_ptr();
let len = s.len();
mem::forget(s);
unsafe {
let slice = slice::from_raw_parts(ptr, len);
str::from_utf8(slice).unwrap()
}
}
```
but "there is no unsafe in Cargo", and I am not the best at unsafe. So I just `to_string` and lived with the extra copy. Is there a better way to hand out references?
I assumed that `InternedString::new` world start appearing in profile result, and that we would want `PackageId`, and `Summary`, Et Al. to store the `InternedString`. That is why I put the interner in a shared folder. So far it is just used in the resolver. It may make sense for a lot more of the Strings to be interned, but with the extra copy... I have not explored it yet.
Eh2406 [Wed, 7 Mar 2018 22:19:53 +0000 (17:19 -0500)]
use `Deref` instead of an explicit function
Eh2406 [Wed, 7 Mar 2018 22:10:55 +0000 (17:10 -0500)]
use `into_boxed_str` to shrink before we leek
bors [Wed, 7 Mar 2018 15:39:24 +0000 (15:39 +0000)]
Auto merge of #5012 - infinity0:pr4988, r=alexcrichton
Don't require dev-dependencies when not needed in certain cases
Specifically, when running `cargo install` and add a flag for this behaviour in `cargo build`.
This closes #4988.
Ximin Luo [Wed, 7 Mar 2018 13:46:43 +0000 (14:46 +0100)]
Work around #5134 for now
bors [Wed, 7 Mar 2018 00:02:33 +0000 (00:02 +0000)]
Auto merge of #5138 - alexcrichton:small-opt, r=matklad
Some small optimizations
Found an easy hot spot or two when profiling `./x.py build` in rust-lang/rust, although certainly still lots remaining.
Alex Crichton [Tue, 6 Mar 2018 23:09:53 +0000 (15:09 -0800)]
Retain a vector instead of reallocating
No need to create a new version!
Eh2406 [Tue, 6 Mar 2018 22:44:31 +0000 (17:44 -0500)]
add unsafe
bors [Tue, 6 Mar 2018 22:34:32 +0000 (22:34 +0000)]
Auto merge of #5135 - matklad:drop-ignored-tests, r=alexcrichton
Drop ignored tests
r? @alexcrichton
These tests are ignored, so its better to remove them. `run` does not supports `--bins` argument, so I've left a single test that checks specifically for this.
cc https://github.com/rust-lang/cargo/pull/3901
Alex Crichton [Tue, 6 Mar 2018 21:36:05 +0000 (13:36 -0800)]
Optimize SourceId::crates_io
Turns out this gets called a lot in large projects as almost all dependencies
come from crates.io and parsed manifests use this. Let's cache the result as
it's always the same!
Eh2406 [Sun, 4 Mar 2018 04:08:13 +0000 (23:08 -0500)]
and links just to be throw
Eh2406 [Sun, 4 Mar 2018 03:38:10 +0000 (22:38 -0500)]
intern the features
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
5000000 ticks in ~65 sec
After we got to
5000000 ticks in ~52 sec
Eh2406 [Sun, 4 Mar 2018 02:01:33 +0000 (21:01 -0500)]
make a global string interner
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
5000000 ticks in ~72 sec
After we got to
5000000 ticks in ~65 sec
Aleksey Kladov [Tue, 6 Mar 2018 20:28:52 +0000 (23:28 +0300)]
Drop ignored tests
Ximin Luo [Tue, 6 Mar 2018 19:49:20 +0000 (20:49 +0100)]
Revert "Make the default behaviour of `cargo build` match the documentation"
This reverts commit
3fc0715d33ccea567526242d2247576930db4a7c.
bors [Tue, 6 Mar 2018 19:16:55 +0000 (19:16 +0000)]
Auto merge of #5132 - Eh2406:less_clones, r=alexcrichton
don't clone a BacktrackFrame if we are not going to backtrack
I think this is a fix for #5130.
Currently the only recoverable `activate` error does not corrupt `cx`, so this is definitely ok. We should be careful as we add more recoverable `activate` errors that they don't corrupt `cx` to the point where the error messages are affected.
Eh2406 [Tue, 6 Mar 2018 19:05:59 +0000 (14:05 -0500)]
don't clone a BacktrackFrame if we are not going to backtrack
Ximin Luo [Tue, 6 Mar 2018 18:56:35 +0000 (19:56 +0100)]
Merge remote-tracking branch 'upstream/master' into pr4988
bors [Tue, 6 Mar 2018 03:22:33 +0000 (03:22 +0000)]
Auto merge of #5127 - ehuss:incremental-doc, r=alexcrichton
Fix reference docs for "incremental" in the wrong place.
It is part of the [build] section, not a [target].
Eric Huss [Tue, 6 Mar 2018 03:10:08 +0000 (19:10 -0800)]
Fix reference docs for "incremental" in the wrong place.
It is part of the [build] section, not a [target].
bors [Tue, 6 Mar 2018 03:01:47 +0000 (03:01 +0000)]
Auto merge of #5122 - acmcarther:acm-emit-features-from-cargo-metadata, r=alexcrichton
Emit Resolve.features_sorted in "cargo metadata"
This PR adds `features` to `metadata.resolve.nodes[*]` using the Resolve object's known features. This is different from the `features` fields that already exist elsewhere within metadata as this one is the actual features that need to be used in order to build the code.
Context: I'm currently using Cargo's internals to synthesize BUILD files for the Bazel build tool. `cargo metadata` currently provides almost everything I need in order to avoid using Cargo's internals -- *except* for this.
cc https://github.com/google/cargo-raze/issues/7
Alex McArther [Mon, 5 Mar 2018 14:36:12 +0000 (06:36 -0800)]
Repair the other metadata tests
Alex McArther [Mon, 5 Mar 2018 06:04:27 +0000 (22:04 -0800)]
Emit resolve.features in "cargo metadata"
bors [Sun, 4 Mar 2018 21:16:16 +0000 (21:16 +0000)]
Auto merge of #5119 - alexcrichton:no-clone-index-in-tests, r=matklad
Update a test to not clone the real index
A local index should work ok!
Alex Crichton [Sun, 4 Mar 2018 20:51:31 +0000 (12:51 -0800)]
Update a test to not clone the real index
A local index should work ok!
bors [Sun, 4 Mar 2018 20:47:56 +0000 (20:47 +0000)]
Auto merge of #5118 - Eh2406:more_rc, r=alexcrichton
use more Rc in the part of resolver that gets cloned a lot
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
1700000 ticks in ~(82 to 97) sec
After we got to
1700000 ticks in ~(63 to 67) sec
Eh2406 [Sun, 4 Mar 2018 02:33:23 +0000 (21:33 -0500)]
use more Rc in the part of resolver that gets cloned a lot
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
1700000 ticks in ~(82 to 97) sec
After we got to
1700000 ticks in ~(63 to 67) sec
bors [Sat, 3 Mar 2018 21:32:24 +0000 (21:32 +0000)]
Auto merge of #5112 - Eh2406:cache_queries, r=alexcrichton
Cache the query result.
Small performance gain.
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
1700000 ticks in ~97 sec
After we got to
1700000 ticks in ~92 sec. I just reran and got ~82, so it seems to be unstable.
And query disappears from the flame graph
Eh2406 [Sat, 3 Mar 2018 17:49:15 +0000 (12:49 -0500)]
Use `HashMap` insted of `BTreeMap`
Eh2406 [Sat, 3 Mar 2018 16:17:05 +0000 (11:17 -0500)]
`Context` no longer needs replacements nor its lifetime
Eh2406 [Sat, 3 Mar 2018 15:56:57 +0000 (10:56 -0500)]
Make a `RegistryQueryer` to own the cache
Ximin Luo [Sat, 3 Mar 2018 11:56:08 +0000 (12:56 +0100)]
Merge remote-tracking branch 'upstream/master' into pr4988
bors [Fri, 2 Mar 2018 23:37:29 +0000 (23:37 +0000)]
Auto merge of #5110 - alexcrichton:reset-harder, r=matklad
Try a lot harder to recover corrupt git repos
We've received a lot of intermittent bug reports historically about corrupt git
repositories. These inevitably happens as Cargo is ctrl-c'd or for whatever
other reason, and to provide a better user experience Cargo strives to
automatically handle these situations by blowing away the old checkout for a new
update.
This commit adds a new test which attempts to pathologically corrupt a git
database and checkout in an attempt to expose bugs in Cargo. Sure enough there
were some more locations that we needed to handle gracefully for corrupt git
checkouts. Notable inclusions were:
* The `fetch` operation in libgit2 would fail due to corrupt references. This
starts by adding an explicit whitelist for classes of errors coming out of
`fetch` to auto-retry by blowing away the repository. We need to be super
careful here as network errors commonly come out of this function and we don't
want to too aggressively re-clone.
* After a `fetch` succeeded a repository could fail to actual resolve a
git reference to the actual revision we want. This indicated that we indeed
needed to blow everything away and re-clone entirely again.
* When creating a checkout from a database the `reset` operation might fail due
to a corrupt local database of the checkout itself. If this happens we needed
to just blow it away and try again.
There's likely more lurking situations where we need to re-clone but I figure we
can discover those over time.
Alex Crichton [Fri, 2 Mar 2018 17:44:47 +0000 (09:44 -0800)]
Try a lot harder to recover corrupt git repos
We've received a lot of intermittent bug reports historically about corrupt git
repositories. These inevitably happens as Cargo is ctrl-c'd or for whatever
other reason, and to provide a better user experience Cargo strives to
automatically handle these situations by blowing away the old checkout for a new
update.
This commit adds a new test which attempts to pathologically corrupt a git
database and checkout in an attempt to expose bugs in Cargo. Sure enough there
were some more locations that we needed to handle gracefully for corrupt git
checkouts. Notable inclusions were:
* The `fetch` operation in libgit2 would fail due to corrupt references. This
starts by adding an explicit whitelist for classes of errors coming out of
`fetch` to auto-retry by blowing away the repository. We need to be super
careful here as network errors commonly come out of this function and we don't
want to too aggressively re-clone.
* After a `fetch` succeeded a repository could fail to actual resolve a
git reference to the actual revision we want. This indicated that we indeed
needed to blow everything away and re-clone entirely again.
* When creating a checkout from a database the `reset` operation might fail due
to a corrupt local database of the checkout itself. If this happens we needed
to just blow it away and try again.
There's likely more lurking situations where we need to re-clone but I figure we
can discover those over time.
Eh2406 [Fri, 2 Mar 2018 22:56:36 +0000 (17:56 -0500)]
Cache the query result.
In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-
357553286
Before we got to
1700000 ticks in ~97 sec
After we got to
1700000 ticks in ~92 sec
And query disappears from the flame graph
bors [Fri, 2 Mar 2018 20:42:25 +0000 (20:42 +0000)]
Auto merge of #5111 - ehuss:bashc-toolchains, r=alexcrichton
Support +toolchain rustup override in bash completions.
Fixes #5107
Eric Huss [Fri, 2 Mar 2018 19:45:16 +0000 (11:45 -0800)]
Support +toolchain rustup override in bash completions.
Fixes #5107
bors [Fri, 2 Mar 2018 18:43:11 +0000 (18:43 +0000)]
Auto merge of #5095 - tdbgamer:master, r=matklad
Issue #5087
* remove Workspace::current_manifest
* remove incorrect logging
* move empty check to Packages::into_package_id_specs
* add test case mentioned in issue
bors [Fri, 2 Mar 2018 15:06:13 +0000 (15:06 +0000)]
Auto merge of #5104 - Eh2406:bug_fix, r=alexcrichton
missed this important bug
In the PR #5000 I finished and we merged yesterday I missed a bug and left in an outdated comment.
@alexcrichton
Eh2406 [Fri, 2 Mar 2018 13:49:42 +0000 (08:49 -0500)]
This test should pass if we have tried to `update registry` evan if the command otherwise fails
Eh2406 [Fri, 2 Mar 2018 02:44:02 +0000 (21:44 -0500)]
get ci green; don't clone more than we need
Eh2406 [Fri, 2 Mar 2018 02:05:22 +0000 (21:05 -0500)]
missed this important bug