dag: add CloneData

Summary: This is the object that will be used to bootstrap a Dag after a clone.

Reviewed By: quark-zju

Differential Revision: D24808328

fbshipit-source-id: 2c7e97c027c84a11e8716f2e288500474990169b
This commit is contained in:
Stefan Filip 2020-11-10 16:45:19 -08:00 committed by Facebook GitHub Bot
parent 40333a545f
commit bff5a9ba29
3 changed files with 49 additions and 2 deletions

View File

@ -3,6 +3,10 @@ name = "dag"
version = "0.1.0"
edition = "2018"
[features]
default = ["for-tests"]
for-tests = ["quickcheck"]
[dependencies]
drawdag = { path = "../drawdag" }
indexedlog = { path = "../indexedlog" }
@ -17,6 +21,7 @@ indexmap = "1.0.1"
itertools = "0.8"
once_cell = "1"
parking_lot = "0.10"
quickcheck = { version = "0.9", optional = true }
serde = { version = "1", features = ["derive"] }
tempfile = "3.0.7"
thiserror = "1"
@ -27,7 +32,6 @@ bindag = { path = "bindag" }
mincode = { path = "../mincode" }
minibench = { path = "../minibench" }
once_cell = "1"
quickcheck = "0.9"
unicode-width = "0.1.7"
[[bench]]

View File

@ -0,0 +1,41 @@
/*
* 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.
*/
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::segment::PreparedFlatSegments;
use crate::Id;
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Serialize, Deserialize)]
pub struct CloneData<Name> {
pub head_id: Id,
pub flat_segments: PreparedFlatSegments,
pub idmap: HashMap<Id, Name>,
}
#[cfg(any(test, feature = "for-tests"))]
use quickcheck::Arbitrary;
#[cfg(any(test, feature = "for-tests"))]
impl<Name> Arbitrary for CloneData<Name>
where
Name: Arbitrary,
{
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
let flat_segments = PreparedFlatSegments {
segments: Vec::arbitrary(g),
};
CloneData {
head_id: Id::arbitrary(g),
flat_segments,
idmap: HashMap::arbitrary(g),
}
}
}

View File

@ -13,6 +13,7 @@
//! Building blocks for the commit graph used by source control.
mod bsearch;
pub mod clone;
mod default_impl;
mod delegate;
pub mod errors;
@ -27,10 +28,11 @@ pub mod nameset;
pub mod ops;
pub mod protocol;
pub mod render;
mod segment;
pub mod segment;
pub mod spanset;
pub mod utils;
pub use clone::CloneData;
pub use id::{Group, Id, VertexName};
pub use iddag::IdDag;
pub use idmap::IdMap;