diff --git a/eden/scm/edenscm/hgext/extlib/indexes/Cargo.toml b/eden/scm/edenscm/hgext/extlib/indexes/Cargo.toml index d17cad90f1..0be97ff889 100644 --- a/eden/scm/edenscm/hgext/extlib/indexes/Cargo.toml +++ b/eden/scm/edenscm/hgext/extlib/indexes/Cargo.toml @@ -16,7 +16,7 @@ crate-type = ["cdylib"] cpython-ext = { path = "../../../../lib/cpython-ext" } cpython-failure = { path = "../../../../lib/cpython-failure" } radixbuf = { path = "../../../../lib/radixbuf" } -failure = "0.1.5" +anyhow = "1.0.20" thiserror = "1.0.5" [dependencies.cpython] diff --git a/eden/scm/edenscm/hgext/extlib/indexes/src/nodemap.rs b/eden/scm/edenscm/hgext/extlib/indexes/src/nodemap.rs index b0ccf4abb9..548c4d42b7 100644 --- a/eden/scm/edenscm/hgext/extlib/indexes/src/nodemap.rs +++ b/eden/scm/edenscm/hgext/extlib/indexes/src/nodemap.rs @@ -6,7 +6,7 @@ */ use crate::errors::ErrorKind; -use failure::{bail, Fallible as Result}; +use anyhow::{bail, Result}; use radixbuf::errors as rerrors; use radixbuf::key::KeyId; use radixbuf::radix::{ diff --git a/eden/scm/edenscmnative/bindings/modules/pydag/Cargo.toml b/eden/scm/edenscmnative/bindings/modules/pydag/Cargo.toml index 7a9119a782..71a4c2a766 100644 --- a/eden/scm/edenscmnative/bindings/modules/pydag/Cargo.toml +++ b/eden/scm/edenscmnative/bindings/modules/pydag/Cargo.toml @@ -8,4 +8,4 @@ cpython-failure = { path = "../../../../lib/cpython-failure" } cpython = { version = "0.3", features = ["python27-sys"], default-features = false } dag = { path = "../../../../lib/dag" } encoding = { path = "../../../../lib/encoding" } -failure = "0.1.3" +anyhow = "1.0.20" diff --git a/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs index e1c064129d..27114bdd78 100644 --- a/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pydag/src/lib.rs @@ -7,6 +7,7 @@ #![allow(non_camel_case_types)] +use anyhow::Error; use cpython::*; use cpython_failure::{FallibleExt, ResultPyErrExt}; use dag::{ @@ -15,7 +16,6 @@ use dag::{ spanset::{SpanSet, SpanSetIter}, }; use encoding::local_bytes_to_path; -use failure::Error; use std::cell::RefCell; type Result = std::result::Result; diff --git a/eden/scm/edenscmnative/bindings/modules/pyedenapi/Cargo.toml b/eden/scm/edenscmnative/bindings/modules/pyedenapi/Cargo.toml index a55bc5e452..b744c580a7 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyedenapi/Cargo.toml +++ b/eden/scm/edenscmnative/bindings/modules/pyedenapi/Cargo.toml @@ -9,7 +9,6 @@ cpython-failure = { path = "../../../../lib/cpython-failure" } cpython = { version = "0.3", features = ["python27-sys"], default-features = false } edenapi = { path = "../../../../lib/edenapi" } encoding = { path = "../../../../lib/encoding" } -failure = "0.1.3" pyrevisionstore = { path = "../pyrevisionstore" } revisionstore = { path = "../../../../lib/revisionstore" } types = { path = "../../../../lib/types" } diff --git a/eden/scm/edenscmnative/bindings/modules/pymanifest/Cargo.toml b/eden/scm/edenscmnative/bindings/modules/pymanifest/Cargo.toml index 68bf56e9da..3587c53236 100644 --- a/eden/scm/edenscmnative/bindings/modules/pymanifest/Cargo.toml +++ b/eden/scm/edenscmnative/bindings/modules/pymanifest/Cargo.toml @@ -4,12 +4,12 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" bytes = { version = "0.4.11" } cpython-ext = { path = "../../../../lib/cpython-ext" } cpython-failure = { path = "../../../../lib/cpython-failure" } cpython = { version = "0.3", features = ["python27-sys"], default-features = false } encoding = { path = "../../../../lib/encoding" } -failure = "0.1.3" manifest = { path = "../../../../lib/manifest" } pathmatcher = { path = "../../../../lib/pathmatcher" } pypathmatcher = { path = "../pypathmatcher" } diff --git a/eden/scm/edenscmnative/bindings/modules/pymanifest/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pymanifest/src/lib.rs index 230c56622a..562f73d606 100644 --- a/eden/scm/edenscmnative/bindings/modules/pymanifest/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pymanifest/src/lib.rs @@ -9,9 +9,9 @@ use std::{borrow::Borrow, cell::RefCell, ops::Deref, str, sync::Arc}; +use anyhow::{format_err, Error}; use bytes::Bytes; use cpython::*; -use failure::{format_err, Error}; use cpython_ext::{pyset_add, pyset_new}; use cpython_failure::ResultPyErrExt; diff --git a/eden/scm/edenscmnative/bindings/modules/pymutationstore/Cargo.toml b/eden/scm/edenscmnative/bindings/modules/pymutationstore/Cargo.toml index 3054102ef4..580dcfdd06 100644 --- a/eden/scm/edenscmnative/bindings/modules/pymutationstore/Cargo.toml +++ b/eden/scm/edenscmnative/bindings/modules/pymutationstore/Cargo.toml @@ -4,12 +4,13 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" byteorder = "1.2.7" cpython-ext = { path = "../../../../lib/cpython-ext" } cpython-failure = { path = "../../../../lib/cpython-failure" } cpython = { version = "0.3", features = ["python27-sys"], default-features = false } encoding = { path = "../../../../lib/encoding" } -failure = "0.1.3" mutationstore = { path = "../../../../lib/mutationstore" } +thiserror = "1.0.5" types = { path = "../../../../lib/types" } vlqencoding = { path = "../../../../lib/vlqencoding" } diff --git a/eden/scm/edenscmnative/bindings/modules/pymutationstore/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pymutationstore/src/lib.rs index b784eb9ea9..9e601ae919 100644 --- a/eden/scm/edenscmnative/bindings/modules/pymutationstore/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pymutationstore/src/lib.rs @@ -9,10 +9,11 @@ use std::{cell::RefCell, io::Cursor}; +use anyhow::Error; use byteorder::{ReadBytesExt, WriteBytesExt}; use cpython::*; use cpython_failure::ResultPyErrExt; -use failure::ResultExt; +use thiserror::Error; use ::mutationstore::{MutationEntry, MutationEntryOrigin, MutationStore}; use encoding::local_bytes_to_path; @@ -75,6 +76,16 @@ fn unbundle(py: Python, data: PyBytes) -> PyResult> { Ok(entries) } +#[derive(Error, Debug)] +enum InvalidNode { + #[error("Invalid successor node: {0}")] + Successor(Error), + #[error("Invalid predecessor node: {0}")] + Predecessor(Error), + #[error("Invalid split node: {0}")] + Split(Error), +} + py_class!(class mutationentry |py| { data entry: MutationEntry; @@ -92,14 +103,14 @@ py_class!(class mutationentry |py| { ) -> PyResult { let origin = MutationEntryOrigin::from_id(origin).map_pyerr::(py)?; let succ = Node::from_slice(succ.data(py)) - .with_context(|e| format!("Invalid successor node: {}", e)) + .map_err(InvalidNode::Successor) .map_pyerr::(py)?; let preds = { let mut nodes = Vec::new(); if let Some(preds) = preds { for p in preds { nodes.push(Node::from_slice(p.data(py)) - .with_context(|e| format!("Invalid predecessor node: {}", e)) + .map_err(InvalidNode::Predecessor) .map_pyerr::(py)?); } } @@ -110,7 +121,7 @@ py_class!(class mutationentry |py| { if let Some(split) = split { for s in split { nodes.push(Node::from_slice(s.data(py)) - .with_context(|e| format!("Invalid split node: {}", e)) + .map_err(InvalidNode::Split) .map_pyerr::(py)?); } } diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/Cargo.toml b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/Cargo.toml index 4fdd45df1e..2f8799db27 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/Cargo.toml +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/Cargo.toml @@ -4,11 +4,11 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" cpython-ext = { path = "../../../../lib/cpython-ext" } cpython-failure = { path = "../../../../lib/cpython-failure" } cpython = { version = "0.3", features = ["python27-sys"], default-features = false } encoding = { path = "../../../../lib/encoding" } -failure = "0.1" parking_lot = "0.9.0" pyconfigparser = { path = "../pyconfigparser" } revisionstore = { path = "../../../../lib/revisionstore" } diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/datastorepyext.rs b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/datastorepyext.rs index 4137278c51..8da212c6ba 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/datastorepyext.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/datastorepyext.rs @@ -5,11 +5,11 @@ * GNU General Public License version 2. */ +use anyhow::Result; use cpython::{ PyBytes, PyDict, PyIterator, PyList, PyObject, PyResult, PyTuple, Python, PythonObject, ToPyObject, }; -use failure::Fallible as Result; use revisionstore::{DataStore, MutableDeltaStore, RemoteDataStore, ToKeys}; use types::{Key, Node}; diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/historystorepyext.rs b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/historystorepyext.rs index 9f63d566f4..ccbca3aac3 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/historystorepyext.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/historystorepyext.rs @@ -5,10 +5,10 @@ * GNU General Public License version 2. */ +use anyhow::Result; use cpython::{ PyBytes, PyIterator, PyList, PyObject, PyResult, PyTuple, Python, PythonObject, ToPyObject, }; -use failure::Fallible as Result; use revisionstore::{HistoryStore, MutableHistoryStore, RemoteHistoryStore, ToKeys}; use types::{Key, NodeInfo}; diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/lib.rs index a79f2013b9..b0b5d30a07 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/lib.rs @@ -15,8 +15,8 @@ use std::{ sync::Arc, }; +use anyhow::{format_err, Error}; use cpython::*; -use failure::{format_err, Error}; use parking_lot::RwLock; use cpython_ext::{Bytes, PyErr}; diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythondatastore.rs b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythondatastore.rs index cffff4f86c..e0fd2fcf8a 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythondatastore.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythondatastore.rs @@ -5,11 +5,11 @@ * GNU General Public License version 2. */ +use anyhow::Result; use cpython::{ exc, FromPyObject, ObjectProtocol, PyBytes, PyDict, PyList, PyObject, PyTuple, Python, PythonObject, PythonObjectWithTypeObject, }; -use failure::Fallible as Result; use cpython_ext::PyErr; use revisionstore::{DataStore, Delta, LocalStore, Metadata, RemoteDataStore}; diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonhistorystore.rs b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonhistorystore.rs index 736df12ebc..9074ada7d8 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonhistorystore.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonhistorystore.rs @@ -5,11 +5,11 @@ * GNU General Public License version 2. */ +use anyhow::Result; use cpython::{ exc, FromPyObject, ObjectProtocol, PyBytes, PyClone, PyList, PyObject, PyTuple, Python, PythonObject, PythonObjectWithTypeObject, }; -use failure::Fallible as Result; use cpython_ext::PyErr; use revisionstore::{HistoryStore, LocalStore}; diff --git a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonutil.rs b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonutil.rs index 8a7bf64e02..09d5be08ec 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonutil.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyrevisionstore/src/pythonutil.rs @@ -7,11 +7,11 @@ use std::io; +use anyhow::{Error, Result}; use cpython::{ exc, FromPyObject, PyBytes, PyDict, PyErr, PyObject, PyResult, PyTuple, Python, PythonObject, ToPyObject, }; -use failure::{Error, Fallible as Result}; use cpython_ext::PyErr as ExtPyErr; use revisionstore::datastore::{Delta, Metadata}; @@ -19,12 +19,9 @@ use types::{Key, Node, RepoPath, RepoPathBuf}; pub fn to_pyerr(py: Python, error: &Error) -> PyErr { if let Some(io_error) = error.downcast_ref::() { - PyErr::new::( - py, - (io_error.raw_os_error(), format!("{}", error.as_fail())), - ) + PyErr::new::(py, (io_error.raw_os_error(), format!("{}", error))) } else { - PyErr::new::(py, format!("{}", error.as_fail())) + PyErr::new::(py, format!("{}", error)) } } diff --git a/eden/scm/edenscmnative/bindings/modules/pytreestate/Cargo.toml b/eden/scm/edenscmnative/bindings/modules/pytreestate/Cargo.toml index 2675ab9095..d5cfea9993 100644 --- a/eden/scm/edenscmnative/bindings/modules/pytreestate/Cargo.toml +++ b/eden/scm/edenscmnative/bindings/modules/pytreestate/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" cpython-failure = { path = "../../../../lib/cpython-failure" } cpython = { version = "0.3", features = ["python27-sys"], default-features = false } encoding = { path = "../../../../lib/encoding" } -failure = "0.1" treestate = { path = "../../../../lib/treestate" } diff --git a/eden/scm/edenscmnative/bindings/modules/pytreestate/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pytreestate/src/lib.rs index 67ed4e8ad6..9d8a0ef4de 100644 --- a/eden/scm/edenscmnative/bindings/modules/pytreestate/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pytreestate/src/lib.rs @@ -23,8 +23,8 @@ use std::cell::RefCell; use std::path::PathBuf; +use anyhow::Error; use cpython::*; -use failure::Error; use ::treestate::{ errors::ErrorKind, diff --git a/eden/scm/exec/hgmain/Cargo.toml b/eden/scm/exec/hgmain/Cargo.toml index 6f0873db12..99e5981319 100644 --- a/eden/scm/exec/hgmain/Cargo.toml +++ b/eden/scm/exec/hgmain/Cargo.toml @@ -14,8 +14,8 @@ hgcommands = { path = "../../lib/hgcommands" } pyblackbox = { path = "../../edenscmnative/bindings/modules/pyblackbox" } [target.'cfg(windows)'.dependencies] +anyhow = "1.0.20" winapi = {version = "0.3.7", features = ["handleapi", "processenv", "winbase"]} -failure = "0.1" [dependencies.encoding] path = "../../lib/encoding" diff --git a/eden/scm/exec/hgmain/src/windows.rs b/eden/scm/exec/hgmain/src/windows.rs index 3d6b1fb0d7..0c4870796e 100644 --- a/eden/scm/exec/hgmain/src/windows.rs +++ b/eden/scm/exec/hgmain/src/windows.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use failure::{format_err, Error}; +use anyhow::{format_err, Error}; use winapi::shared::minwindef::DWORD; use winapi::um::errhandlingapi::GetLastError; use winapi::um::handleapi::{SetHandleInformation, INVALID_HANDLE_VALUE}; diff --git a/eden/scm/exec/scm_daemon/Cargo.toml b/eden/scm/exec/scm_daemon/Cargo.toml index 9b7bc118b2..42d5158e2c 100644 --- a/eden/scm/exec/scm_daemon/Cargo.toml +++ b/eden/scm/exec/scm_daemon/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" clap = "2.32.0" env_logger = "0.7" -failure = "0.1.3" libc = "0.2" log = "0.4.6" serde = "1.0.80" diff --git a/eden/scm/exec/scm_daemon/src/error.rs b/eden/scm/exec/scm_daemon/src/error.rs index c29d21acef..b9f63c8f53 100644 --- a/eden/scm/exec/scm_daemon/src/error.rs +++ b/eden/scm/exec/scm_daemon/src/error.rs @@ -7,7 +7,7 @@ #![deny(warnings)] -pub use failure::Error; +pub use anyhow::{Error, Result}; use thiserror::Error; #[derive(Debug, Error)] @@ -15,5 +15,3 @@ pub enum ErrorKind { #[error("unexpected error {0}")] ScmDaemonUnexpectedError(String), } - -pub type Result = ::std::result::Result; diff --git a/eden/scm/exec/scm_daemon/src/main.rs b/eden/scm/exec/scm_daemon/src/main.rs index c24e3f6dd1..687f6c7435 100644 --- a/eden/scm/exec/scm_daemon/src/main.rs +++ b/eden/scm/exec/scm_daemon/src/main.rs @@ -7,11 +7,11 @@ pub mod error; +use anyhow::{bail, Result}; use clap::{App, Arg}; use commitcloudsubscriber::{ CommitCloudConfig, CommitCloudTcpReceiverService, CommitCloudWorkspaceSubscriberService, }; -use failure::{bail, Fallible as Result}; use log::info; use serde::Deserialize; use std::fs::File; diff --git a/eden/scm/exec/scratch/Cargo.toml b/eden/scm/exec/scratch/Cargo.toml index db0a3c8554..b7b12f687f 100644 --- a/eden/scm/exec/scratch/Cargo.toml +++ b/eden/scm/exec/scratch/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Source Control Oncall oncall+source_control@xmail.facebook.com"] edition = "2018" [dependencies] +anyhow = "1.0.20" clap = "2.31.2" dirs = "1.0" -failure = "0.1" libc = "0.2" # version taken from fbcode/third-party2/.../crates.io/.. serde = "1.0" serde_derive = "1.0" diff --git a/eden/scm/exec/scratch/src/main.rs b/eden/scm/exec/scratch/src/main.rs index 90db602b80..541b227213 100644 --- a/eden/scm/exec/scratch/src/main.rs +++ b/eden/scm/exec/scratch/src/main.rs @@ -13,8 +13,8 @@ //! may want to use watchman to watch a portion of the scratch space //! and can arrange the directory structure to prevent over-watching. +use anyhow::{bail, ensure, format_err, Result}; use clap::{App, AppSettings, Arg, SubCommand}; -use failure::{bail, format_err, Fallible as Result}; use serde::Deserialize; use std::collections::HashMap; use std::env; @@ -254,7 +254,7 @@ struct PasswordEntry { impl PasswordEntry { fn maybe_string(cstr: *const libc::c_char, context: &str) -> Result { if cstr.is_null() { - Err(failure::err_msg(context.to_string())) + bail!(context.to_string()); } else { let cstr = unsafe { std::ffi::CStr::from_ptr(cstr) }; cstr.to_str().map_err(|e| e.into()).map(|x| x.to_owned()) @@ -262,7 +262,7 @@ impl PasswordEntry { } fn from_password(pwent: *const libc::passwd) -> Result { - failure::ensure!(!pwent.is_null(), "password ptr is null"); + ensure!(!pwent.is_null(), "password ptr is null"); let pw = unsafe { &*pwent }; Ok(Self { unixname: Self::maybe_string(pw.pw_name, "pw_name is null")?, diff --git a/eden/scm/exec/utils/Cargo.toml b/eden/scm/exec/utils/Cargo.toml index 2b600535ac..cc3925f479 100644 --- a/eden/scm/exec/utils/Cargo.toml +++ b/eden/scm/exec/utils/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" bytes = { version = "0.4.11", features = ["serde"] } -failure = "0.1.3" indexedlog = { path = "../../lib/indexedlog" } manifest = { path = "../../lib/manifest" } pathmatcher = { path = "../../lib/pathmatcher" } diff --git a/eden/scm/exec/utils/src/bin/manifest.rs b/eden/scm/exec/utils/src/bin/manifest.rs index 42e4ae422a..439e367381 100644 --- a/eden/scm/exec/utils/src/bin/manifest.rs +++ b/eden/scm/exec/utils/src/bin/manifest.rs @@ -7,8 +7,8 @@ use std::{path::PathBuf, sync::Arc}; +use anyhow::{format_err, Result}; use bytes::Bytes; -use failure::{format_err, Fallible as Result}; use structopt::StructOpt; use pathmatcher::AlwaysMatcher; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncdatapack.rs b/eden/scm/lib/asyncrevisionstore/src/asyncdatapack.rs index f38658468e..28ab9964d1 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncdatapack.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncdatapack.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncdatastore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncdatastore.rs index 971ff1a780..19e891b703 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncdatastore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncdatastore.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use failure::{Error, Fallible as Result}; +use anyhow::{Error, Result}; use futures::{future::ok, stream::iter_ok}; use tokio::prelude::*; diff --git a/eden/scm/lib/asyncrevisionstore/src/asynchistorypack.rs b/eden/scm/lib/asyncrevisionstore/src/asynchistorypack.rs index c4c7117dd8..52fa696431 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asynchistorypack.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asynchistorypack.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asynchistorystore.rs b/eden/scm/lib/asyncrevisionstore/src/asynchistorystore.rs index d1bec11c0f..7ed5e76e90 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asynchistorystore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asynchistorystore.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use failure::{Error, Fallible as Result}; +use anyhow::{Error, Result}; use futures::{future::ok, stream::iter_ok}; use tokio::prelude::*; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncindexedlogdatastore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncindexedlogdatastore.rs index ed5b923dff..4570d56cbf 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncindexedlogdatastore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncindexedlogdatastore.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncindexedloghistorystore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncindexedloghistorystore.rs index ac4d673550..02936c0832 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncindexedloghistorystore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncindexedloghistorystore.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncmutabledatapack.rs b/eden/scm/lib/asyncrevisionstore/src/asyncmutabledatapack.rs index d4e33cdf8e..dd533e82f9 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncmutabledatapack.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncmutabledatapack.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncmutabledeltastore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncmutabledeltastore.rs index 4a56626dfc..c41921d508 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncmutabledeltastore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncmutabledeltastore.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorypack.rs b/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorypack.rs index 55c4e4669f..b945364531 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorypack.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorypack.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs index 245530278e..d19b8c6959 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::Error; +use anyhow::Error; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncuniondatastore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncuniondatastore.rs index cc626ac06f..2efc88785f 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncuniondatastore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncuniondatastore.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; -use failure::{Error, Fallible as Result}; +use anyhow::{Error, Result}; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncunionhistorystore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncunionhistorystore.rs index a90f3602e5..258458e213 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncunionhistorystore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncunionhistorystore.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; -use failure::{Error, Fallible as Result}; +use anyhow::{Error, Result}; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/asyncrevisionstore/src/util.rs b/eden/scm/lib/asyncrevisionstore/src/util.rs index 9d25d7e444..1b7e641314 100644 --- a/eden/scm/lib/asyncrevisionstore/src/util.rs +++ b/eden/scm/lib/asyncrevisionstore/src/util.rs @@ -7,7 +7,7 @@ use std::sync::Arc; -use failure::{Error, Fallible as Result}; +use anyhow::{Error, Result}; use futures::future::poll_fn; use tokio::prelude::*; use tokio_threadpool::blocking; diff --git a/eden/scm/lib/auth/Cargo.toml b/eden/scm/lib/auth/Cargo.toml index e0e8f13742..60784044f8 100644 --- a/eden/scm/lib/auth/Cargo.toml +++ b/eden/scm/lib/auth/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" bytes = "0.4.12" configparser = { path = "../configparser" } -failure = "0.1.6" indexmap = "1.0.1" url = "2.1.0" util = { path = "../util" } diff --git a/eden/scm/lib/auth/src/lib.rs b/eden/scm/lib/auth/src/lib.rs index 5ea433c866..5fe78338dd 100644 --- a/eden/scm/lib/auth/src/lib.rs +++ b/eden/scm/lib/auth/src/lib.rs @@ -7,8 +7,8 @@ use std::{collections::HashMap, convert::TryFrom, path::PathBuf, str}; +use anyhow::{Error, Result}; use bytes::Bytes; -use failure::{err_msg, Error, Fallible as Result}; use indexmap::IndexMap; use url::Url; @@ -38,7 +38,7 @@ impl TryFrom<(&str, HashMap<&str, Bytes>)> for Auth { .map(bytes_to_str) .transpose()? .map(String::from) - .ok_or(err_msg("auth prefix missing"))?; + .ok_or_else(|| Error::msg("auth prefix missing"))?; let cert = settings .get("cert") diff --git a/eden/scm/lib/backingstore/Cargo.toml b/eden/scm/lib/backingstore/Cargo.toml index f3d2e00c2d..a4c6a35e7b 100644 --- a/eden/scm/lib/backingstore/Cargo.toml +++ b/eden/scm/lib/backingstore/Cargo.toml @@ -9,8 +9,8 @@ configparser = { path = "../configparser" } manifest = { path = "../manifest" } revisionstore = { path = "../revisionstore" } types = { path = "../types" } +anyhow = "1.0.20" bytes = "0.4.12" -failure = "0.1.6" libc = "0.2.62" [lib] diff --git a/eden/scm/lib/backingstore/src/backingstore.rs b/eden/scm/lib/backingstore/src/backingstore.rs index 12c14201c9..f89045b44a 100644 --- a/eden/scm/lib/backingstore/src/backingstore.rs +++ b/eden/scm/lib/backingstore/src/backingstore.rs @@ -7,9 +7,9 @@ use crate::raw; use crate::treecontentstore::TreeContentStore; +use anyhow::Result; use configparser::config::ConfigSet; use configparser::hg::ConfigSetHgExt; -use failure::Fallible as Result; use manifest::Tree; use revisionstore::{ContentStore, ContentStoreBuilder, DataStore}; use std::convert::TryFrom; diff --git a/eden/scm/lib/backingstore/src/raw/backingstore.rs b/eden/scm/lib/backingstore/src/raw/backingstore.rs index e2397aedc2..046909e924 100644 --- a/eden/scm/lib/backingstore/src/raw/backingstore.rs +++ b/eden/scm/lib/backingstore/src/raw/backingstore.rs @@ -7,7 +7,7 @@ //! Provides the c-bindings for `crate::backingstore`. -use failure::{ensure, err_msg, Fallible as Result}; +use anyhow::{ensure, Error, Result}; use libc::{c_char, size_t}; use std::{slice, str}; @@ -59,7 +59,7 @@ fn backingstore_get_blob( store .get_blob(path, node) - .and_then(|opt| opt.ok_or_else(|| err_msg("no blob found"))) + .and_then(|opt| opt.ok_or_else(|| Error::msg("no blob found"))) .map(CBytes::from_vec) .map(|result| Box::into_raw(Box::new(result))) } diff --git a/eden/scm/lib/backingstore/src/raw/cfallible.rs b/eden/scm/lib/backingstore/src/raw/cfallible.rs index 380f8ace03..7c59a67abf 100644 --- a/eden/scm/lib/backingstore/src/raw/cfallible.rs +++ b/eden/scm/lib/backingstore/src/raw/cfallible.rs @@ -14,7 +14,7 @@ //! Consumer of this struct needs to ensure the returned error string freed with //! `rust_cfallible_free_error`. -use failure::Fallible as Result; +use anyhow::Result; use libc::c_char; use std::ffi::CString; diff --git a/eden/scm/lib/backingstore/src/raw/tree.rs b/eden/scm/lib/backingstore/src/raw/tree.rs index 54efc64170..01b6c4fe6e 100644 --- a/eden/scm/lib/backingstore/src/raw/tree.rs +++ b/eden/scm/lib/backingstore/src/raw/tree.rs @@ -10,7 +10,7 @@ //! Structs in this file should be keep in sync with `eden/fs/model/{Tree, TreeEntry}.h`. use crate::raw::CBytes; -use failure::{format_err, Fallible}; +use anyhow::{format_err, Result}; use manifest::{tree::List, FileType, FsNode}; use std::convert::TryFrom; use types::PathComponentBuf; @@ -44,7 +44,7 @@ pub struct TreeEntry { } impl TreeEntry { - fn try_from_path_node(path: PathComponentBuf, node: FsNode) -> Fallible { + fn try_from_path_node(path: PathComponentBuf, node: FsNode) -> Result { let (ttype, hash) = match node { FsNode::Directory(Some(hgid)) => (TreeEntryType::Tree, hgid.as_ref().to_vec()), FsNode::File(metadata) => (metadata.file_type.into(), metadata.hgid.as_ref().to_vec()), @@ -72,7 +72,7 @@ pub struct Tree { } impl TryFrom for Tree { - type Error = failure::Error; + type Error = anyhow::Error; fn try_from(list: List) -> Result { match list { @@ -81,7 +81,7 @@ impl TryFrom for Tree { let entries = list .into_iter() .map(|(path, node)| TreeEntry::try_from_path_node(path, node)) - .collect::>>()?; + .collect::>>()?; let entries = Box::new(entries); let length = entries.len(); diff --git a/eden/scm/lib/backingstore/src/treecontentstore.rs b/eden/scm/lib/backingstore/src/treecontentstore.rs index 1208f7e8d2..63bb2b0fe0 100644 --- a/eden/scm/lib/backingstore/src/treecontentstore.rs +++ b/eden/scm/lib/backingstore/src/treecontentstore.rs @@ -5,8 +5,8 @@ * GNU General Public License version 2. */ +use anyhow::{format_err, Result}; use bytes::Bytes; -use failure::{format_err, Fallible}; use manifest::TreeStore; use revisionstore::{ContentStore, DataStore}; use types::{HgId, Key, RepoPath}; @@ -22,7 +22,7 @@ impl TreeContentStore { } impl TreeStore for TreeContentStore { - fn get(&self, path: &RepoPath, hgid: HgId) -> Fallible { + fn get(&self, path: &RepoPath, hgid: HgId) -> Result { let key = Key::new(path.to_owned(), hgid); self.inner.get(&key).and_then(|opt| { @@ -31,7 +31,7 @@ impl TreeStore for TreeContentStore { }) } - fn insert(&self, _path: &RepoPath, _hgid: HgId, _data: Bytes) -> Fallible<()> { + fn insert(&self, _path: &RepoPath, _hgid: HgId, _data: Bytes) -> Result<()> { Err(format_err!("insert is not implemented.")) } } diff --git a/eden/scm/lib/blackbox/Cargo.toml b/eden/scm/lib/blackbox/Cargo.toml index 00155d9325..ccd878cab2 100644 --- a/eden/scm/lib/blackbox/Cargo.toml +++ b/eden/scm/lib/blackbox/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" byteorder = "1" -failure = "0.1" indexedlog = { path = "../indexedlog" } lazy_static = "1" libc = "0.2" diff --git a/eden/scm/lib/blackbox/src/blackbox.rs b/eden/scm/lib/blackbox/src/blackbox.rs index 2f04757000..a89e39a12a 100644 --- a/eden/scm/lib/blackbox/src/blackbox.rs +++ b/eden/scm/lib/blackbox/src/blackbox.rs @@ -7,8 +7,8 @@ use super::{capture_pattern, json, match_pattern}; use crate::event::Event; +use anyhow::Result; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::Fallible as Result; use indexedlog::log::IndexOutput; use indexedlog::rotate::{OpenOptions, RotateLog, RotateLowLevelExt}; use lazy_static::lazy_static; diff --git a/eden/scm/lib/blackbox/src/event.rs b/eden/scm/lib/blackbox/src/event.rs index e9a5732d13..66320553e9 100644 --- a/eden/scm/lib/blackbox/src/event.rs +++ b/eden/scm/lib/blackbox/src/event.rs @@ -14,7 +14,7 @@ //! types of events that are outside this module. use super::ToValue; -use failure::Fallible as Result; +use anyhow::Result; use serde_alt::serde_alt; use serde_derive::{Deserialize, Serialize}; use serde_json::Value; diff --git a/eden/scm/lib/bookmarkstore/Cargo.toml b/eden/scm/lib/bookmarkstore/Cargo.toml index 7ad4dbb2e4..d19a1bd0c6 100644 --- a/eden/scm/lib/bookmarkstore/Cargo.toml +++ b/eden/scm/lib/bookmarkstore/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Facebook Source Control Team "] edition = "2018" [dependencies] +anyhow = "1.0.20" atomicwrites = "0.2.2" -failure = "0.1.5" types = { path = "../types" } indexedlog = { path = "../indexedlog" } thiserror = "1.0.5" diff --git a/eden/scm/lib/bookmarkstore/src/lib.rs b/eden/scm/lib/bookmarkstore/src/lib.rs index c63033ee2e..f25e40216b 100644 --- a/eden/scm/lib/bookmarkstore/src/lib.rs +++ b/eden/scm/lib/bookmarkstore/src/lib.rs @@ -16,7 +16,7 @@ use std::io::Write; use std::path::Path; use std::str; -use failure::Fallible as Result; +use anyhow::Result; use indexedlog::log::{IndexDef, IndexOutput, Log}; use types::hgid::HgId; diff --git a/eden/scm/lib/clidispatch/Cargo.toml b/eden/scm/lib/clidispatch/Cargo.toml index ac1b96caaa..256fe6ef26 100644 --- a/eden/scm/lib/clidispatch/Cargo.toml +++ b/eden/scm/lib/clidispatch/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Facebook Source Control Team "] edition = "2018" [dependencies] +anyhow = "1.0.20" bytes = "0.4.10" blackbox = { path = "../blackbox" } configparser = { path = "../configparser" } cliparser = { path = "../cliparser" } -failure = "0.1.3" indexedlog = { path = "../indexedlog" } thiserror = "1.0.5" util = { path = "../util" } diff --git a/eden/scm/lib/clidispatch/src/command.rs b/eden/scm/lib/clidispatch/src/command.rs index da4c972bcb..5c42977404 100644 --- a/eden/scm/lib/clidispatch/src/command.rs +++ b/eden/scm/lib/clidispatch/src/command.rs @@ -6,8 +6,8 @@ */ use crate::{io::IO, repo::Repo}; +use anyhow::Result; use cliparser::parser::{Flag, ParseOutput, StructFlags}; -use failure::Fallible as Result; use std::collections::BTreeMap; use std::convert::{TryFrom, TryInto}; use std::ops::Deref; @@ -105,7 +105,7 @@ pub trait Register { // NoRepo commands. impl Register for CommandTable where - S: TryFrom + StructFlags, + S: TryFrom + StructFlags, FN: Fn(S, &mut IO) -> Result + 'static, { fn register(&mut self, f: FN, name: &str, doc: &str) { @@ -120,7 +120,7 @@ where // OptionalRepo commands. impl Register for CommandTable where - S: TryFrom + StructFlags, + S: TryFrom + StructFlags, FN: Fn(S, &mut IO, Option) -> Result + 'static, { fn register(&mut self, f: FN, name: &str, doc: &str) { @@ -136,7 +136,7 @@ where // Repo commands. impl Register for CommandTable where - S: TryFrom + StructFlags, + S: TryFrom + StructFlags, FN: Fn(S, &mut IO, Repo) -> Result + 'static, { fn register(&mut self, f: FN, name: &str, doc: &str) { diff --git a/eden/scm/lib/clidispatch/src/dispatch.rs b/eden/scm/lib/clidispatch/src/dispatch.rs index 0ecb701637..67f50240c5 100644 --- a/eden/scm/lib/clidispatch/src/dispatch.rs +++ b/eden/scm/lib/clidispatch/src/dispatch.rs @@ -10,12 +10,12 @@ use crate::errors; use crate::global_flags::HgGlobalOpts; use crate::io::IO; use crate::repo::OptionalRepo; +use anyhow::Error; use bytes::Bytes; use cliparser::alias::{expand_aliases, find_command_name}; use cliparser::parser::{ParseError, ParseOptions, ParseOutput, StructFlags}; use configparser::config::ConfigSet; use configparser::hg::ConfigSetHgExt; -use failure::Error; use std::convert::TryInto; use std::{env, path::Path}; diff --git a/eden/scm/lib/clidispatch/src/errors.rs b/eden/scm/lib/clidispatch/src/errors.rs index 4938b01d69..f5783c7c06 100644 --- a/eden/scm/lib/clidispatch/src/errors.rs +++ b/eden/scm/lib/clidispatch/src/errors.rs @@ -48,7 +48,7 @@ pub struct Abort(pub Cow<'static, str>); /// Print an error suitable for end-user consumption. /// /// This function adds `hg:` or `abort:` to error messages. -pub fn print_error(err: &failure::Error, io: &mut crate::io::IO) { +pub fn print_error(err: &anyhow::Error, io: &mut crate::io::IO) { use cliparser::parser::ParseError; if err.downcast_ref::().is_some() { let _ = io.write_err(format!("hg: parse error: {}\n", err)); diff --git a/eden/scm/lib/clidispatch/src/lib.rs b/eden/scm/lib/clidispatch/src/lib.rs index cbecc12102..718669b2f7 100644 --- a/eden/scm/lib/clidispatch/src/lib.rs +++ b/eden/scm/lib/clidispatch/src/lib.rs @@ -13,6 +13,3 @@ pub mod errors; pub mod global_flags; pub mod io; pub mod repo; - -// Re-export -pub use failure; diff --git a/eden/scm/lib/clidispatch/src/repo.rs b/eden/scm/lib/clidispatch/src/repo.rs index 9cecfb2c2a..c8fb90be36 100644 --- a/eden/scm/lib/clidispatch/src/repo.rs +++ b/eden/scm/lib/clidispatch/src/repo.rs @@ -6,8 +6,8 @@ */ use crate::errors; +use anyhow::Result; use configparser::{config::ConfigSet, hg::ConfigSetHgExt}; -use failure::Fallible as Result; use std::fs; use std::path::Path; use std::path::PathBuf; diff --git a/eden/scm/lib/cliparser/Cargo.toml b/eden/scm/lib/cliparser/Cargo.toml index 2f1d39e8be..c9be22edb8 100644 --- a/eden/scm/lib/cliparser/Cargo.toml +++ b/eden/scm/lib/cliparser/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Facebook Source Control Team "] edition = "2018" [dependencies] -failure = "0.1.3" +anyhow = "1.0.20" lazy_static = "1.3.0" shlex = "0.1" cpython-ext = { path = "../cpython-ext", optional = true } diff --git a/eden/scm/lib/cliparser/src/macros.rs b/eden/scm/lib/cliparser/src/macros.rs index 64473e3ea6..87e151a433 100644 --- a/eden/scm/lib/cliparser/src/macros.rs +++ b/eden/scm/lib/cliparser/src/macros.rs @@ -47,9 +47,9 @@ macro_rules! _define_flags_impl { } impl ::std::convert::TryFrom<$crate::parser::ParseOutput> for $name { - type Error = ::failure::Error; + type Error = ::anyhow::Error; - fn try_from(out: $crate::parser::ParseOutput) -> ::failure::Fallible { + fn try_from(out: $crate::parser::ParseOutput) -> ::anyhow::Result { if !$has_varargs && out.args.len() > $varargs_offset { return Err($crate::errors::InvalidArguments.into()); } diff --git a/eden/scm/lib/commitcloudsubscriber/Cargo.toml b/eden/scm/lib/commitcloudsubscriber/Cargo.toml index e133e96284..f4267dbd36 100644 --- a/eden/scm/lib/commitcloudsubscriber/Cargo.toml +++ b/eden/scm/lib/commitcloudsubscriber/Cargo.toml @@ -16,8 +16,8 @@ description = """ \ edition = "2018" [dependencies] +anyhow = "1.0.20" eventsource = "0.3.0" -failure = "0.1.3" lazy_static = "1.2.0" log = "0.4.6" serde = { version = "1.0.80", features = ["derive"] } diff --git a/eden/scm/lib/commitcloudsubscriber/src/action.rs b/eden/scm/lib/commitcloudsubscriber/src/action.rs index 41319261b3..222f160fd4 100644 --- a/eden/scm/lib/commitcloudsubscriber/src/action.rs +++ b/eden/scm/lib/commitcloudsubscriber/src/action.rs @@ -6,7 +6,7 @@ */ use crate::error::*; -use failure::Fallible as Result; +use anyhow::Result; use log::{error, info}; use std::path::Path; use std::process::{Command, Stdio}; diff --git a/eden/scm/lib/commitcloudsubscriber/src/receiver.rs b/eden/scm/lib/commitcloudsubscriber/src/receiver.rs index 987725f91e..59209b71bf 100644 --- a/eden/scm/lib/commitcloudsubscriber/src/receiver.rs +++ b/eden/scm/lib/commitcloudsubscriber/src/receiver.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use failure::Fallible as Result; +use anyhow::Result; use log::{error, info}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; diff --git a/eden/scm/lib/commitcloudsubscriber/src/subscriber.rs b/eden/scm/lib/commitcloudsubscriber/src/subscriber.rs index 03e86b4ca5..0af10c1b99 100644 --- a/eden/scm/lib/commitcloudsubscriber/src/subscriber.rs +++ b/eden/scm/lib/commitcloudsubscriber/src/subscriber.rs @@ -13,8 +13,8 @@ use crate::receiver::CommandName::{ CommitCloudStartSubscriptions, }; use crate::util; +use anyhow::{bail, Result}; use eventsource::reqwest::Client; -use failure::{bail, Fallible as Result}; use log::{error, info, warn}; use reqwest::Url; use serde::Deserialize; diff --git a/eden/scm/lib/commitcloudsubscriber/src/util.rs b/eden/scm/lib/commitcloudsubscriber/src/util.rs index 24da45f9f0..fadd92acd7 100644 --- a/eden/scm/lib/commitcloudsubscriber/src/util.rs +++ b/eden/scm/lib/commitcloudsubscriber/src/util.rs @@ -7,7 +7,7 @@ use crate::error::*; use crate::subscriber::Subscription; -use failure::{bail, Fallible as Result}; +use anyhow::{bail, Result}; use ini::Ini; use log::{error, info}; use std::collections::HashMap; diff --git a/eden/scm/lib/configparser/Cargo.toml b/eden/scm/lib/configparser/Cargo.toml index 7061c1b280..539c7928b6 100644 --- a/eden/scm/lib/configparser/Cargo.toml +++ b/eden/scm/lib/configparser/Cargo.toml @@ -4,14 +4,14 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.19" bytes = "0.4.10" dirs = "1.0.4" -failure = "0.1.2" -failure_derive = "0.1.2" indexmap = "1.0.1" parking_lot = "0.9" pest = "2.1.0" pest_derive = "2.1.0" +thiserror = "1.0.5" util = { path = "../util" } [dev-dependencies] diff --git a/eden/scm/lib/configparser/src/error.rs b/eden/scm/lib/configparser/src/error.rs index e9f49be9b1..ffb4e7ff59 100644 --- a/eden/scm/lib/configparser/src/error.rs +++ b/eden/scm/lib/configparser/src/error.rs @@ -9,24 +9,24 @@ use std::io; use std::path::PathBuf; use std::str; -use failure::Fail; +use thiserror::Error; /// The error type for parsing config files. -#[derive(Fail, Debug)] +#[derive(Error, Debug)] pub enum Error { /// Unable to convert to a type. - #[fail(display = "{}", _0)] + #[error("{0}")] Convert(String), /// Unable to parse a file due to syntax. - #[fail(display = "{:?}:\n{}", _0, _1)] + #[error("{0:?}:\n{1}")] Parse(PathBuf, String), /// Unable to read a file due to IO errors. - #[fail(display = "{:?}: {}", _0, _1)] - Io(PathBuf, #[cause] io::Error), + #[error("{0:?}: {1}")] + Io(PathBuf, #[source] io::Error), /// Config file contains invalid UTF-8. - #[fail(display = "{:?}: {}", _0, _1)] - Utf8(PathBuf, #[cause] str::Utf8Error), + #[error("{0:?}: {1}")] + Utf8(PathBuf, #[source] str::Utf8Error), } diff --git a/eden/scm/lib/configparser/src/hg.rs b/eden/scm/lib/configparser/src/hg.rs index cbd184f096..9ffccc0e2d 100644 --- a/eden/scm/lib/configparser/src/hg.rs +++ b/eden/scm/lib/configparser/src/hg.rs @@ -13,8 +13,8 @@ use std::env; use std::hash::Hash; use std::path::{Path, PathBuf}; +use anyhow::Result; use bytes::Bytes; -use failure::Fallible as Result; use util::path::expand_path; use crate::config::{ConfigSet, Options}; diff --git a/eden/scm/lib/cpython-ext/Cargo.toml b/eden/scm/lib/cpython-ext/Cargo.toml index b2d0dc4c2f..77b546e2cf 100644 --- a/eden/scm/lib/cpython-ext/Cargo.toml +++ b/eden/scm/lib/cpython-ext/Cargo.toml @@ -9,7 +9,7 @@ python2 = [] python3 = [] [dependencies] -failure = "0.1.3" +anyhow = "1.0.20" serde = "1" [dependencies.cpython] diff --git a/eden/scm/lib/cpython-ext/src/failure.rs b/eden/scm/lib/cpython-ext/src/failure.rs index 2c50a934a7..ec69e2a224 100644 --- a/eden/scm/lib/cpython-ext/src/failure.rs +++ b/eden/scm/lib/cpython-ext/src/failure.rs @@ -5,10 +5,10 @@ * GNU General Public License version 2. */ -//! Integrate cpython with failure +//! Integrate cpython with anyhow +use anyhow::{Error, Result}; use cpython::{ObjectProtocol, PyClone, PyResult, Python, PythonObjectWithTypeObject}; -use failure::{AsFail, Error, Fallible as Result}; use std::fmt; /// Extends the `Result` type to allow conversion to `PyResult` by specifying a @@ -20,9 +20,9 @@ use std::fmt; /// # Examples /// /// ``` +/// use anyhow::{format_err, Error}; /// use cpython::{exc, Python, PyResult}; /// use cpython_ext::failure::ResultPyErrExt; -/// use failure::{format_err, Error}; /// /// fn fail_if_negative(i: i32) -> Result { /// if (i >= 0) { @@ -45,8 +45,8 @@ pub trait ResultPyErrExt { /// # Examples /// /// ``` +/// use anyhow::Result; /// use cpython_ext::failure::{FallibleExt, PyErr}; -/// use failure::Fallible as Result; /// /// fn eval_py() -> Result { /// let gil = cpython::Python::acquire_gil(); @@ -68,10 +68,10 @@ pub trait FallibleExt { fn into_fallible(self) -> Result; } -impl ResultPyErrExt for std::result::Result { +impl> ResultPyErrExt for Result { fn map_pyerr(self, py: Python<'_>) -> PyResult { self.map_err(|e| { - let e = e.as_fail(); + let e = e.into(); if let Some(e) = e.downcast_ref::() { e.inner.clone_ref(py) } else { @@ -83,7 +83,7 @@ impl ResultPyErrExt for std::result::Result { impl FallibleExt for PyResult { fn into_fallible(self) -> Result { - self.map_err(|e| Error::from_boxed_compat(Box::new(PyErr::from(e)))) + self.map_err(|e| Error::new(PyErr::from(e))) } } diff --git a/eden/scm/lib/dag/Cargo.toml b/eden/scm/lib/dag/Cargo.toml index 7473cfb5d2..cc9fc4e5fa 100644 --- a/eden/scm/lib/dag/Cargo.toml +++ b/eden/scm/lib/dag/Cargo.toml @@ -7,9 +7,9 @@ edition = "2018" indexedlog = { path = "../indexedlog" } vlqencoding = { path = "../vlqencoding" } +anyhow = "1.0.20" bitflags = "1" byteorder = "1.2.7" -failure = "0.1.5" fs2 = "0.4.3" indexmap = "1.0.1" tempfile = "3.0.7" diff --git a/eden/scm/lib/dag/benches/dag_ops.rs b/eden/scm/lib/dag/benches/dag_ops.rs index 49f4b9039e..52771e0ccc 100644 --- a/eden/scm/lib/dag/benches/dag_ops.rs +++ b/eden/scm/lib/dag/benches/dag_ops.rs @@ -5,8 +5,8 @@ * GNU General Public License version 2. */ +use anyhow::Result; use dag::{idmap::IdMap, segment::Dag, spanset::SpanSet}; -use failure::Fallible as Result; use minibench::{bench, elapsed}; use tempfile::tempdir; diff --git a/eden/scm/lib/dag/benches/segment_sizes.rs b/eden/scm/lib/dag/benches/segment_sizes.rs index 8bb02db720..ea9d431b7a 100644 --- a/eden/scm/lib/dag/benches/segment_sizes.rs +++ b/eden/scm/lib/dag/benches/segment_sizes.rs @@ -5,8 +5,8 @@ * GNU General Public License version 2. */ +use anyhow::Result; use dag::{idmap::IdMap, segment::Dag}; -use failure::Fallible as Result; use minibench::{ bench, elapsed, measure::{self, Measure}, diff --git a/eden/scm/lib/dag/src/idmap.rs b/eden/scm/lib/dag/src/idmap.rs index 25b9b78ebd..25e698dc29 100644 --- a/eden/scm/lib/dag/src/idmap.rs +++ b/eden/scm/lib/dag/src/idmap.rs @@ -9,8 +9,8 @@ //! //! See [`IdMap`] for the main structure. +use anyhow::{bail, ensure, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::{bail, ensure, Fallible as Result}; use fs2::FileExt; use indexedlog::log; use std::fs::{self, File}; diff --git a/eden/scm/lib/dag/src/segment.rs b/eden/scm/lib/dag/src/segment.rs index 3d4d65a757..23c4ebdf9a 100644 --- a/eden/scm/lib/dag/src/segment.rs +++ b/eden/scm/lib/dag/src/segment.rs @@ -16,9 +16,9 @@ use crate::spanset::Span; use crate::spanset::SpanSet; +use anyhow::{bail, Result}; use bitflags::bitflags; use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; -use failure::{bail, Fallible as Result}; use fs2::FileExt; use indexedlog::log; use indexmap::set::IndexSet; diff --git a/eden/scm/lib/dag/src/tests.rs b/eden/scm/lib/dag/src/tests.rs index 46d7c3c26d..bf5f80a74f 100644 --- a/eden/scm/lib/dag/src/tests.rs +++ b/eden/scm/lib/dag/src/tests.rs @@ -8,7 +8,7 @@ use crate::idmap::IdMap; use crate::segment::Dag; use crate::spanset::SpanSet; -use failure::Fallible as Result; +use anyhow::Result; use tempfile::tempdir; // Example from segmented-changelog.pdf diff --git a/eden/scm/lib/edenapi/Cargo.toml b/eden/scm/lib/edenapi/Cargo.toml index 21855e2820..05ce614658 100644 --- a/eden/scm/lib/edenapi/Cargo.toml +++ b/eden/scm/lib/edenapi/Cargo.toml @@ -4,12 +4,12 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" auth = { path = "../auth" } blackbox = { path = "../blackbox" } bytes = "0.4.11" configparser = { path = "../configparser" } curl = { version = "0.4.20", features = ["http2"] } -failure = "0.1.3" http = "0.1.17" itertools = "0.8.0" lazy_static = "1.2" diff --git a/eden/scm/lib/edenapi/src/config.rs b/eden/scm/lib/edenapi/src/config.rs index 8eb6caeda6..0e86ddcf76 100644 --- a/eden/scm/lib/edenapi/src/config.rs +++ b/eden/scm/lib/edenapi/src/config.rs @@ -187,7 +187,7 @@ mod tests { use std::fs::File; - use failure::Fallible as Result; + use anyhow::Result; use tempdir::TempDir; use configparser::config::Options; diff --git a/eden/scm/lib/edenapi/src/curl.rs b/eden/scm/lib/edenapi/src/curl.rs index 03e5dbebcf..019273bd11 100644 --- a/eden/scm/lib/edenapi/src/curl.rs +++ b/eden/scm/lib/edenapi/src/curl.rs @@ -7,13 +7,13 @@ use std::{cmp, sync::mpsc::channel, sync::Arc, thread, time::Instant}; +use anyhow::{format_err, Result}; use bytes::Bytes; use curl::{ self, easy::{Easy2, Handler, HttpVersion, List}, multi::Multi, }; -use failure::{format_err, Fallible}; use itertools::Itertools; use parking_lot::{Mutex, MutexGuard}; use serde::{de::DeserializeOwned, Serialize}; @@ -583,7 +583,7 @@ fn prepare_cbor_post( /// Check the integrity of the data in this entry and either return /// the data or an integrity check failure depending on the validation /// result and the user's configuration. -fn check_data(entry: &DataEntry, validate: bool) -> Fallible { +fn check_data(entry: &DataEntry, validate: bool) -> Result { log::trace!("Validating data for: {}", entry.key()); let (data, validity) = entry.data(); diff --git a/eden/scm/lib/edenapi/src/errors.rs b/eden/scm/lib/edenapi/src/errors.rs index 421c6e7305..3fbe963170 100644 --- a/eden/scm/lib/edenapi/src/errors.rs +++ b/eden/scm/lib/edenapi/src/errors.rs @@ -7,11 +7,12 @@ use std::{ convert::TryInto, + error::Error as StdError, fmt::{self, Display}, path::PathBuf, }; -use failure::{Backtrace, Error, Fail}; +use anyhow::{Error, Result}; use http::StatusCode; use thiserror::Error; @@ -59,13 +60,12 @@ impl ApiError { } } -impl Fail for ApiError { - fn cause(&self) -> Option<&dyn Fail> { - self.cause.as_ref().map(Error::as_fail) - } - - fn backtrace(&self) -> Option<&Backtrace> { - self.cause.as_ref().map(Error::backtrace) +impl StdError for ApiError { + fn source(&self) -> Option<&(dyn StdError + 'static)> { + match &self.cause { + Some(cause) => Some(&**cause), + None => None, + } } } diff --git a/eden/scm/lib/hg_watchman_client/Cargo.toml b/eden/scm/lib/hg_watchman_client/Cargo.toml index 8c263f71a1..a87a2cbfff 100644 --- a/eden/scm/lib/hg_watchman_client/Cargo.toml +++ b/eden/scm/lib/hg_watchman_client/Cargo.toml @@ -5,9 +5,9 @@ edition = "2018" [dependencies] watchman_client = { version = "0.1.0", path = "../watchman_client" } +anyhow = "1.0.20" serde = "1" serde_json = "1" -failure = "0.1.3" [features] default = [] diff --git a/eden/scm/lib/hg_watchman_client/src/hgclient.rs b/eden/scm/lib/hg_watchman_client/src/hgclient.rs index 1a4a5e559c..a633dd98f5 100644 --- a/eden/scm/lib/hg_watchman_client/src/hgclient.rs +++ b/eden/scm/lib/hg_watchman_client/src/hgclient.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use failure::Fallible as Result; +use anyhow::Result; use serde_json::json; use std::path::{Path, PathBuf}; use watchman_client::queries::*; diff --git a/eden/scm/lib/hg_watchman_client/tester/Cargo.toml b/eden/scm/lib/hg_watchman_client/tester/Cargo.toml index 48a1d19156..df9b9c9586 100644 --- a/eden/scm/lib/hg_watchman_client/tester/Cargo.toml +++ b/eden/scm/lib/hg_watchman_client/tester/Cargo.toml @@ -6,9 +6,9 @@ edition = "2018" [dependencies] hg_watchman_client = { version = "0.1.0", path = "../" } watchman_client = { version = "0.1.0", path = "../../watchman_client/" } +anyhow = "1.0.20" clap = "2.32.0" serde = { version = "1", features = ["derive"] } -failure = "0.1.3" [features] default = [] diff --git a/eden/scm/lib/hg_watchman_client/tester/src/main.rs b/eden/scm/lib/hg_watchman_client/tester/src/main.rs index 1d5f6b313b..2388f6b070 100644 --- a/eden/scm/lib/hg_watchman_client/tester/src/main.rs +++ b/eden/scm/lib/hg_watchman_client/tester/src/main.rs @@ -55,7 +55,7 @@ macro_rules! println_result { } mod test_client { - use failure::bail; + use anyhow::{bail, Result}; use hg_watchman_client::{ HgWatchmanClient, QueryResponse, StateEnterResponse, StateLeaveResponse, }; @@ -69,8 +69,6 @@ mod test_client { use watchman_client::protocol::{JsonProtocol, Protocol}; use watchman_client::transport::Transport; - type Result = std::result::Result; - static FILENAME: &str = "tester_watchmanstate"; #[derive(Clone, Default, Debug, Serialize, Deserialize)] diff --git a/eden/scm/lib/hgcommands/Cargo.toml b/eden/scm/lib/hgcommands/Cargo.toml index 8d728a65d5..bb9623b12f 100644 --- a/eden/scm/lib/hgcommands/Cargo.toml +++ b/eden/scm/lib/hgcommands/Cargo.toml @@ -9,13 +9,13 @@ python2 = [] python3 = [] [dependencies] +anyhow = "1.0.20" bindings = { path = "../../edenscmnative/bindings" } blackbox = { path = "../blackbox" } clidispatch = { path = "../clidispatch" } cliparser = { path = "../cliparser", features = ["python"] } cpython-ext = { path = "../cpython-ext" } edenapi = { path = "../edenapi" } -failure = "0.1" flate2 = "1" hgtime = { path = "../hgtime"} indexedlog = { path = "../indexedlog" } diff --git a/eden/scm/lib/hgcommands/src/commands.rs b/eden/scm/lib/hgcommands/src/commands.rs index 592eaaedb8..b7902c6740 100644 --- a/eden/scm/lib/hgcommands/src/commands.rs +++ b/eden/scm/lib/hgcommands/src/commands.rs @@ -5,6 +5,7 @@ * GNU General Public License version 2. */ +use anyhow::Result; use clidispatch::{ command::{CommandTable, Register}, errors, @@ -12,7 +13,6 @@ use clidispatch::{ repo::Repo, }; use cliparser::define_flags; -use failure::Fallible as Result; use blackbox::{event::Event, json, SessionId}; use edenapi::{Config as EdenApiConfig, EdenApi, EdenApiCurlClient}; diff --git a/eden/scm/lib/hgcommands/src/run.rs b/eden/scm/lib/hgcommands/src/run.rs index ba44a4c315..bc346d9a9e 100644 --- a/eden/scm/lib/hgcommands/src/run.rs +++ b/eden/scm/lib/hgcommands/src/run.rs @@ -6,8 +6,8 @@ */ use crate::{commands, HgPython}; +use anyhow::Result; use clidispatch::{dispatch, errors}; -use failure::Fallible as Result; use parking_lot::Mutex; use std::env; use std::fs::File; diff --git a/eden/scm/lib/indexedlog/src/errors.rs b/eden/scm/lib/indexedlog/src/errors.rs index 44ab10b234..dfe510e407 100644 --- a/eden/scm/lib/indexedlog/src/errors.rs +++ b/eden/scm/lib/indexedlog/src/errors.rs @@ -21,7 +21,7 @@ use std::path::Path; // - The library can change error structure internals. That means accesses // to the error object are via public methods instead of struct or enum // fields. `Error` is the only opaque public error type. -// - Compatible with std Error. Therefore failure::Error is supported too. +// - Compatible with std Error. Therefore anyhow::Error is supported too. /// Represents all possible errors that can occur when using indexedlog. pub struct Error { diff --git a/eden/scm/lib/lz4-pyframe/Cargo.toml b/eden/scm/lib/lz4-pyframe/Cargo.toml index aecd569fe0..a456b37987 100644 --- a/eden/scm/lib/lz4-pyframe/Cargo.toml +++ b/eden/scm/lib/lz4-pyframe/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Facebook Source Control Team "] edition = "2018" [dependencies] +anyhow = "1.0.20" byteorder = "1" -failure = "0" libc = "0.2" lz4-sys = "1" thiserror = "1.0.5" diff --git a/eden/scm/lib/lz4-pyframe/src/lz4.rs b/eden/scm/lib/lz4-pyframe/src/lz4.rs index a44df3f639..1d1b43f1ec 100644 --- a/eden/scm/lib/lz4-pyframe/src/lz4.rs +++ b/eden/scm/lib/lz4-pyframe/src/lz4.rs @@ -5,8 +5,8 @@ * GNU General Public License version 2. */ +use anyhow::Result; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; -use failure::Fallible as Result; use libc::{c_int, c_void}; use lz4_sys::{ LZ4StreamDecode, LZ4StreamEncode, LZ4_compressBound, LZ4_compress_continue, LZ4_createStream, diff --git a/eden/scm/lib/manifest/Cargo.toml b/eden/scm/lib/manifest/Cargo.toml index 12abdf0923..9873233441 100644 --- a/eden/scm/lib/manifest/Cargo.toml +++ b/eden/scm/lib/manifest/Cargo.toml @@ -9,8 +9,8 @@ default = [] for-tests = ["quickcheck"] [dependencies] +anyhow = "1.0.20" bytes = { version = "0.4.11", features = ["serde"] } -failure = "0.1.3" once_cell = "1.0.2" quickcheck = { version = "0.9", optional = true } rand = { version = "0.7", optional = true } diff --git a/eden/scm/lib/manifest/src/lib.rs b/eden/scm/lib/manifest/src/lib.rs index 4120bcc04c..16a7ed3132 100644 --- a/eden/scm/lib/manifest/src/lib.rs +++ b/eden/scm/lib/manifest/src/lib.rs @@ -12,7 +12,7 @@ //! repository. The file path and file revision are then used to retrieve the contents of the //! file thus achieving the reconstruction of the entire repository state. -use failure::Fallible as Result; +use anyhow::Result; use types::{HgId, RepoPath, RepoPathBuf}; diff --git a/eden/scm/lib/manifest/src/tree/cursor.rs b/eden/scm/lib/manifest/src/tree/cursor.rs index 3f5d972e98..214aa408c7 100644 --- a/eden/scm/lib/manifest/src/tree/cursor.rs +++ b/eden/scm/lib/manifest/src/tree/cursor.rs @@ -7,7 +7,7 @@ use std::collections::btree_map; -use failure::Error; +use anyhow::Error; use types::{PathComponentBuf, RepoPath, RepoPathBuf}; diff --git a/eden/scm/lib/manifest/src/tree/diff.rs b/eden/scm/lib/manifest/src/tree/diff.rs index 4507b92538..0e625a76ea 100644 --- a/eden/scm/lib/manifest/src/tree/diff.rs +++ b/eden/scm/lib/manifest/src/tree/diff.rs @@ -7,7 +7,7 @@ use std::{cmp::Ordering, collections::VecDeque, mem}; -use failure::Fallible as Result; +use anyhow::Result; use pathmatcher::{DirectoryMatch, Matcher}; use types::{RepoPath, RepoPathBuf}; diff --git a/eden/scm/lib/manifest/src/tree/files.rs b/eden/scm/lib/manifest/src/tree/files.rs index b3aa2f69a1..c84560a096 100644 --- a/eden/scm/lib/manifest/src/tree/files.rs +++ b/eden/scm/lib/manifest/src/tree/files.rs @@ -7,7 +7,7 @@ use std::{collections::VecDeque, mem}; -use failure::Fallible as Result; +use anyhow::Result; use pathmatcher::{DirectoryMatch, Matcher}; use types::{HgId, RepoPathBuf}; diff --git a/eden/scm/lib/manifest/src/tree/link.rs b/eden/scm/lib/manifest/src/tree/link.rs index 2340fbf154..57bf61fb6e 100644 --- a/eden/scm/lib/manifest/src/tree/link.rs +++ b/eden/scm/lib/manifest/src/tree/link.rs @@ -7,7 +7,7 @@ use std::{collections::BTreeMap, sync::Arc}; -use failure::{bail, format_err, Fallible as Result}; +use anyhow::{bail, format_err, Result}; use once_cell::sync::OnceCell; use types::{HgId, PathComponentBuf, RepoPath}; diff --git a/eden/scm/lib/manifest/src/tree/mod.rs b/eden/scm/lib/manifest/src/tree/mod.rs index b63e8bfef1..d59c91ff21 100644 --- a/eden/scm/lib/manifest/src/tree/mod.rs +++ b/eden/scm/lib/manifest/src/tree/mod.rs @@ -20,9 +20,9 @@ use std::{ sync::Arc, }; +use anyhow::{bail, Result}; use bytes::Bytes; use crypto::{digest::Digest, sha1::Sha1}; -use failure::{bail, Fallible as Result}; use once_cell::sync::OnceCell; use pathmatcher::Matcher; diff --git a/eden/scm/lib/manifest/src/tree/store.rs b/eden/scm/lib/manifest/src/tree/store.rs index 4d2327cf52..d5b2ad8586 100644 --- a/eden/scm/lib/manifest/src/tree/store.rs +++ b/eden/scm/lib/manifest/src/tree/store.rs @@ -7,8 +7,8 @@ use std::{str::from_utf8, sync::Arc}; +use anyhow::{format_err, Result}; use bytes::{Bytes, BytesMut}; -use failure::{format_err, Fallible as Result}; use types::{HgId, Key, PathComponent, PathComponentBuf, RepoPath}; diff --git a/eden/scm/lib/manifest/src/tree/testutil.rs b/eden/scm/lib/manifest/src/tree/testutil.rs index 8b2f5b1e0e..bdd8a0770e 100644 --- a/eden/scm/lib/manifest/src/tree/testutil.rs +++ b/eden/scm/lib/manifest/src/tree/testutil.rs @@ -7,7 +7,7 @@ use std::sync::Arc; -use failure::Fallible as Result; +use anyhow::Result; use types::{testutil::*, HgId, RepoPath}; diff --git a/eden/scm/lib/metalog/Cargo.toml b/eden/scm/lib/metalog/Cargo.toml index 4aba7925f2..db6064f8d4 100644 --- a/eden/scm/lib/metalog/Cargo.toml +++ b/eden/scm/lib/metalog/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2018" [dependencies] -failure = "0.1.5" +anyhow = "1.0.20" indexedlog = { path = "../indexedlog" } lazy_static = "1" mincode = { path = "../mincode" } diff --git a/eden/scm/lib/metalog/src/errors.rs b/eden/scm/lib/metalog/src/errors.rs index ab4ad048ab..97ba916bdc 100644 --- a/eden/scm/lib/metalog/src/errors.rs +++ b/eden/scm/lib/metalog/src/errors.rs @@ -28,7 +28,7 @@ impl From for Error { } } -impl ForeignError for failure::Error {} +impl ForeignError for anyhow::Error {} impl ForeignError for indexedlog::Error {} impl ForeignError for mincode::Error {} impl ForeignError for std::io::Error {} diff --git a/eden/scm/lib/mutationstore/Cargo.toml b/eden/scm/lib/mutationstore/Cargo.toml index 2ec1afa96c..67331a1c5e 100644 --- a/eden/scm/lib/mutationstore/Cargo.toml +++ b/eden/scm/lib/mutationstore/Cargo.toml @@ -4,9 +4,8 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" byteorder = "1.2.7" -failure = "0.1.3" -failure_derive = "0.1.3" indexedlog = { path = "../indexedlog" } thiserror = "1.0.5" types = { path = "../types" } diff --git a/eden/scm/lib/mutationstore/src/lib.rs b/eden/scm/lib/mutationstore/src/lib.rs index c38ad663d2..46e5d526b9 100644 --- a/eden/scm/lib/mutationstore/src/lib.rs +++ b/eden/scm/lib/mutationstore/src/lib.rs @@ -27,8 +27,8 @@ //! an error to refer to later commits, and any entry that causes a cycle will //! be ignored. +use anyhow::Result; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::Fallible as Result; use indexedlog::log::{IndexDef, IndexOutput, Log}; use std::io::{Cursor, Read, Write}; use std::path::Path; diff --git a/eden/scm/lib/nodemap/Cargo.toml b/eden/scm/lib/nodemap/Cargo.toml index 5dac97b448..e296cdc4ce 100644 --- a/eden/scm/lib/nodemap/Cargo.toml +++ b/eden/scm/lib/nodemap/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Facebook Source Control Team "] edition = "2018" [dependencies] -failure = "0.1.3" +anyhow = "1.0.20" indexedlog = { path = "../indexedlog" } thiserror = "1.0.5" types = { path = "../types" } diff --git a/eden/scm/lib/nodemap/src/nodemap.rs b/eden/scm/lib/nodemap/src/nodemap.rs index 1373dadcbc..ec9ca66f19 100644 --- a/eden/scm/lib/nodemap/src/nodemap.rs +++ b/eden/scm/lib/nodemap/src/nodemap.rs @@ -8,7 +8,7 @@ use std::ops::Range; use std::path::Path; -use failure::Fallible as Result; +use anyhow::Result; use indexedlog::log::{self, IndexOutput, Log}; use thiserror::Error; use types::errors::KeyError; diff --git a/eden/scm/lib/nodemap/src/nodeset.rs b/eden/scm/lib/nodemap/src/nodeset.rs index ceb1de4a50..00cf8e7b21 100644 --- a/eden/scm/lib/nodemap/src/nodeset.rs +++ b/eden/scm/lib/nodemap/src/nodeset.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use failure::Fallible as Result; +use anyhow::Result; use indexedlog::log::{self, IndexOutput, Log}; use std::path::Path; use thiserror::Error; diff --git a/eden/scm/lib/radixbuf/Cargo.toml b/eden/scm/lib/radixbuf/Cargo.toml index 3695a3140d..291c2c3543 100644 --- a/eden/scm/lib/radixbuf/Cargo.toml +++ b/eden/scm/lib/radixbuf/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2018" [dependencies] -failure = "0.1.5" +anyhow = "1.0.20" thiserror = "1.0.5" vlqencoding = { path = "../vlqencoding" } diff --git a/eden/scm/lib/radixbuf/src/key.rs b/eden/scm/lib/radixbuf/src/key.rs index 808f2e2d27..281fb32e16 100644 --- a/eden/scm/lib/radixbuf/src/key.rs +++ b/eden/scm/lib/radixbuf/src/key.rs @@ -27,7 +27,7 @@ use crate::errors::ErrorKind; use crate::traits::Resize; -use failure::{bail, Fallible as Result}; +use anyhow::{bail, Result}; use std::io::{Cursor, Seek, SeekFrom, Write}; use vlqencoding::{VLQDecode, VLQEncode}; diff --git a/eden/scm/lib/radixbuf/src/radix.rs b/eden/scm/lib/radixbuf/src/radix.rs index 6b93648737..b87bb12e94 100644 --- a/eden/scm/lib/radixbuf/src/radix.rs +++ b/eden/scm/lib/radixbuf/src/radix.rs @@ -77,7 +77,7 @@ use crate::base16::Base16Iter; use crate::errors::ErrorKind; use crate::key::KeyId; use crate::traits::Resize; -use failure::{bail, Fallible as Result}; +use anyhow::{bail, Result}; /// Number of children ("pointer"s) a radix node has pub const RADIX_NCHILDREN: usize = 16; @@ -398,7 +398,6 @@ where mod tests { use super::*; use crate::key::{FixedKey, VariantKey}; - use failure::AsFail; use quickcheck::quickcheck; use std::collections::HashSet; use std::mem::transmute; @@ -413,33 +412,30 @@ mod tests { let key_id = (1u32 << 31).into(); let r = radix_insert_with_key(&mut radix_buf, 0, key_id, &key, FixedKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); - assert_eq!( - t, - format!("{}", ErrorKind::OffsetOverflow(2147483648).as_fail()) - ); + assert_eq!(t, format!("{}", ErrorKind::OffsetOverflow(2147483648))); // KeyId exceeds key buffer length let key_id = 30u32.into(); let r = radix_insert(&mut radix_buf, 0, key_id, FixedKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::InvalidKeyId(key_id).as_fail())); + assert_eq!(t, format!("{}", ErrorKind::InvalidKeyId(key_id))); // Radix root node offset exceeds radix buffer length let r = radix_insert_with_key(&mut radix_buf, 16, key_id, &key, FixedKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::OffsetOverflow(16).as_fail())); + assert_eq!(t, format!("{}", ErrorKind::OffsetOverflow(16))); // Radix node offset out of range during a lookup let prefix = [0xf].iter().cloned(); let r = radix_prefix_lookup(&radix_buf, 0, prefix, FixedKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::OffsetOverflow(15).as_fail())); + assert_eq!(t, format!("{}", ErrorKind::OffsetOverflow(15))); // Base16 sequence overflow let prefix = [21].iter().cloned(); let r = radix_prefix_lookup(&radix_buf, 0, prefix.clone(), FixedKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::InvalidBase16(21).as_fail())); + assert_eq!(t, format!("{}", ErrorKind::InvalidBase16(21))); // Inserting a same key with a same `KeyId` is okay let key_id1 = VariantKey::append(&mut key_buf, &b"ab"); @@ -452,7 +448,7 @@ mod tests { let t = format!("{}", r.unwrap_err()); assert_eq!( t, - format!("{}", ErrorKind::PrefixConflict(key_id1, key_id2).as_fail()) + format!("{}", ErrorKind::PrefixConflict(key_id1, key_id2)) ); // A key cannot be a prefix of another key @@ -476,12 +472,12 @@ mod tests { // Still impossible to cause key prefix conflicts let r = radix_insert(&mut radix_buf, 0, key_id4, VariantKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::AmbiguousPrefix.as_fail())); + assert_eq!(t, format!("{}", ErrorKind::AmbiguousPrefix)); let r = radix_insert(&mut radix_buf, 0, key_id5, VariantKey::read, &key_buf); let t = format!("{}", r.unwrap_err()); assert_eq!( t, - format!("{}", ErrorKind::PrefixConflict(key_id1, key_id5).as_fail()) + format!("{}", ErrorKind::PrefixConflict(key_id1, key_id5)) ); } @@ -502,7 +498,7 @@ mod tests { if i == 0 { // This is sub-optimal. But see the NOTE in RadixOffset::follow. let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::AmbiguousPrefix.as_fail())); + assert_eq!(t, format!("{}", ErrorKind::AmbiguousPrefix)); } else if i <= key1.len() * 2 { assert_eq!(r.unwrap(), Some(key1_id)); } else { @@ -519,7 +515,7 @@ mod tests { let r = radix_prefix_lookup(&radix_buf, 0, prefix, VariantKey::read, &key_buf); if i <= 5 { let t = format!("{}", r.unwrap_err()); - assert_eq!(t, format!("{}", ErrorKind::AmbiguousPrefix.as_fail())); + assert_eq!(t, format!("{}", ErrorKind::AmbiguousPrefix)); } else if i <= key1.len() * 2 { assert_eq!(r.unwrap(), Some(key1_id)); } else { diff --git a/eden/scm/lib/revisionstore/Cargo.toml b/eden/scm/lib/revisionstore/Cargo.toml index 6b890617a4..b3e5170cf1 100644 --- a/eden/scm/lib/revisionstore/Cargo.toml +++ b/eden/scm/lib/revisionstore/Cargo.toml @@ -9,12 +9,12 @@ default = [] for-tests = [] [dependencies] +anyhow = "1.0.20" bytes = { version = "0.4.11", features = ["serde"] } byteorder = "1.2.7" configparser = { path = "../configparser" } edenapi = { path = "../edenapi" } indexedlog = { path = "../indexedlog" } -failure = "0.1.3" lz4-pyframe = { path = "../lz4-pyframe" } memmap = "0.7.0" mpatch = { path = "../mpatch" } diff --git a/eden/scm/lib/revisionstore/src/c_api.rs b/eden/scm/lib/revisionstore/src/c_api.rs index f654f1258a..01f5b01fc7 100644 --- a/eden/scm/lib/revisionstore/src/c_api.rs +++ b/eden/scm/lib/revisionstore/src/c_api.rs @@ -19,7 +19,7 @@ use std::{ sync::Arc, }; -use failure::Fallible as Result; +use anyhow::Result; use types::{HgId, Key, RepoPath}; diff --git a/eden/scm/lib/revisionstore/src/contentstore.rs b/eden/scm/lib/revisionstore/src/contentstore.rs index f9c3be5381..e2776d6b32 100644 --- a/eden/scm/lib/revisionstore/src/contentstore.rs +++ b/eden/scm/lib/revisionstore/src/contentstore.rs @@ -10,7 +10,7 @@ use std::{ sync::Arc, }; -use failure::Fallible as Result; +use anyhow::Result; use configparser::{config::ConfigSet, hg::ConfigSetHgExt}; use types::Key; diff --git a/eden/scm/lib/revisionstore/src/dataindex.rs b/eden/scm/lib/revisionstore/src/dataindex.rs index a78d1c3968..10038cd384 100644 --- a/eden/scm/lib/revisionstore/src/dataindex.rs +++ b/eden/scm/lib/revisionstore/src/dataindex.rs @@ -12,8 +12,8 @@ use std::{ path::Path, }; +use anyhow::Result; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::Fallible as Result; use memmap::{Mmap, MmapOptions}; use thiserror::Error; diff --git a/eden/scm/lib/revisionstore/src/datapack.rs b/eden/scm/lib/revisionstore/src/datapack.rs index 761d723c40..dc26ba39fa 100644 --- a/eden/scm/lib/revisionstore/src/datapack.rs +++ b/eden/scm/lib/revisionstore/src/datapack.rs @@ -89,9 +89,9 @@ use std::{ sync::Arc, }; +use anyhow::{format_err, Result}; use byteorder::{BigEndian, ReadBytesExt}; use bytes::Bytes; -use failure::{format_err, Fallible as Result}; use memmap::{Mmap, MmapOptions}; use thiserror::Error; diff --git a/eden/scm/lib/revisionstore/src/datastore.rs b/eden/scm/lib/revisionstore/src/datastore.rs index 7c57762679..6f23131e30 100644 --- a/eden/scm/lib/revisionstore/src/datastore.rs +++ b/eden/scm/lib/revisionstore/src/datastore.rs @@ -11,9 +11,9 @@ use std::{ path::PathBuf, }; +use anyhow::{format_err, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use bytes::Bytes; -use failure::{format_err, Fallible as Result}; use serde_derive::{Deserialize, Serialize}; use types::Key; diff --git a/eden/scm/lib/revisionstore/src/edenapi.rs b/eden/scm/lib/revisionstore/src/edenapi.rs index 487e81666b..d75aab8e14 100644 --- a/eden/scm/lib/revisionstore/src/edenapi.rs +++ b/eden/scm/lib/revisionstore/src/edenapi.rs @@ -7,7 +7,7 @@ use std::sync::Arc; -use failure::Fallible as Result; +use anyhow::Result; use edenapi::EdenApi; use types::Key; diff --git a/eden/scm/lib/revisionstore/src/fanouttable.rs b/eden/scm/lib/revisionstore/src/fanouttable.rs index 77c9a7b719..1b0dd958b4 100644 --- a/eden/scm/lib/revisionstore/src/fanouttable.rs +++ b/eden/scm/lib/revisionstore/src/fanouttable.rs @@ -18,8 +18,8 @@ use std::{ option::Option, }; +use anyhow::Result; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::Fallible as Result; use thiserror::Error; use types::HgId; diff --git a/eden/scm/lib/revisionstore/src/historyindex.rs b/eden/scm/lib/revisionstore/src/historyindex.rs index 23c4cc4d26..0e1da02533 100644 --- a/eden/scm/lib/revisionstore/src/historyindex.rs +++ b/eden/scm/lib/revisionstore/src/historyindex.rs @@ -13,10 +13,10 @@ use std::{ path::Path, }; +use anyhow::Result; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use crypto::digest::Digest; use crypto::sha1::Sha1; -use failure::Fallible as Result; use memmap::{Mmap, MmapOptions}; use thiserror::Error; diff --git a/eden/scm/lib/revisionstore/src/historypack.rs b/eden/scm/lib/revisionstore/src/historypack.rs index 3bf2b326b5..de7af5eeee 100644 --- a/eden/scm/lib/revisionstore/src/historypack.rs +++ b/eden/scm/lib/revisionstore/src/historypack.rs @@ -90,8 +90,8 @@ use std::{ sync::Arc, }; +use anyhow::{format_err, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::{format_err, Fallible as Result}; use memmap::{Mmap, MmapOptions}; use thiserror::Error; diff --git a/eden/scm/lib/revisionstore/src/historystore.rs b/eden/scm/lib/revisionstore/src/historystore.rs index 6d2f64c79b..be28d82a95 100644 --- a/eden/scm/lib/revisionstore/src/historystore.rs +++ b/eden/scm/lib/revisionstore/src/historystore.rs @@ -7,7 +7,7 @@ use std::{ops::Deref, path::PathBuf}; -use failure::Fallible as Result; +use anyhow::Result; use types::{HistoryEntry, Key, NodeInfo}; diff --git a/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs b/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs index 41892dd0dd..fb2faa322f 100644 --- a/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs +++ b/eden/scm/lib/revisionstore/src/indexedlogdatastore.rs @@ -11,9 +11,9 @@ use std::{ sync::Arc, }; +use anyhow::{bail, ensure, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use bytes::Bytes; -use failure::{bail, ensure, Fallible as Result}; use parking_lot::RwLock; use indexedlog::{ diff --git a/eden/scm/lib/revisionstore/src/indexedloghistorystore.rs b/eden/scm/lib/revisionstore/src/indexedloghistorystore.rs index 4e75a4301e..c107813dbe 100644 --- a/eden/scm/lib/revisionstore/src/indexedloghistorystore.rs +++ b/eden/scm/lib/revisionstore/src/indexedloghistorystore.rs @@ -11,9 +11,9 @@ use std::{ sync::{Arc, RwLock}, }; +use anyhow::Result; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use crypto::{digest::Digest, sha1::Sha1}; -use failure::Fallible as Result; use indexedlog::{ log::IndexOutput, diff --git a/eden/scm/lib/revisionstore/src/localstore.rs b/eden/scm/lib/revisionstore/src/localstore.rs index 3838cb74ca..054770436b 100644 --- a/eden/scm/lib/revisionstore/src/localstore.rs +++ b/eden/scm/lib/revisionstore/src/localstore.rs @@ -9,7 +9,7 @@ use std::{ops::Deref, path::Path}; -use failure::Fallible as Result; +use anyhow::Result; use types::Key; diff --git a/eden/scm/lib/revisionstore/src/metadatastore.rs b/eden/scm/lib/revisionstore/src/metadatastore.rs index 12db532886..41786410b9 100644 --- a/eden/scm/lib/revisionstore/src/metadatastore.rs +++ b/eden/scm/lib/revisionstore/src/metadatastore.rs @@ -10,7 +10,7 @@ use std::{ sync::Arc, }; -use failure::Fallible as Result; +use anyhow::Result; use configparser::{config::ConfigSet, hg::ConfigSetHgExt}; use types::{Key, NodeInfo}; diff --git a/eden/scm/lib/revisionstore/src/multiplexstore.rs b/eden/scm/lib/revisionstore/src/multiplexstore.rs index 5b62aa9974..16e983c511 100644 --- a/eden/scm/lib/revisionstore/src/multiplexstore.rs +++ b/eden/scm/lib/revisionstore/src/multiplexstore.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use failure::{format_err, Fallible as Result}; +use anyhow::{format_err, Result}; use types::{Key, NodeInfo}; diff --git a/eden/scm/lib/revisionstore/src/mutabledatapack.rs b/eden/scm/lib/revisionstore/src/mutabledatapack.rs index d449f19130..929198fc9f 100644 --- a/eden/scm/lib/revisionstore/src/mutabledatapack.rs +++ b/eden/scm/lib/revisionstore/src/mutabledatapack.rs @@ -14,10 +14,10 @@ use std::{ u16, }; +use anyhow::{format_err, Result}; use byteorder::{BigEndian, WriteBytesExt}; use crypto::digest::Digest; use crypto::sha1::Sha1; -use failure::{format_err, Fallible as Result}; use parking_lot::Mutex; use tempfile::{Builder, NamedTempFile}; use thiserror::Error; diff --git a/eden/scm/lib/revisionstore/src/mutablehistorypack.rs b/eden/scm/lib/revisionstore/src/mutablehistorypack.rs index c015007241..84fecf07ed 100644 --- a/eden/scm/lib/revisionstore/src/mutablehistorypack.rs +++ b/eden/scm/lib/revisionstore/src/mutablehistorypack.rs @@ -14,10 +14,10 @@ use std::{ sync::Arc, }; +use anyhow::Result; use byteorder::WriteBytesExt; use crypto::digest::Digest; use crypto::sha1::Sha1; -use failure::Fallible as Result; use parking_lot::Mutex; use tempfile::NamedTempFile; use thiserror::Error; diff --git a/eden/scm/lib/revisionstore/src/mutablepack.rs b/eden/scm/lib/revisionstore/src/mutablepack.rs index b7b7165259..531bbf5fd3 100644 --- a/eden/scm/lib/revisionstore/src/mutablepack.rs +++ b/eden/scm/lib/revisionstore/src/mutablepack.rs @@ -9,7 +9,7 @@ use std::os::unix::fs::PermissionsExt; use std::{fs::Permissions, io::ErrorKind, path::PathBuf}; -use failure::Fallible as Result; +use anyhow::Result; use tempfile::NamedTempFile; use crate::error::EmptyMutablePack; diff --git a/eden/scm/lib/revisionstore/src/packstore.rs b/eden/scm/lib/revisionstore/src/packstore.rs index fed130387f..afe2809a93 100644 --- a/eden/scm/lib/revisionstore/src/packstore.rs +++ b/eden/scm/lib/revisionstore/src/packstore.rs @@ -16,7 +16,7 @@ use std::{ time::{Duration, Instant}, }; -use failure::Fallible as Result; +use anyhow::Result; use parking_lot::Mutex; use types::{Key, NodeInfo}; diff --git a/eden/scm/lib/revisionstore/src/packwriter.rs b/eden/scm/lib/revisionstore/src/packwriter.rs index c5037c1394..0ebfd6ee28 100644 --- a/eden/scm/lib/revisionstore/src/packwriter.rs +++ b/eden/scm/lib/revisionstore/src/packwriter.rs @@ -11,7 +11,7 @@ use std::{ io::{self, BufWriter, Write}, }; -use failure::Fallible as Result; +use anyhow::Result; /// A `PackWriter` will buffers all the writes to `T` and count the total number of bytes written. pub struct PackWriter { diff --git a/eden/scm/lib/revisionstore/src/repack.rs b/eden/scm/lib/revisionstore/src/repack.rs index 671bc446c3..9b660845c5 100644 --- a/eden/scm/lib/revisionstore/src/repack.rs +++ b/eden/scm/lib/revisionstore/src/repack.rs @@ -10,7 +10,7 @@ use std::{ path::{Path, PathBuf}, }; -use failure::{format_err, Error, Fallible as Result}; +use anyhow::{format_err, Error, Result}; use thiserror::Error; use types::Key; diff --git a/eden/scm/lib/revisionstore/src/sliceext.rs b/eden/scm/lib/revisionstore/src/sliceext.rs index 34b4b7df38..7b91a329f7 100644 --- a/eden/scm/lib/revisionstore/src/sliceext.rs +++ b/eden/scm/lib/revisionstore/src/sliceext.rs @@ -7,7 +7,7 @@ use std::{fmt::Debug, slice::SliceIndex}; -use failure::Fallible as Result; +use anyhow::Result; use thiserror::Error; #[derive(Debug, Error)] diff --git a/eden/scm/lib/revisionstore/src/testutil.rs b/eden/scm/lib/revisionstore/src/testutil.rs index 67707bf11f..7dbd417995 100644 --- a/eden/scm/lib/revisionstore/src/testutil.rs +++ b/eden/scm/lib/revisionstore/src/testutil.rs @@ -7,8 +7,8 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; +use anyhow::{Error, Result}; use bytes::Bytes; -use failure::{err_msg, Fallible as Result}; use edenapi::{ApiResult, DownloadStats, EdenApi, ProgressFn}; use types::{HgId, HistoryEntry, Key, NodeInfo, RepoPathBuf}; @@ -78,7 +78,7 @@ struct FakeRemoteDataStore { impl RemoteDataStore for FakeRemoteDataStore { fn prefetch(&self, keys: Vec) -> Result<()> { for k in keys { - let data = self.map.get(&k).ok_or(err_msg("Not found"))?; + let data = self.map.get(&k).ok_or_else(|| Error::msg("Not found"))?; let delta = Delta { data: data.clone(), base: None, @@ -133,7 +133,7 @@ impl RemoteHistoryStore for FakeRemoteHistoryStore { fn prefetch(&self, keys: Vec) -> Result<()> { for k in keys { self.store - .add(&k, self.map.get(&k).ok_or(err_msg("Not found"))?)? + .add(&k, self.map.get(&k).ok_or_else(|| Error::msg("Not found"))?)? } Ok(()) diff --git a/eden/scm/lib/revisionstore/src/uniondatastore.rs b/eden/scm/lib/revisionstore/src/uniondatastore.rs index 84b0e044cb..060724d397 100644 --- a/eden/scm/lib/revisionstore/src/uniondatastore.rs +++ b/eden/scm/lib/revisionstore/src/uniondatastore.rs @@ -6,7 +6,7 @@ */ // Union data store -use failure::{err_msg, Fallible as Result}; +use anyhow::{Error, Result}; use mpatch::mpatch::get_full_text; @@ -50,7 +50,7 @@ impl DataStore for UnionDataStore { .collect(); Ok(Some( - get_full_text(basetext.data.as_ref(), &deltas).map_err(|e| err_msg(e))?, + get_full_text(basetext.data.as_ref(), &deltas).map_err(Error::msg)?, )) } diff --git a/eden/scm/lib/revisionstore/src/unionhistorystore.rs b/eden/scm/lib/revisionstore/src/unionhistorystore.rs index d9c698387a..428e265f40 100644 --- a/eden/scm/lib/revisionstore/src/unionhistorystore.rs +++ b/eden/scm/lib/revisionstore/src/unionhistorystore.rs @@ -6,7 +6,7 @@ */ // Union history store -use failure::Fallible as Result; +use anyhow::Result; use types::{Key, NodeInfo}; diff --git a/eden/scm/lib/revisionstore/src/unionstore.rs b/eden/scm/lib/revisionstore/src/unionstore.rs index eac52c2cbe..6439b37138 100644 --- a/eden/scm/lib/revisionstore/src/unionstore.rs +++ b/eden/scm/lib/revisionstore/src/unionstore.rs @@ -9,7 +9,7 @@ use std::{slice::Iter, vec::IntoIter}; -use failure::Fallible as Result; +use anyhow::Result; use types::Key; diff --git a/eden/scm/lib/revisionstore/src/util.rs b/eden/scm/lib/revisionstore/src/util.rs index 85be26716f..6729d13541 100644 --- a/eden/scm/lib/revisionstore/src/util.rs +++ b/eden/scm/lib/revisionstore/src/util.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; -use failure::{format_err, Fallible as Result}; +use anyhow::{format_err, Result}; use configparser::{config::ConfigSet, hg::ConfigSetHgExt}; use util::path::create_dir; diff --git a/eden/scm/lib/treestate/Cargo.toml b/eden/scm/lib/treestate/Cargo.toml index c956474096..7c33be1b0b 100644 --- a/eden/scm/lib/treestate/Cargo.toml +++ b/eden/scm/lib/treestate/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Facebook Source Control Team "] edition = "2018" [dependencies] +anyhow = "1.0.20" bitflags = "1.0.4" byteorder = "1.2.7" -failure = "0.1.5" thiserror = "1.0.5" twox-hash = "*" vlqencoding = { version = "0.1.0", path = "../vlqencoding" } diff --git a/eden/scm/lib/treestate/src/filestore.rs b/eden/scm/lib/treestate/src/filestore.rs index 4a096222fb..6094a8bfe1 100644 --- a/eden/scm/lib/treestate/src/filestore.rs +++ b/eden/scm/lib/treestate/src/filestore.rs @@ -9,8 +9,8 @@ use crate::errors::ErrorKind; use crate::store::{BlockId, Store, StoreView}; +use anyhow::{bail, Result}; use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt}; -use failure::{bail, Fallible as Result}; use std::borrow::Cow; use std::cell::RefCell; use std::fs::File; diff --git a/eden/scm/lib/treestate/src/serialization.rs b/eden/scm/lib/treestate/src/serialization.rs index 0b1fd3f848..1501786cbd 100644 --- a/eden/scm/lib/treestate/src/serialization.rs +++ b/eden/scm/lib/treestate/src/serialization.rs @@ -13,8 +13,8 @@ use crate::store::BlockId; use crate::tree::{AggregatedState, Key, Node, NodeEntry, NodeEntryMap}; use crate::treedirstate::TreeDirstateRoot; use crate::treestate::TreeStateRoot; +use anyhow::{bail, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use failure::{bail, Fallible as Result}; use std::hash::Hasher; use std::io::{Cursor, Read, Write}; use twox_hash::XxHash; diff --git a/eden/scm/lib/treestate/src/store.rs b/eden/scm/lib/treestate/src/store.rs index 0e54c289dd..4e47a87a05 100644 --- a/eden/scm/lib/treestate/src/store.rs +++ b/eden/scm/lib/treestate/src/store.rs @@ -8,7 +8,7 @@ //! Trait defining an append-only storage system. use crate::errors::ErrorKind; -use failure::{bail, Fallible as Result}; +use anyhow::{bail, Result}; use std::borrow::Cow; #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)] diff --git a/eden/scm/lib/treestate/src/tree.rs b/eden/scm/lib/treestate/src/tree.rs index 65cca3f808..028e96c81a 100644 --- a/eden/scm/lib/treestate/src/tree.rs +++ b/eden/scm/lib/treestate/src/tree.rs @@ -12,7 +12,7 @@ use crate::serialization::Serializable; use crate::store::{BlockId, Store, StoreView}; use crate::vecmap::VecMap; use crate::vecstack::VecStack; -use failure::Fallible as Result; +use anyhow::Result; use std::cell::Cell; use std::collections::Bound; use std::io::{Cursor, Read, Write}; diff --git a/eden/scm/lib/treestate/src/treedirstate.rs b/eden/scm/lib/treestate/src/treedirstate.rs index d79375cb9a..177f506ae0 100644 --- a/eden/scm/lib/treestate/src/treedirstate.rs +++ b/eden/scm/lib/treestate/src/treedirstate.rs @@ -12,7 +12,7 @@ use crate::filestore::FileStore; use crate::serialization::Serializable; use crate::store::{BlockId, NullStore, Store, StoreView}; use crate::tree::{Key, KeyRef, Tree, VisitorResult}; -use failure::Fallible as Result; +use anyhow::Result; use std::io::Cursor; use std::path::Path; diff --git a/eden/scm/lib/treestate/src/treestate.rs b/eden/scm/lib/treestate/src/treestate.rs index 67de7e4d46..0288043d5d 100644 --- a/eden/scm/lib/treestate/src/treestate.rs +++ b/eden/scm/lib/treestate/src/treestate.rs @@ -10,7 +10,7 @@ use crate::filestore::FileStore; use crate::serialization::Serializable; use crate::store::{BlockId, Store, StoreView}; use crate::tree::{AggregatedState, Key, KeyRef, Node, Tree, VisitorResult}; -use failure::Fallible as Result; +use anyhow::Result; use std::io::Cursor; use std::ops::Deref; use std::path::Path; diff --git a/eden/scm/lib/types/Cargo.toml b/eden/scm/lib/types/Cargo.toml index ea1b9c054a..d6830cc9bb 100644 --- a/eden/scm/lib/types/Cargo.toml +++ b/eden/scm/lib/types/Cargo.toml @@ -8,9 +8,8 @@ default = [] for-tests = ["rand", "quickcheck", "lazy_static"] [dependencies] +anyhow = "1.0.20" bytes = { version = "0.4.11", features = ["serde"] } -failure = "0.1.3" -failure_derive = "0.1.3" lazy_static = { version = "1.4.0", optional = true } log = "0.4.6" quickcheck = { version = "0.9", optional = true } diff --git a/eden/scm/lib/types/src/dataentry.rs b/eden/scm/lib/types/src/dataentry.rs index 3e9fc3efb3..e05f2c1cc4 100644 --- a/eden/scm/lib/types/src/dataentry.rs +++ b/eden/scm/lib/types/src/dataentry.rs @@ -5,9 +5,9 @@ * GNU General Public License version 2. */ +use anyhow::{format_err, Error}; use bytes::Bytes; use crypto::{digest::Digest, sha1::Sha1}; -use failure::{format_err, Error}; use serde_derive::{Deserialize, Serialize}; use crate::{hgid::HgId, key::Key, parents::Parents}; diff --git a/eden/scm/lib/types/src/errors.rs b/eden/scm/lib/types/src/errors.rs index d33a60fedf..88d4e29742 100644 --- a/eden/scm/lib/types/src/errors.rs +++ b/eden/scm/lib/types/src/errors.rs @@ -5,35 +5,12 @@ * GNU General Public License version 2. */ -use failure::{Backtrace, Context, Error, Fail}; -use std::fmt; +use anyhow::Error; +use thiserror::Error; -#[derive(Debug)] -pub struct KeyError(Error); - -impl Fail for KeyError { - fn backtrace(&self) -> Option<&Backtrace> { - Some(self.0.backtrace()) - } - - fn cause(&self) -> Option<&dyn Fail> { - Some(self.0.as_ref()) - } - - fn context(self, context: D) -> Context - where - D: fmt::Display + Send + Sync + 'static, - Self: Sized, - { - self.0.context(context) - } -} - -impl fmt::Display for KeyError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "Key Error: {:?}", self.0) - } -} +#[derive(Debug, Error)] +#[error("Key Error: {0:?}")] +pub struct KeyError(#[source] Error); impl KeyError { pub fn new(err: Error) -> Self { diff --git a/eden/scm/lib/types/src/hgid.rs b/eden/scm/lib/types/src/hgid.rs index 17c9a6ea7b..9a87a8d3c4 100644 --- a/eden/scm/lib/types/src/hgid.rs +++ b/eden/scm/lib/types/src/hgid.rs @@ -10,7 +10,7 @@ use std::{ io::{self, Read, Write}, }; -use failure::Fallible as Result; +use anyhow::Result; use serde_derive::{Deserialize, Serialize}; use thiserror::Error; diff --git a/eden/scm/lib/util/Cargo.toml b/eden/scm/lib/util/Cargo.toml index b5950eeac9..3f356d7b86 100644 --- a/eden/scm/lib/util/Cargo.toml +++ b/eden/scm/lib/util/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" dirs = "2.0.2" -failure = "0.1.3" shellexpand = "1.0.0" tempfile = "3.0.4" diff --git a/eden/scm/lib/util/src/path.rs b/eden/scm/lib/util/src/path.rs index af9a43ccbd..589661e1ed 100644 --- a/eden/scm/lib/util/src/path.rs +++ b/eden/scm/lib/util/src/path.rs @@ -14,7 +14,7 @@ use std::fs::{self, remove_file as fs_remove_file}; use std::io::{self, ErrorKind}; use std::path::{Component, Path, PathBuf}; -use failure::Fallible as Result; +use anyhow::Result; #[cfg(not(unix))] use tempfile::Builder; diff --git a/eden/scm/lib/watchman_client/Cargo.toml b/eden/scm/lib/watchman_client/Cargo.toml index 2f0926ffb7..ec08de2209 100644 --- a/eden/scm/lib/watchman_client/Cargo.toml +++ b/eden/scm/lib/watchman_client/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2018" [dependencies] +anyhow = "1.0.20" log = "0.4.6" -failure = "0.1.3" serde = "1" serde_derive = "1" serde_json = "1" diff --git a/eden/scm/lib/watchman_client/src/protocol.rs b/eden/scm/lib/watchman_client/src/protocol.rs index 90c769022c..9ecca4985a 100644 --- a/eden/scm/lib/watchman_client/src/protocol.rs +++ b/eden/scm/lib/watchman_client/src/protocol.rs @@ -6,7 +6,7 @@ */ use crate::error::*; -use failure::Fallible as Result; +use anyhow::Result; use std::io::{BufRead, Read, Write}; pub trait Protocol { diff --git a/eden/scm/lib/watchman_client/src/transport.rs b/eden/scm/lib/watchman_client/src/transport.rs index 2cc4fd8019..ec86fd0b9d 100644 --- a/eden/scm/lib/watchman_client/src/transport.rs +++ b/eden/scm/lib/watchman_client/src/transport.rs @@ -8,7 +8,7 @@ use crate::error::*; use crate::protocol::{JsonProtocol, Protocol}; use crate::queries::*; -use failure::{bail, Fallible as Result}; +use anyhow::{bail, Result}; use std::io::BufReader; use std::marker::PhantomData; use std::path::Path; diff --git a/eden/scm/lib/workingcopy/Cargo.toml b/eden/scm/lib/workingcopy/Cargo.toml index c6f59bdfdf..6133c69121 100644 --- a/eden/scm/lib/workingcopy/Cargo.toml +++ b/eden/scm/lib/workingcopy/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2018" [dependencies] -failure = "0.1.3" +anyhow = "1.0.20" pathmatcher = { path = "../pathmatcher"} types = { path = "../types"} diff --git a/eden/scm/lib/workingcopy/src/lib.rs b/eden/scm/lib/workingcopy/src/lib.rs index 2c4473bbc7..4195e7e7aa 100644 --- a/eden/scm/lib/workingcopy/src/lib.rs +++ b/eden/scm/lib/workingcopy/src/lib.rs @@ -9,7 +9,7 @@ use std::fs::{self, DirEntry}; use std::io; use std::path::PathBuf; -use failure::Fallible as Result; +use anyhow::Result; use pathmatcher::{DirectoryMatch, Matcher}; use types::{RepoPath, RepoPathBuf};