Commit Graph

9 Commits

Author SHA1 Message Date
David Tolnay
4c90bc48f7 rust: Replace implementation of failure_ext to remove failure dependency
Summary:
This diff changes failure_ext::Error from reexporting failure::Error to anyhow::Error instead.

Failure's error type requires all errors to have an implementation of failure's own failure::Fail trait in order for cause chains and backtraces to work. The necessary methods for this functionality have made their way into the standard library error trait, so modern error libraries build directly on std::error::Error rather than something like failure::Fail. Once we are no longer tied to failure 0.1's Fail trait, different parts of the codebase will be free to use any std::error::Error-based libraries they like while still working nicely together.

Sadly this diff is not the end of the remove-failure stack, it is near the middle. This diff is the point where we've made failure look as much as possible like anyhow and made anyhow look as much like failure via failure_ext, such that we can atomically cut over with a relatively small diff. That means some of the code here isn't necessarily idiomatic. Later diffs will follow up on removing failurisms like the bail_err / bail_msg / ensure_err / ensure_msg distinction which should no longer be necessary.

Reviewed By: Imxset21

Differential Revision: D18577341

fbshipit-source-id: 5689c3c9ddeaa79a123e710831986cf4656a5205
2019-11-22 09:27:59 -08:00
Andres Suarez
cf36295fa4 Yearless license header
Summary:
This diff updates all license headers to use the new text and style.
Also, a few internal files were missing the header, but now they have it.
`fbcode/common/rust/netstring/` had the internal header, but now it has
GPLV2PLUS - since that goes to Mononoke's Github too.

Differential Revision: D17881539

fbshipit-source-id: b70d2ee41d2019fc7c2fe458627f0f7c01978186
2019-10-11 13:52:34 -07:00
Pavel Aslanov
1bb01bb7a1 move mercurial related creates to mercurial subdirectory
Summary:
Start moving mercurial related stuff to `mercurial` directory:
- rename `mercurial` to `mercurial_revlog` and moved to `/mercurial/revlog`
- move `mercurial_types` to `/mercurial/types`
- move `mercurial_bundles` to `/mercurial/bundels`

Reviewed By: farnz

Differential Revision: D16783728

fbshipit-source-id: 79cf1757bb7cc84a6273a4a3c486242b1ef4cd00
2019-08-14 04:03:00 -07:00
Jeremy Fitzhardinge
820395cb2a Convert scm/mononoke to Rust 2018
Summary:
Rust 2018 updates to:
  //scm/mononoke:admin-rust-build-info-lib
  //scm/mononoke:aliasverify
  //scm/mononoke:aliasverify-rust-build-info-lib
  //scm/mononoke:aliasverify-unittest
  //scm/mononoke:blobimport
  //scm/mononoke:blobimport-rust-build-info-lib
  //scm/mononoke:blobimport-unittest
  //scm/mononoke:blobstore_healer-rust-build-info-lib
  //scm/mononoke:bonsai_verify
  //scm/mononoke:bonsai_verify-rust-build-info-lib
  //scm/mononoke:configlint-rust-build-info-lib
  //scm/mononoke:dumprev
  //scm/mononoke:dumprev-rust-build-info-lib
  //scm/mononoke:idxdump
  //scm/mononoke:idxdump-rust-build-info-lib
  //scm/mononoke:mononoke-rust-build-info-lib
  //scm/mononoke:populate_healer-rust-build-info-lib
  //scm/mononoke:revlogrepo
  //scm/mononoke:revlogrepo-rust-build-info-lib
  //scm/mononoke:revlogrepo-unittest

Reviewed By: fanzeyi

Differential Revision: D15465530

fbshipit-source-id: 616db5cc0a8584ccb05f4c3c446b1b3ffd343695
2019-05-23 11:14:19 -07:00
Simon Farnsworth
cd9679166e cleanup warning: causes has become iter_chain in new versions
Summary: This popped up while I was building Mononoke - fix it.

Reviewed By: StanislavGlebik

Differential Revision: D10126386

fbshipit-source-id: 117239dea88c3ecd921f852ce86691ba6aa8bb07
2018-10-01 07:39:00 -07:00
Lukas Piatkowski
a4cd4005df mercurial: refactor RevlogRepo to expose less methods publicly
Summary:
RevlogRepo exposes a ton of methods that are almost equvalent to taking Revlog directly and ignoring the RevloRepo abstraction above it.
This diff cleans this up a bit, there are still some methods that the "old" blobimport uses, but the "new" one shouldn't need to do that.

Reviewed By: StanislavGlebik

Differential Revision: D7289445

fbshipit-source-id: ac7130fe41c4e4484d6986fe5b19d5adc751369a
2018-03-20 11:53:09 -07:00
Jeremy Fitzhardinge
ac31713c84 rust: failure cleanup pass
Summary:
Don't use failure's bail!() and ensure!() macros.

Instead, failure_ext provides:
- bail_err!(err) - Converts its single parameter to the expected error and returns; ie `return Err(From::from(err));`
- bail_msg!(fmt, ...) - takes format string parameters and returns a `failure::err_msg()` error
- ensure_err!(), ensure_msg!() - corresponding changes

Also:
- remove all stray references to error-chain
- remove direct references to failure_derive (it's reexported via failure and failure_ext)
- replace uses of `Err(foo)?;` with `bail_err!()` (since `bail_err` unconditionally returns, but `Err(x)?` does not in principle, which can affect type inference)

Reviewed By: kulshrax

Differential Revision: D6507717

fbshipit-source-id: 635fb6f8c96d185b195dff171ea9c8db9e83af10
2017-12-07 14:10:17 -08:00
Jeremy Fitzhardinge
dc5e78c1c1 rust: mass convert scm/mononoke/... to use failure
Summary:
Convert scm/mononoke to use failure, and update common/rust crates it depends on as well.

What it looks like is a lot of deleted code...

General strategy:
- common/rust/failure_ext adds some things that are in git failure that aren't yet in crates.io (`bail!` and `ensure!`, `Result<T, Error>`)
- everything returns `Result<T, failure::Error>`
- crates with real error get an error type, with a derived Fail implementation
  - replicate error-chain by defining an `enum ErrorKind` where the fields match the declared errors in the error! macro
- crates with dummy error-chain (no local errors) lose it
- `.chain_err()` -> `.context()` or `.with_context()`

So far the only place I've needed to extract an error is in a unit test.
Having a single unified error type has simplified a lot of things, and removed a lot of error type parameters, error conversion, etc, etc.

Reviewed By: sid0

Differential Revision: D6446584

fbshipit-source-id: 744640ca2997d4a85513c4519017f2e2e78a73f5
2017-12-05 18:11:13 -08:00
facebook-github-bot
2b6af6b941 Initial commit
fbshipit-source-id: f75baa4ff6aa71973f677b752d7aba582cf4927f
2017-07-27 18:00:19 -07:00