diff --git a/eden/mononoke/apiserver/src/actor/query.rs b/eden/mononoke/apiserver/src/actor/query.rs index 8d47b7ff9e..deb2feae9d 100644 --- a/eden/mononoke/apiserver/src/actor/query.rs +++ b/eden/mononoke/apiserver/src/actor/query.rs @@ -18,7 +18,7 @@ use apiserver_thrift::types::{ MononokeGetTreeParams, MononokeIsAncestorParams, MononokeListDirectoryParams, MononokeListDirectoryUnodesParams, MononokeRevision, }; -use types::api::{DataRequest, HistoryRequest, TreeRequest}; +use edenapi_types::{DataRequest, HistoryRequest, TreeRequest}; #[derive(Debug, Clone, Serialize)] pub enum Revision { diff --git a/eden/mononoke/apiserver/src/actor/repo.rs b/eden/mononoke/apiserver/src/actor/repo.rs index dd2f150a9d..89626f9f9c 100644 --- a/eden/mononoke/apiserver/src/actor/repo.rs +++ b/eden/mononoke/apiserver/src/actor/repo.rs @@ -42,6 +42,10 @@ use time_ext::DurationExt; use tokio_compat::runtime::TaskExecutor; use unodes::RootUnodeManifestId; +use edenapi_types::{ + DataEntry, DataRequest, DataResponse, HistoryRequest, HistoryResponse, TreeRequest, + WireHistoryEntry, +}; use mercurial_types::{ blobs::{HgBlobChangeset, HgBlobEntry}, fetch_manifest_envelope, @@ -53,10 +57,7 @@ use metaconfig_types::{ }; use scuba_ext::{ScubaSampleBuilder, ScubaSampleBuilderExt}; use stats::prelude::*; -use types::{ - api::{DataRequest, DataResponse, HistoryRequest, HistoryResponse, TreeRequest}, - DataEntry, Key, RepoPathBuf, WireHistoryEntry, -}; +use types::{Key, RepoPathBuf}; use warm_bookmarks_cache::WarmBookmarksCache; use mononoke_types::{ChangesetId, FileUnodeId, MPath, ManifestUnodeId}; diff --git a/eden/mononoke/apiserver/src/actor/response.rs b/eden/mononoke/apiserver/src/actor/response.rs index 3c9376b5b6..5c2ee2bfb2 100644 --- a/eden/mononoke/apiserver/src/actor/response.rs +++ b/eden/mononoke/apiserver/src/actor/response.rs @@ -16,10 +16,8 @@ use serde::{Deserialize, Serialize}; use tokio::{self, sync::mpsc}; use tokio_compat::runtime::TaskExecutor; -use types::{ - api::{DataResponse, HistoryResponse}, - DataEntry, RepoPathBuf, WireHistoryEntry, -}; +use edenapi_types::{DataEntry, DataResponse, HistoryResponse, WireHistoryEntry}; +use types::RepoPathBuf; use super::file_stream::FileStream; use super::model::{Changeset, Entry, EntryLight, EntryWithSizeAndContentHash}; diff --git a/eden/mononoke/edenapi_server/Cargo.toml b/eden/mononoke/edenapi_server/Cargo.toml index ce506e4f84..f32e27cad7 100644 --- a/eden/mononoke/edenapi_server/Cargo.toml +++ b/eden/mononoke/edenapi_server/Cargo.toml @@ -10,6 +10,7 @@ include = ["src/**/*.rs"] blobrepo_factory = { path = "../blobrepo/factory" } cmdlib = { path = "../cmdlib" } context = { path = "../server/context" } +edenapi_types = { path = "../../scm/lib/edenapi/types" } gotham_ext = { path = "../gotham_ext" } mercurial_types = { path = "../mercurial/types" } mononoke_api = { path = "../mononoke_api" } diff --git a/eden/mononoke/edenapi_server/src/handlers/data.rs b/eden/mononoke/edenapi_server/src/handlers/data.rs index eba52b58c0..0be2e4f7b4 100644 --- a/eden/mononoke/edenapi_server/src/handlers/data.rs +++ b/eden/mononoke/edenapi_server/src/handlers/data.rs @@ -12,13 +12,11 @@ use gotham::state::{FromState, State}; use gotham_derive::{StateData, StaticResponseExtender}; use serde::Deserialize; +use edenapi_types::{DataEntry, DataRequest, DataResponse}; use gotham_ext::{error::HttpError, response::BytesBody}; use mercurial_types::HgNodeHash; use mononoke_api::hg::{HgDataContext, HgDataId, HgRepoContext}; -use types::{ - api::{DataRequest, DataResponse}, - DataEntry, Key, -}; +use types::Key; use crate::context::ServerContext; use crate::middleware::RequestContext; diff --git a/eden/mononoke/edenapi_server/src/handlers/history.rs b/eden/mononoke/edenapi_server/src/handlers/history.rs index c343c62d43..b6e45245b6 100644 --- a/eden/mononoke/edenapi_server/src/handlers/history.rs +++ b/eden/mononoke/edenapi_server/src/handlers/history.rs @@ -17,14 +17,12 @@ use gotham::state::{FromState, State}; use gotham_derive::{StateData, StaticResponseExtender}; use serde::Deserialize; +use edenapi_types::{HistoryRequest, HistoryResponse, WireHistoryEntry}; use gotham_ext::{error::HttpError, response::BytesBody}; use mercurial_types::{HgFileNodeId, HgNodeHash}; use mononoke_api::hg::HgRepoContext; use mononoke_types::MPath; -use types::{ - api::{HistoryRequest, HistoryResponse}, - Key, WireHistoryEntry, -}; +use types::Key; use crate::context::ServerContext; use crate::middleware::RequestContext; diff --git a/eden/mononoke/hgproto/Cargo.toml b/eden/mononoke/hgproto/Cargo.toml index 549261b0a2..a0a36bea55 100644 --- a/eden/mononoke/hgproto/Cargo.toml +++ b/eden/mononoke/hgproto/Cargo.toml @@ -7,10 +7,10 @@ license = "GPLv2+" include = ["src/**/*.rs"] [dependencies] +edenapi_types = { path = "../../scm/lib/edenapi/types" } mercurial_bundles = { path = "../mercurial/bundles" } mercurial_types = { path = "../mercurial/types" } mononoke_types = { path = "../mononoke_types" } -types = { path = "../../scm/lib/types" } failure_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" } futures_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" } anyhow = "1.0" diff --git a/eden/mononoke/hgproto/src/lib.rs b/eden/mononoke/hgproto/src/lib.rs index 365faec995..b19c33f754 100644 --- a/eden/mononoke/hgproto/src/lib.rs +++ b/eden/mononoke/hgproto/src/lib.rs @@ -15,13 +15,13 @@ use anyhow::Error; use bytes_old::Bytes; +use edenapi_types::TreeRequest; use mercurial_types::{HgChangesetId, HgManifestId}; use mononoke_types::MPath; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::convert::TryFrom; use std::fmt::{self, Debug}; use std::sync::Mutex; -use types::api::TreeRequest; pub mod batch; mod commands; diff --git a/eden/mononoke/mercurial/types/Cargo.toml b/eden/mononoke/mercurial/types/Cargo.toml index 14a50e5102..1961664047 100644 --- a/eden/mononoke/mercurial/types/Cargo.toml +++ b/eden/mononoke/mercurial/types/Cargo.toml @@ -9,6 +9,7 @@ include = ["src/**/*.rs"] [dependencies] blobstore = { path = "../../blobstore" } context = { path = "../../server/context" } +edenapi_types = { path = "../../../scm/lib/edenapi/types" } filestore = { path = "../../filestore" } manifest = { path = "../../manifest" } mercurial-thrift = { path = "if" } diff --git a/eden/mononoke/mercurial/types/src/remotefilelog.rs b/eden/mononoke/mercurial/types/src/remotefilelog.rs index 0a75dc1b1f..7e2f39edc7 100644 --- a/eden/mononoke/mercurial/types/src/remotefilelog.rs +++ b/eden/mononoke/mercurial/types/src/remotefilelog.rs @@ -6,9 +6,10 @@ */ use anyhow::{Error, Result}; +use edenapi_types::WireHistoryEntry; use mononoke_types::MPath; use std::convert::TryFrom; -use types::{Parents, RepoPathBuf as ClientRepoPathBuf, WireHistoryEntry}; +use types::{Parents, RepoPathBuf as ClientRepoPathBuf}; use crate::blobnode::HgParents; use crate::nodehash::{HgChangesetId, HgFileNodeId, NULL_HASH}; diff --git a/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs b/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs index 877901ed3d..f072ab1a6a 100644 --- a/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs +++ b/eden/scm/lib/asyncrevisionstore/src/asyncmutablehistorystore.rs @@ -13,8 +13,9 @@ use tokio::prelude::*; use tokio_threadpool::blocking; use cloned::cloned; +use edenapi_types::HistoryEntry; use revisionstore::HgIdMutableHistoryStore; -use types::{HistoryEntry, Key, NodeInfo}; +use types::{Key, NodeInfo}; pub struct AsyncHgIdMutableHistoryStore { inner: Option, diff --git a/eden/scm/lib/edenapi/Cargo.toml b/eden/scm/lib/edenapi/Cargo.toml index fba64b879b..ba4ae05d71 100644 --- a/eden/scm/lib/edenapi/Cargo.toml +++ b/eden/scm/lib/edenapi/Cargo.toml @@ -20,6 +20,7 @@ serde = "1.0.89" serde_cbor = "0.11" thiserror = "1.0.5" tracing = "0" +edenapi_types = { path = "types" } types = { path = "../types" } url = "2.1.0" diff --git a/eden/scm/lib/edenapi/src/api.rs b/eden/scm/lib/edenapi/src/api.rs index 2651180931..a56eaa1cc3 100644 --- a/eden/scm/lib/edenapi/src/api.rs +++ b/eden/scm/lib/edenapi/src/api.rs @@ -7,7 +7,8 @@ use bytes::Bytes; -use types::{HgId, HistoryEntry, Key, RepoPathBuf}; +use edenapi_types::HistoryEntry; +use types::{HgId, Key, RepoPathBuf}; use crate::errors::ApiResult; use crate::progress::ProgressFn; diff --git a/eden/scm/lib/edenapi/src/curl.rs b/eden/scm/lib/edenapi/src/curl.rs index 00019285de..1be64b5717 100644 --- a/eden/scm/lib/edenapi/src/curl.rs +++ b/eden/scm/lib/edenapi/src/curl.rs @@ -20,12 +20,11 @@ use serde::{de::DeserializeOwned, Serialize}; use serde_cbor::Deserializer; use url::Url; -use driver::MultiDriver; -use handler::Collector; -use types::{ - api::{DataRequest, DataResponse, HistoryRequest, HistoryResponse, TreeRequest}, - DataEntry, HgId, HistoryEntry, Key, RepoPathBuf, Validity, WireHistoryEntry, +use edenapi_types::{ + DataEntry, DataRequest, DataResponse, HistoryEntry, HistoryRequest, HistoryResponse, + TreeRequest, Validity, WireHistoryEntry, }; +use types::{HgId, Key, RepoPathBuf}; use crate::api::EdenApi; use crate::config::{ClientCreds, Config}; @@ -36,6 +35,9 @@ use crate::stats::DownloadStats; mod driver; mod handler; +use self::driver::MultiDriver; +use self::handler::Collector; + mod paths { pub const HEALTH_CHECK: &str = "/health_check"; pub const HOSTNAME: &str = "/hostname"; diff --git a/eden/scm/lib/edenapi/tools/make_req/Cargo.toml b/eden/scm/lib/edenapi/tools/make_req/Cargo.toml index 7a3b548163..8d56144672 100644 --- a/eden/scm/lib/edenapi/tools/make_req/Cargo.toml +++ b/eden/scm/lib/edenapi/tools/make_req/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" [dependencies] anyhow = "1.0" +edenapi_types = { path = "../../types" } serde_json = "1.0" serde_cbor = "0.11" structopt = "0.3" diff --git a/eden/scm/lib/edenapi/tools/make_req/src/main.rs b/eden/scm/lib/edenapi/tools/make_req/src/main.rs index 5c4eb30401..8770b1e200 100644 --- a/eden/scm/lib/edenapi/tools/make_req/src/main.rs +++ b/eden/scm/lib/edenapi/tools/make_req/src/main.rs @@ -24,10 +24,8 @@ use anyhow::{anyhow, ensure, Result}; use serde_json::Value; use structopt::StructOpt; -use types::{ - api::{DataRequest, HistoryRequest, TreeRequest}, - HgId, Key, RepoPathBuf, -}; +use edenapi_types::{DataRequest, HistoryRequest, TreeRequest}; +use types::{HgId, Key, RepoPathBuf}; #[derive(Debug, StructOpt)] #[structopt(name = "make_req", about = "Make EdenAPI CBOR request payloads")] diff --git a/eden/scm/lib/edenapi/tools/read_res/Cargo.toml b/eden/scm/lib/edenapi/tools/read_res/Cargo.toml index 193f7ed2e4..046cba967d 100644 --- a/eden/scm/lib/edenapi/tools/read_res/Cargo.toml +++ b/eden/scm/lib/edenapi/tools/read_res/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" [dependencies] anyhow = "1.0" +edenapi_types = { path = "../../types" } serde = "1.0" serde_cbor = "0.11" structopt = "0.3" diff --git a/eden/scm/lib/edenapi/tools/read_res/src/main.rs b/eden/scm/lib/edenapi/tools/read_res/src/main.rs index eadd2e16b9..a79b593fe9 100644 --- a/eden/scm/lib/edenapi/tools/read_res/src/main.rs +++ b/eden/scm/lib/edenapi/tools/read_res/src/main.rs @@ -21,10 +21,8 @@ use anyhow::{anyhow, Result}; use serde::de::DeserializeOwned; use structopt::StructOpt; -use types::{ - api::{DataResponse, HistoryResponse}, - Key, Parents, RepoPathBuf, Validity, WireHistoryEntry, -}; +use edenapi_types::{DataResponse, HistoryResponse, Validity, WireHistoryEntry}; +use types::{Key, Parents, RepoPathBuf}; #[derive(Debug, StructOpt)] #[structopt(name = "read_res", about = "Read the content of EdenAPI responses")] diff --git a/eden/scm/lib/edenapi/types/Cargo.toml b/eden/scm/lib/edenapi/types/Cargo.toml new file mode 100644 index 0000000000..8d5662e73a --- /dev/null +++ b/eden/scm/lib/edenapi/types/Cargo.toml @@ -0,0 +1,20 @@ +# @generated by autocargo from //eden/scm/lib/edenapi/types:edenapi_types +[package] +name = "edenapi_types" +edition = "2018" +version = "0.1.0" +include = ["src/**/*.rs"] + +[features] +default = [] +for-tests = [] + +[dependencies] +types = { path = "../../types" } +anyhow = "1.0" +bytes = { version = "0.5", features = ["serde"] } +quickcheck = "0.9" +rand = { version = "0.7", features = ["small_rng"] } +serde = { version = "1.0", features = ["derive", "rc"] } +serde_derive = "1.0" +sha-1 = "0.8" diff --git a/eden/scm/lib/types/src/api.rs b/eden/scm/lib/edenapi/types/src/api.rs similarity index 95% rename from eden/scm/lib/types/src/api.rs rename to eden/scm/lib/edenapi/types/src/api.rs index babd1c677b..bf00e5253c 100644 --- a/eden/scm/lib/types/src/api.rs +++ b/eden/scm/lib/edenapi/types/src/api.rs @@ -9,12 +9,11 @@ use serde_derive::{Deserialize, Serialize}; +use types::{hgid::HgId, key::Key, path::RepoPathBuf}; + use crate::{ dataentry::DataEntry, - hgid::HgId, historyentry::{HistoryEntry, WireHistoryEntry}, - key::Key, - path::RepoPathBuf, }; #[derive(Debug, Serialize, Deserialize)] @@ -115,7 +114,9 @@ impl TreeRequest { mod tests { use super::*; - use crate::{ + use bytes::Bytes; + + use types::{ hgid::mocks::{AS, BS, CS, ONES, THREES, TWOS}, key::mocks::{BAR_KEY, BAZ_KEY, FOO_KEY}, nodeinfo::NodeInfo, @@ -123,6 +124,10 @@ mod tests { testutil::*, }; + fn data_entry(key: Key, data: impl AsRef<[u8]>) -> DataEntry { + DataEntry::new(key, Bytes::copy_from_slice(data.as_ref()), Parents::None) + } + #[test] fn data_iter() { let data = vec![ diff --git a/eden/scm/lib/types/src/dataentry.rs b/eden/scm/lib/edenapi/types/src/dataentry.rs similarity index 98% rename from eden/scm/lib/types/src/dataentry.rs rename to eden/scm/lib/edenapi/types/src/dataentry.rs index 6ba68ba75f..e3fb8af201 100644 --- a/eden/scm/lib/types/src/dataentry.rs +++ b/eden/scm/lib/edenapi/types/src/dataentry.rs @@ -10,7 +10,7 @@ use bytes::Bytes; use serde_derive::{Deserialize, Serialize}; use sha1::{Digest, Sha1}; -use crate::{hgid::HgId, key::Key, parents::Parents}; +use types::{hgid::HgId, key::Key, parents::Parents}; /// Tombstone string to replace the content of blacklisted files with /// TODO(T48685378): Handle redacted content in a less hacky way diff --git a/eden/scm/lib/types/src/historyentry.rs b/eden/scm/lib/edenapi/types/src/historyentry.rs similarity index 98% rename from eden/scm/lib/types/src/historyentry.rs rename to eden/scm/lib/edenapi/types/src/historyentry.rs index 5ad6f23df4..fc6de96344 100644 --- a/eden/scm/lib/types/src/historyentry.rs +++ b/eden/scm/lib/edenapi/types/src/historyentry.rs @@ -7,7 +7,7 @@ use serde_derive::{Deserialize, Serialize}; -use crate::{hgid::HgId, key::Key, nodeinfo::NodeInfo, parents::Parents, path::RepoPathBuf}; +use types::{hgid::HgId, key::Key, nodeinfo::NodeInfo, parents::Parents, path::RepoPathBuf}; /// Structure containing the fields corresponding to a HistoryPack's /// in-memory representation of a history entry. Useful for adding diff --git a/eden/scm/lib/edenapi/types/src/lib.rs b/eden/scm/lib/edenapi/types/src/lib.rs new file mode 100644 index 0000000000..0decf04ac0 --- /dev/null +++ b/eden/scm/lib/edenapi/types/src/lib.rs @@ -0,0 +1,16 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This software may be used and distributed according to the terms of the + * GNU General Public License version 2. + */ + +#![deny(warnings)] + +pub mod api; +pub mod dataentry; +pub mod historyentry; + +pub use crate::api::{DataRequest, DataResponse, HistoryRequest, HistoryResponse, TreeRequest}; +pub use crate::dataentry::{DataEntry, Validity}; +pub use crate::historyentry::{HistoryEntry, WireHistoryEntry}; diff --git a/eden/scm/lib/revisionstore/Cargo.toml b/eden/scm/lib/revisionstore/Cargo.toml index 5e5753b4d9..8696bcf80f 100644 --- a/eden/scm/lib/revisionstore/Cargo.toml +++ b/eden/scm/lib/revisionstore/Cargo.toml @@ -15,6 +15,7 @@ bytes = { version = "0.5", features = ["serde"] } byteorder = "1.2.7" configparser = { path = "../configparser" } edenapi = { path = "../edenapi" } +edenapi_types = { path = "../edenapi/types" } futures = "0.3" hex = "0.4" indexedlog = { path = "../indexedlog" } diff --git a/eden/scm/lib/revisionstore/src/historystore.rs b/eden/scm/lib/revisionstore/src/historystore.rs index 3ac02616fc..4f08bae569 100644 --- a/eden/scm/lib/revisionstore/src/historystore.rs +++ b/eden/scm/lib/revisionstore/src/historystore.rs @@ -9,7 +9,8 @@ use std::{ops::Deref, path::PathBuf}; use anyhow::Result; -use types::{HistoryEntry, Key, NodeInfo}; +use edenapi_types::HistoryEntry; +use types::{Key, NodeInfo}; use crate::{localstore::LocalStore, types::StoreKey}; diff --git a/eden/scm/lib/revisionstore/src/testutil.rs b/eden/scm/lib/revisionstore/src/testutil.rs index 8eb2711320..f9a2fc09fc 100644 --- a/eden/scm/lib/revisionstore/src/testutil.rs +++ b/eden/scm/lib/revisionstore/src/testutil.rs @@ -12,7 +12,8 @@ use bytes::Bytes; use configparser::config::ConfigSet; use edenapi::{ApiResult, DownloadStats, EdenApi, ProgressFn}; -use types::{HgId, HistoryEntry, Key, NodeInfo, RepoPathBuf}; +use edenapi_types::HistoryEntry; +use types::{HgId, Key, NodeInfo, RepoPathBuf}; use crate::{ datastore::{Delta, HgIdDataStore, HgIdMutableDeltaStore, Metadata, RemoteDataStore}, diff --git a/eden/scm/lib/types/Cargo.toml b/eden/scm/lib/types/Cargo.toml index c5f22adfbd..359cafcad4 100644 --- a/eden/scm/lib/types/Cargo.toml +++ b/eden/scm/lib/types/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" include = ["src/**/*.rs"] [features] -default = [] +default = ["for-tests"] for-tests = ["rand", "quickcheck", "lazy_static"] [dependencies] diff --git a/eden/scm/lib/types/src/lib.rs b/eden/scm/lib/types/src/lib.rs index e392306b93..d572111452 100644 --- a/eden/scm/lib/types/src/lib.rs +++ b/eden/scm/lib/types/src/lib.rs @@ -7,11 +7,8 @@ //! Common types used by sibling crates -pub mod api; -pub mod dataentry; pub mod errors; pub mod hgid; -pub mod historyentry; pub mod key; pub mod mutation; pub mod node; @@ -20,9 +17,7 @@ pub mod parents; pub mod path; pub mod sha; -pub use crate::dataentry::{DataEntry, Validity}; pub use crate::hgid::HgId; -pub use crate::historyentry::{HistoryEntry, WireHistoryEntry}; pub use crate::key::Key; pub use crate::node::Node; pub use crate::nodeinfo::NodeInfo; diff --git a/eden/scm/lib/types/src/testutil.rs b/eden/scm/lib/types/src/testutil.rs index a3f3f0facd..a4d39bd51f 100644 --- a/eden/scm/lib/types/src/testutil.rs +++ b/eden/scm/lib/types/src/testutil.rs @@ -7,15 +7,12 @@ use std::{collections::HashSet, str::FromStr}; -use bytes::Bytes; use quickcheck::{Arbitrary, Gen}; use rand::Rng; use crate::{ - dataentry::DataEntry, hgid::HgId, key::Key, - parents::Parents, path::{PathComponent, PathComponentBuf, RepoPath, RepoPathBuf}, }; @@ -65,10 +62,6 @@ pub fn null_key(path: &str) -> Key { Key::new(repo_path_buf(path), HgId::null_id().clone()) } -pub fn data_entry(key: Key, data: impl AsRef<[u8]>) -> DataEntry { - DataEntry::new(key, Bytes::copy_from_slice(data.as_ref()), Parents::None) -} - pub fn generate_repo_paths(count: usize, qc_gen: &mut G) -> Vec { struct Generator<'a, G: Gen> { current_path: RepoPathBuf,