mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
dag: add DagImportCloneData::import_clone_data
Summary: This method reconstructs a dag from clone data. At the moment we only have a clone data construction method in Mononoke. It's the Dags job to construct and import the clone_data. We'll consolidate that at a later time. Reviewed By: quark-zju Differential Revision: D24954823 fbshipit-source-id: fe92179ec80f71234fc8f1cf7709f5104aabb4fb
This commit is contained in:
parent
042dcbb3a8
commit
8327c54db1
@ -9,6 +9,7 @@
|
|||||||
//!
|
//!
|
||||||
//! Combination of IdMap and IdDag.
|
//! Combination of IdMap and IdDag.
|
||||||
|
|
||||||
|
use crate::clone::CloneData;
|
||||||
use crate::delegate;
|
use crate::delegate;
|
||||||
use crate::errors::bug;
|
use crate::errors::bug;
|
||||||
use crate::errors::programming;
|
use crate::errors::programming;
|
||||||
@ -24,6 +25,7 @@ use crate::nameset::hints::Hints;
|
|||||||
use crate::nameset::NameSet;
|
use crate::nameset::NameSet;
|
||||||
use crate::ops::DagAddHeads;
|
use crate::ops::DagAddHeads;
|
||||||
use crate::ops::DagAlgorithm;
|
use crate::ops::DagAlgorithm;
|
||||||
|
use crate::ops::DagImportCloneData;
|
||||||
use crate::ops::DagPersistent;
|
use crate::ops::DagPersistent;
|
||||||
use crate::ops::IdConvert;
|
use crate::ops::IdConvert;
|
||||||
use crate::ops::IdMapSnapshot;
|
use crate::ops::IdMapSnapshot;
|
||||||
@ -227,6 +229,21 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<IS, M, P, S> DagImportCloneData for AbstractNameDag<IdDag<IS>, M, P, S>
|
||||||
|
where
|
||||||
|
IS: IdDagStore,
|
||||||
|
M: IdMapAssignHead,
|
||||||
|
{
|
||||||
|
fn import_clone_data(&mut self, clone_data: CloneData<VertexName>) -> Result<()> {
|
||||||
|
for (id, name) in clone_data.idmap {
|
||||||
|
self.map.insert(id, name.as_ref())?;
|
||||||
|
}
|
||||||
|
self.dag
|
||||||
|
.build_segments_volatile_from_prepared_flat_segments(&clone_data.flat_segments)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<IS, M, P, S> AbstractNameDag<IdDag<IS>, M, P, S>
|
impl<IS, M, P, S> AbstractNameDag<IdDag<IS>, M, P, S>
|
||||||
where
|
where
|
||||||
IS: IdDagStore,
|
IS: IdDagStore,
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
//! DAG and Id operations (mostly traits)
|
//! DAG and Id operations (mostly traits)
|
||||||
|
|
||||||
|
use crate::clone::CloneData;
|
||||||
use crate::default_impl;
|
use crate::default_impl;
|
||||||
use crate::id::Group;
|
use crate::id::Group;
|
||||||
use crate::id::Id;
|
use crate::id::Id;
|
||||||
@ -169,6 +170,12 @@ pub trait DagAddHeads {
|
|||||||
F: Fn(VertexName) -> Result<Vec<VertexName>>;
|
F: Fn(VertexName) -> Result<Vec<VertexName>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Import a generated `CloneData` object into the DAG.
|
||||||
|
pub trait DagImportCloneData {
|
||||||
|
/// Updates the DAG using a `CloneData` object.
|
||||||
|
fn import_clone_data(&mut self, clone_data: CloneData<VertexName>) -> Result<()>;
|
||||||
|
}
|
||||||
|
|
||||||
/// Persistent the DAG on disk.
|
/// Persistent the DAG on disk.
|
||||||
pub trait DagPersistent {
|
pub trait DagPersistent {
|
||||||
/// Write in-memory DAG to disk. This might also pick up changes to
|
/// Write in-memory DAG to disk. This might also pick up changes to
|
||||||
|
Loading…
Reference in New Issue
Block a user