mirror of
https://github.com/facebook/sapling.git
synced 2024-12-25 05:53:24 +03:00
pydag: add an API to migrate from one DAG to segmented DAG
Summary: This will be used for migrating revlog DAG to segmented changelog. It does not migrate commit text data (which can take 10+ minutes). Reviewed By: DurhamG, sfilipco Differential Revision: D22970582 fbshipit-source-id: 125a8726d48e15ceb06edb139d6d5b2fc132a32c
This commit is contained in:
parent
9f8961a75c
commit
fa25f42fea
@ -145,6 +145,18 @@ py_class!(pub class commits |py| {
|
||||
Self::from_commits(py, inner)
|
||||
}
|
||||
|
||||
/// Migrate from revlog to segmented changelog (full IdMap).
|
||||
///
|
||||
/// This does not migrate commit texts and therefore only useful for
|
||||
/// doublewrite backend.
|
||||
@staticmethod
|
||||
def migraterevlogtosegments(revlogdir: &PyPath, segmentsdir: &PyPath, commitsdir: &PyPath, master: Names) -> PyResult<PyNone> {
|
||||
let revlog = RevlogCommits::new(revlogdir.as_path()).map_pyerr(py)?;
|
||||
let mut segments = HgCommits::new(segmentsdir.as_path(), commitsdir.as_path()).map_pyerr(py)?;
|
||||
py.allow_threads(|| segments.import_dag(revlog, master.0)).map_pyerr(py)?;
|
||||
Ok(PyNone)
|
||||
}
|
||||
|
||||
/// Construct "double write" `commits` from both revlog and segmented
|
||||
/// changelog.
|
||||
@staticmethod
|
||||
|
@ -53,6 +53,13 @@ impl HgCommits {
|
||||
};
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Import another DAG. `main` specifies the main branch for commit graph
|
||||
/// optimization.
|
||||
pub fn import_dag(&mut self, other: impl DagAlgorithm, main: Set) -> Result<()> {
|
||||
self.dag.import_and_flush(&other, main)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl AppendCommits for HgCommits {
|
||||
|
Loading…
Reference in New Issue
Block a user