mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 06:18:07 +03:00
dag: remove remove_non_master API and tests
Summary: They are no longer needed as we now have more flexible "strip" APIs. Reviewed By: zzl0 Differential Revision: D47488532 fbshipit-source-id: 932c1ff8b041aa663c7006cec3b572a91bee6647
This commit is contained in:
parent
be9bf235ee
commit
069dfdebf5
@ -1757,13 +1757,6 @@ impl<Store: IdDagStore> IdDag<Store> {
|
||||
Ok(parents)
|
||||
}
|
||||
|
||||
/// Remove all non master Group identifiers from the DAG.
|
||||
pub fn remove_non_master(&mut self) -> Result<()> {
|
||||
// Non-append-only change. Use a new incompatible version.
|
||||
self.version = VerLink::new();
|
||||
self.store.remove_non_master()
|
||||
}
|
||||
|
||||
/// Remove `set` and their descendants. Return `descendents(set)`.
|
||||
///
|
||||
/// The returned `descendants(set)` is usually used to remove
|
||||
|
@ -273,9 +273,6 @@ pub trait IdDagStore: Send + Sync + 'static {
|
||||
parent: Id,
|
||||
) -> Result<Box<dyn Iterator<Item = Result<Segment>> + 'a>>;
|
||||
|
||||
/// Remove all non master Group identifiers from the DAG.
|
||||
fn remove_non_master(&mut self) -> Result<()>;
|
||||
|
||||
/// Attempt to merge the flat `segment` with the last flat segment to reduce
|
||||
/// fragmentation.
|
||||
///
|
||||
@ -612,10 +609,6 @@ pub(crate) mod tests {
|
||||
assert_eq!(all_id_str(store, &[M]), "0..=70");
|
||||
assert_eq!(all_id_str(store, &[N]), "N0..=N30");
|
||||
assert_eq!(all_id_str(store, &[M, N]), "0..=70 N0..=N30");
|
||||
|
||||
store.remove_non_master().unwrap();
|
||||
assert_eq!(all_id_str(store, &[N]), "");
|
||||
assert_eq!(all_id_str(store, &[M, N]), "0..=70");
|
||||
}
|
||||
|
||||
fn test_all_ids_in_segment_level(store: &mut dyn IdDagStore) {
|
||||
@ -841,30 +834,6 @@ pub(crate) mod tests {
|
||||
assert_eq!(answer, expected);
|
||||
}
|
||||
|
||||
fn test_remove_non_master(store: &mut dyn IdDagStore) {
|
||||
store.remove_non_master().unwrap();
|
||||
|
||||
assert!(
|
||||
store
|
||||
.find_segment_by_head_and_level(nid(2), 0 as Level)
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
assert!(
|
||||
store
|
||||
.find_flat_segment_including_id(nid(1))
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
assert!(
|
||||
store
|
||||
.iter_flat_segments_with_parent_span(nid(2).into())
|
||||
.unwrap()
|
||||
.next()
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn test_remove_segment(store: &mut dyn IdDagStore) {
|
||||
// Prepare segments, 3 segments per group.
|
||||
let parents_nid_3_4 = [nid(4), nid(3)];
|
||||
@ -1145,11 +1114,6 @@ P->C: 50->N100, 50->N300"#
|
||||
for_each_store(|store| test_store_iter_flat_segments_with_parent(store));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multi_stores_remove_non_master() {
|
||||
for_each_store(|store| test_remove_non_master(store));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multi_stores_discontinuous_merges() {
|
||||
for_each_empty_store(|store| test_discontinuous_merges(store));
|
||||
|
@ -206,26 +206,6 @@ impl IdDagStore for InProcessStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remove_non_master(&mut self) -> Result<()> {
|
||||
for segment in self.non_master_segments.iter() {
|
||||
let level = segment.level()?;
|
||||
let head = segment.head()?;
|
||||
self.level_head_index
|
||||
.get_mut(level as usize)
|
||||
.map(|head_index| head_index.remove(&head));
|
||||
}
|
||||
let group = Group::NON_MASTER;
|
||||
for (_key, children) in self
|
||||
.parent_index
|
||||
.range_mut((group, group.min_id())..=(group, group.max_id()))
|
||||
{
|
||||
children.clear();
|
||||
}
|
||||
self.non_master_segments = Vec::new();
|
||||
self.id_set_by_group[Group::NON_MASTER.0] = IdSet::empty();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn all_ids_in_groups(&self, groups: &[Group]) -> Result<IdSet> {
|
||||
let mut result = IdSet::empty();
|
||||
for group in groups {
|
||||
|
@ -373,16 +373,6 @@ impl IdDagStore for IndexedLogStore {
|
||||
let iter = self.iter_flat_segments_with_parent_span(parent.into())?;
|
||||
Ok(Box::new(iter.map(|item| item.map(|(_, seg)| seg))))
|
||||
}
|
||||
|
||||
/// Mark non-master ids as "removed".
|
||||
fn remove_non_master(&mut self) -> Result<()> {
|
||||
self.log.append(Self::MAGIC_CLEAR_NON_MASTER)?;
|
||||
let non_master_ids = self.all_ids_in_groups(&[Group::NON_MASTER])?;
|
||||
if !non_master_ids.is_empty() {
|
||||
return bug("remove_non_master did not take effect");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Persist for IndexedLogStore {
|
||||
|
Loading…
Reference in New Issue
Block a user