Apply rustfmt to all rust files

Reviewed By: jsgf

Differential Revision: D14578283

fbshipit-source-id: 9b4a7b1fd445fd033b64c6af04ee52b27eefb616
This commit is contained in:
Andres Suarez 2019-07-10 19:30:31 -07:00 committed by Facebook Github Bot
parent df39ac67d6
commit 9a90a484f8
19 changed files with 80 additions and 59 deletions

View File

@ -22,7 +22,7 @@ pub struct MeteredRead<R: Read> {
impl<R: Read> MeteredRead<R> {
pub fn new(inner: R) -> Self {
MeteredRead {
inner: inner,
inner,
total_thru: 0,
}
}
@ -98,7 +98,7 @@ pub struct MeteredWrite<W: Write> {
impl<W: Write> MeteredWrite<W> {
pub fn new(inner: W) -> Self {
MeteredWrite {
inner: inner,
inner,
total_thru: 0,
}
}

View File

@ -8,8 +8,8 @@ use super::*;
use futures::executor::{spawn, Notify, NotifyHandle, Spawn};
use futures_ext::FutureExt;
use std::cell::RefCell;
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Mutex;
use std::thread;
use std::time::Duration;
use std::usize;

View File

@ -89,9 +89,7 @@ where
{
#[inline]
fn get_weight(&self) -> usize {
let inner_size = self.as_ref()
.map(Weight::get_weight)
.unwrap_or(0);
let inner_size = self.as_ref().map(Weight::get_weight).unwrap_or(0);
mem::size_of::<Self>() - mem::size_of::<A>() + inner_size
}

View File

@ -291,7 +291,12 @@ fn new_production<T: SqlFactory>(
Ok(BlobRepo::new_with_changeset_fetcher_factory(
logger,
bookmarks,
make_censored_prefixed_blobstore(blobstore, censored_blobs, repoid.prefix(), scuba_censored_table),
make_censored_prefixed_blobstore(
blobstore,
censored_blobs,
repoid.prefix(),
scuba_censored_table,
),
Arc::new(filenodes),
changesets,
Arc::new(bonsai_hg_mapping),

View File

@ -6,5 +6,6 @@
mod manifest;
pub use self::manifest::{apply_diff, BonsaiMFVerify, BonsaiMFVerifyDifference,
BonsaiMFVerifyResult};
pub use self::manifest::{
apply_diff, BonsaiMFVerify, BonsaiMFVerifyDifference, BonsaiMFVerifyResult,
};

View File

@ -101,12 +101,10 @@ mod test {
.expect("initial put should work");
let outer = MemWritesBlobstore::new(inner.clone());
assert!(
outer
.is_present(ctx.clone(), foo_key.clone())
.wait()
.expect("is_present to inner should work")
);
assert!(outer
.is_present(ctx.clone(), foo_key.clone())
.wait()
.expect("is_present to inner should work"));
assert_eq!(
outer

View File

@ -107,16 +107,13 @@ mod test {
);
// Test that is_present works for both the prefixed and unprefixed stores.
assert!(
prefixed
.is_present(ctx.clone(), unprefixed_key.clone())
.wait()
.expect("is_present should succeed")
);
assert!(
base.is_present(ctx.clone(), prefixed_key.clone())
.wait()
.expect("is_present should succeed")
);
assert!(prefixed
.is_present(ctx.clone(), unprefixed_key.clone())
.wait()
.expect("is_present should succeed"));
assert!(base
.is_present(ctx.clone(), prefixed_key.clone())
.wait()
.expect("is_present should succeed"));
}
}

View File

@ -39,8 +39,10 @@ impl Rocksblob {
pub fn open_with_options<P: AsRef<Path>>(path: P, opts: rocksdb::Options) -> Result<Self> {
let opts = opts.set_compression(rocksdb::Compression::Zstd);
let opts = opts.set_block_based_table_factory(&rocksdb::BlockBasedTableOptions::new()
.set_filter_policy(rocksdb::FilterPolicy::create_bloom(10)));
let opts = opts.set_block_based_table_factory(
&rocksdb::BlockBasedTableOptions::new()
.set_filter_policy(rocksdb::FilterPolicy::create_bloom(10)),
);
Ok(Rocksblob {
db: Db::open(path, opts)?,

View File

@ -139,7 +139,7 @@ macro_rules! blobstore_test_impl {
boxable($new_cb(state.clone()));
}
}
}
};
}
blobstore_test_impl! {

View File

@ -16,7 +16,7 @@ use std::str::FromStr;
use clap::{App, SubCommand};
use mercurial::{RevlogChangeset, revlog::Revlog};
use mercurial::{revlog::Revlog, RevlogChangeset};
use mercurial_types::HgNodeHash;
fn setup_app<'a, 'b>() -> App<'a, 'b> {

View File

@ -25,7 +25,8 @@ pub mod prelude {
}
pub use failure::{
_core, bail, err_msg, AsFail, Backtrace, Causes, Compat, Context, Error, Fail, ResultExt, SyncFailure,
_core, bail, err_msg, AsFail, Backtrace, Causes, Compat, Context, Error, Fail, ResultExt,
SyncFailure,
};
pub use failure_derive::*;

View File

@ -273,7 +273,7 @@ impl<H: HgCommands + Send + 'static> HgCommandHandler<H> {
.boxify(),
instream,
)
},
}
SingleRequest::GetpackV2 => {
let (reqs, instream) =
decode_getfiles_arg_stream(instream, || Getpackv1ArgDecoder::new());

View File

@ -356,9 +356,13 @@ impl LuaHook {
if acc {
Ok(HookExecution::Accepted)
} else {
let desc = t.get::<String, _, _>(2).ok_or(Error::from(ErrorKind::HookRuntimeError("No description".to_string())))?;
let desc = t.get::<String, _, _>(2).ok_or(Error::from(
ErrorKind::HookRuntimeError("No description".to_string()),
))?;
let long_desc = t.get::<String, _, _>(3);
Ok(HookExecution::Rejected(HookRejectionInfo::new_opt(desc, long_desc)))
Ok(HookExecution::Rejected(HookRejectionInfo::new_opt(
desc, long_desc,
)))
}
})
})

View File

@ -45,12 +45,14 @@ impl Fail for BlobRepoErrorCause {
#[derive(Debug, Fail)]
pub enum ErrorKind {
#[fail(display = "{} not found in repo", _0)] NodeNotFound(String),
#[fail(display = "{} not found in repo", _0)]
NodeNotFound(String),
#[fail(display = "failed to fetch node generation")]
GenerationFetchFailed(#[cause] BlobRepoErrorCause),
#[fail(display = "failed to fetch parent nodes")]
ParentsFetchFailed(#[cause] BlobRepoErrorCause),
#[fail(display = "checking existence failed")]
CheckExistenceFailed(String, #[cause] BlobRepoErrorCause),
#[fail(display = "Unknown field in thrift encoding")] UknownSkiplistThriftEncoding,
#[fail(display = "Unknown field in thrift encoding")]
UknownSkiplistThriftEncoding,
}

View File

@ -357,7 +357,6 @@ mod test {
use futures::Future;
use mononoke_types::Generation;
#[test]
fn test_helpers() {
async_unit::tokio_unit_test(move || {

View File

@ -9,7 +9,10 @@
extern crate futures;
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use futures::{Async, Future, Poll};
@ -83,7 +86,8 @@ impl ReadyHandle {
where
F: Future,
{
let inner = self.inner
let inner = self
.inner
.take()
.expect("inner should only be None in the Drop impl");
ReadyFuture {

View File

@ -97,18 +97,25 @@ pub fn create_repo_listeners(
let mut ready = ready_state::ReadyStateBuilder::new();
(
repo_handlers(repos, myrouter_port, caching, common_config.scuba_censored_table.clone(), &root_log, &mut ready)
.and_then(move |handlers| {
connection_acceptor(
common_config,
sockname,
root_log,
handlers,
tls_acceptor,
terminate_process,
)
})
.boxify(),
repo_handlers(
repos,
myrouter_port,
caching,
common_config.scuba_censored_table.clone(),
&root_log,
&mut ready,
)
.and_then(move |handlers| {
connection_acceptor(
common_config,
sockname,
root_log,
handlers,
tls_acceptor,
terminate_process,
)
})
.boxify(),
ready.freeze(),
)
}

View File

@ -48,7 +48,8 @@ pub(crate) fn start_thrift_service<'a>(
port,
0, // Disables separate status http server
Box::new(MononokeService { ready }),
).expect("failure while running thrift service framework")
)
.expect("failure while running thrift service framework")
})
.map_err(Error::from)
})

View File

@ -18,8 +18,9 @@ use blobrepo::{save_bonsai_changesets, BlobRepo};
use bytes::Bytes;
use context::CoreContext;
use futures::future::Future;
use mononoke_types::{BonsaiChangesetMut, ChangesetId, DateTime, FileChange, FileContents,
FileType, MPath};
use mononoke_types::{
BonsaiChangesetMut, ChangesetId, DateTime, FileChange, FileContents, FileType, MPath,
};
use std::collections::BTreeMap;
@ -28,7 +29,7 @@ pub fn store_files(
files: BTreeMap<&str, Option<&str>>,
repo: BlobRepo,
) -> BTreeMap<MPath, Option<FileChange>> {
let mut res = btreemap!{};
let mut res = btreemap! {};
for (path, content) in files {
let path = MPath::new(path).unwrap();
@ -72,16 +73,17 @@ pub fn create_commit(
file_changes: BTreeMap<MPath, Option<FileChange>>,
) -> ChangesetId {
let bcs = BonsaiChangesetMut {
parents: parents,
parents,
author: "author".to_string(),
author_date: DateTime::from_timestamp(0, 0).unwrap(),
committer: None,
committer_date: None,
message: "message".to_string(),
extra: btreemap!{},
extra: btreemap! {},
file_changes,
}.freeze()
.unwrap();
}
.freeze()
.unwrap();
let bcs_id = bcs.get_changeset_id();
save_bonsai_changesets(vec![bcs], ctx, repo.clone())