Auto merge of #4551 - natboehm:owner-invite-messages, r=alexcrichton
Owner invite messages
This PR addresses issue #4537, the plan for `cargo owner --add` requiring invitations in Cargo and the encompassing issue [#924](https://github.com/rust-lang/crates.io/issues/924), requiring an invite to add someone as an owner in Crates.io.
Regarding the Cargo issue, we went with Option 2, changing the `add_owners` function to decode a struct sent from Crates containing a `boolean` and `String`, the `boolean` being the response status and `String` being the success message. This may sound redundant however we concluded that using both of these fields were necessary to support older versions of Cargo - if we changed Crates.io to only return the `String` message on success this would likely break systems using the older version of `add_owner` expecting a response containing a `boolean`. Matching this schema, `add_owners` on the Crates.io side will soon return a struct containing a `boolean` and `String`, and instead of adding a new crate owner to the database will add a crate owner invite. If successful, `modify_owners` now prints the message sent from Crates.io instead of the old hardcoded message.
Auto merge of #4547 - lukaslueg:installlisterror, r=alexcrichton
Improve error message for crippled .crates.toml
In case `.crates.toml` can't be parsed for some reason, the user is left wondering where to look. The problem is exasperated by the fact that `.cargo.toml` is a hidden file. Improve the error message during `install`/`uninstall`/`list` and point to the path of `.crates.toml`. A error message might now look like
> error: failed to parse crate metadata at `/home/foobar/.cargo/.crates.toml`
>
> Caused by:
> invalid TOML found for metadata
>
> Caused by:
> ...
A unit-test for a crippled `.cargo.toml` had been missing before, added that.
Auto merge of #4542 - equal-l2:sha256-crypto-hash, r=alexcrichton
Use crypto-hash to calculate SHA256
`crypto-hash` is an abstraction library for native hash libraries.
It uses CryptoAPI on Windows, CommonCrypto on macOS, and OpenSSL on *nix.
This PR will also remove `openssl` and `advapi32-sys` from dependencies since they are only used for calculating SHA256, which is superseded by `crypto-hash`.
(`crypto-hash` itself uses `openssl` and `advapi32-sys` though)
Auto merge of #4530 - djc:update-deps, r=alexcrichton
Update dependencies
It would be nice to use openssl-0.9.19 in particular, since it supports
newer LibreSSL.
Not sure how this usually works, would it be better to only update openssl and related dependencies? I figured doing everything at once couldn't hurt, and it seems to pass tests locally at least.
Also, would it be feasible to backport this to the beta branch?
Auto merge of #4526 - lukaslueg:patch-2, r=matklad
Update CONTRIBUTING.md
Point out that code added to Cargo may raise the minimal version of Rust required. Cargo does not have a grace period where it has to compile on "stable -2" or anything like that.
Auto merge of #4525 - lukaslueg:springclean, r=alexcrichton
Cleaning lints
I've started to clean some minor defects in cargo. This is the first commit of possibly many.
Requesting advice if this is actually wanted; #cargo was positive.
Some things raise the minimum version of rust required to compile cargo. E.g. `assert_ne!(foo, bar)` instead of `assert!(foo != bar)` requires (iirc) rust 1.13. Any advice on that in particular?
Point out that code added to Cargo may raise the minimal version of Rust required. Cargo does not have a grace period where it has to compile on "stable -2" or anything like that.
Auto merge of #4519 - leavehouse:patch-1, r=alexcrichton
Clarify dependencies documentation
The snippet:
```
... but not `2.0`. `0.0.x` is not considered ...
```
Looks very similar to `... but not 2.0.0.0.x is not considered ...`, when rendered, which is confusing.
Auto merge of #4520 - goffrie:master, r=alexcrichton
Don't visit the same unit multiple times.
This fixes some accidentally-exponential behaviour we were seeing in our
fairly large workspace. It brings a no-op cargo run from about 10
seconds to 0.3 seconds on my machine.
Also changes an association list to a hashmap because that was showing
up in profiles too.
Geoffry Song [Thu, 21 Sep 2017 19:15:49 +0000 (12:15 -0700)]
Don't visit the same unit multiple times.
This fixes some accidentally-exponential behaviour we were seeing in our
fairly large workspace. It brings a no-op cargo run from about 10
seconds to 0.3 seconds on my machine.
Also changes an association list to a hashmap because that was showing
up in profiles too.
```
... but not `2.0`. `0.0.x` is not considered ...
```
Looks very similar to `... but not 2.0.0.0.x is not considered ...`, when rendered, which is confusing.
Auto merge of #4515 - lukaslueg:issue1006, r=alexcrichton
Improve message for multiple links to native lib
Proposal for a fix to #1006, as advertised in my comment; as discussed briefly with alexcrichton on IRC.
In case multiple packages link to the same library, the error message is now
> error: More than one package links to native library `a`, which can only be linked once.
>
> Package a-sys v0.5.0 (file:///home/lukas/dev/issue1006test/a) links to native library `a`.
> (Dependency via foo v0.5.0 (file:///home/lukas/dev/issue1006test))
>
> Package b-sys v0.5.0 (file:///home/lukas/dev/issue1006test/a/b) also links to native library `a`.
> (Dependency via a-sys v0.5.0 (file:///home/lukas/dev/issue1006test/a) => foo v0.5.0 (file:///home/lukas/dev/issue1006test))
>
> Try updating or pinning your dependencies to ensure that native library `a` is only linked once.
>
In case the root-package itself is an offender:
> Package foo v0.5.0 (file:///home/lukas/dev/issue1006test) links to native library `a`.
> (This is the root-package)
>
IMHO the wording is much clearer now (the term "native library" and "package" are repeated on purpose); printing the whole dependency-chain from the offending package up to the root allows the user to at least figure out where the native library actually comes in.
Added a unit-test, which all pass. Please scrutinize this carefully, it's my first PR for cargo.
If a native library is linked multiple times, present the user with a
clear error message, indicating the offending packages and their
dependency-chain.
Auto merge of #4496 - rwakulszowa:infer_from_subdirectories, r=matklad
Infer targets from subdirectories
Fixes #4086
I still have a few questions:
- should I add some tests for the old behaviour? It isn't really tested at the moment (no tests failed when I broke the implementation); I could refactor the tests to check for both single file and subdirectory inference
- I moved things around, mostly reusing the code from `inferred_bins` - hopefully I didn't break anything, but it won't hurt to double check :)
- Do we have something like servo's `tidy` check for coding style? I'm open for suggestions if something isn't formatted correctly
- Just a general one - should I rebase + squash commits every time I make subsequent changes to cargo?
Auto merge of #4501 - matklad:top-level-features, r=alexcrichton
Move cargo features to top-level
This should allow to add Cargo-features to virtual manifest as well.
I've not actually added support for features in virtual manifests just yet, because that will probably require some refactoring to avoid duplicating feature-related code between virtual and usual manifests.
Auto merge of #4478 - alexcrichton:less-fds, r=matklad
Periodically gc repos in Cargo
This commit is targeted at improving the long-term management of git checkouts
and git repositories. Currently every time data is fetched from crates.io
libgit2 will create a new pack file in the repository. These pack files
accumulate over time and end up causing pathological behavior if there's lots of
them, causing libgit2 to open many file descriptors all at once, possibly
blowing the system's file descriptor limits.
To alleviate this problem you typically run `git gc`, but libgit2 doesn't have
this implemented. Instead what Cargo now does is detect this situation and run
literally the command line tool `git gc` in a best-effort attempt to compact the
repo. Failing that, for example when git isn't installed, Cargo will remove the
entire repo and do a full checkout again.
At the same time this commit also generalizes this logic, plus the existing fast
path github logic, to all git repositories and not just the index. That way all
git repositories can benefit from the "github fast path" as well as the
compaction steps.
Alex Crichton [Sat, 9 Sep 2017 01:30:37 +0000 (18:30 -0700)]
Periodically gc repos in Cargo
This commit is targeted at improving the long-term management of git checkouts
and git repositories. Currently every time data is fetched from crates.io
libgit2 will create a new pack file in the repository. These pack files
accumulate over time and end up causing pathological behavior if there's lots of
them, causing libgit2 to open many file descriptors all at once, possibly
blowing the system's file descriptor limits.
To alleviate this problem you typically run `git gc`, but libgit2 doesn't have
this implemented. Instead what Cargo now does is detect this situation and run
literally the command line tool `git gc` in a best-effort attempt to compact the
repo. Failing that, for example when git isn't installed, Cargo will remove the
entire repo and do a full checkout again.
At the same time this commit also generalizes this logic, plus the existing fast
path github logic, to all git repositories and not just the index. That way all
git repositories can benefit from the "github fast path" as well as the
compaction steps.
Auto merge of #4485 - integer32llc:clarify-config, r=alexcrichton
Clarify that .cargo/config files are unified
It wasn't immediately clear to me from the text on this page whether Cargo looks for these files and stops at the first one, or whether it looks for them all and puts them all together. I was pretty sure it was the latter, but I think these few more words would have made me feel more confident sooner :)
Alex Crichton [Sat, 9 Sep 2017 20:52:03 +0000 (13:52 -0700)]
Make `dep_targets` consistent throughout compilation
Previously it depended on dynamic state that was calculated throughout a
compilation which ended up causing different fingerprints showing up in a few
locations, so this makes the invocation deterministic throughout `cargo_rustc`.
Auto merge of #4477 - alexcrichton:fix-out-of-bounds, r=matklad
Use poll instead of select to handle large fds
It may be the case that Cargo's running around with a lot of file descriptors,
and in this case we wouldn't be able to call `select` due to the file
descriptors being too large and not fitting in the bit array. This switches to
what the standard library is currently doing, using `poll`, which doesn't have
this limitations.
Auto merge of #3992 - alexcrichton:replace-git, r=matklad
Support vendoring git repositories
Currently the vendoring support in Cargo primarily only allows replacing
registry sources, e.g. crates.io. Other networked sources of code, such as git
repositories, cannot currently be replaced. The purpose of this commit is to
support vendoring of git dependencies to eventually have support implemented in
the `cargo-vendor` subcommand.
Support for vendoring git repositories required a few subtle changes:
* First and foremost, configuration for source replacement of a git repository
was added. This looks similar to the `Cargo.toml` configuration of a git
source.
* The restriction around checksum providing sources was relaxed. If a
replacement source provides checksums but the replaced source doesn't then
that's now considered ok unlike it being an error before.
* Lock files can be generated for crates.io crates against vendored sources, but
lock files cannot be generated against git sources. A lock file must
previously exist to make use of a vendored git source.
* The `package` field of `.cargo-checksum.json` is now optional, and it is
intended to be omitted for git sources that are vendored.
Alex Crichton [Fri, 8 Sep 2017 05:14:55 +0000 (22:14 -0700)]
Use poll instead of select to handle large fds
It may be the case that Cargo's running around with a lot of file descriptors,
and in this case we wouldn't be able to call `select` due to the file
descriptors being too large and not fitting in the bit array. This switches to
what the standard library is currently doing, using `poll`, which doesn't have
this limitations.
Alex Crichton [Thu, 4 May 2017 03:33:28 +0000 (20:33 -0700)]
Support vendoring git repositories
Currently the vendoring support in Cargo primarily only allows replacing
registry sources, e.g. crates.io. Other networked sources of code, such as git
repositories, cannot currently be replaced. The purpose of this commit is to
support vendoring of git dependencies to eventually have support implemented in
the `cargo-vendor` subcommand.
Support for vendoring git repositories required a few subtle changes:
* First and foremost, configuration for source replacement of a git repository
was added. This looks similar to the `Cargo.toml` configuration of a git
source.
* The restriction around checksum providing sources was relaxed. If a
replacement source provides checksums but the replaced source doesn't then
that's now considered ok unlike it being an error before.
* Lock files can be generated for crates.io crates against vendored sources, but
lock files cannot be generated against git sources. A lock file must
previously exist to make use of a vendored git source.
* The `package` field of `.cargo-checksum.json` is now optional, and it is
intended to be omitted for git sources that are vendored.