mirror of
https://github.com/martinvonz/jj.git
synced 2024-10-23 15:00:17 +00:00
index: use DefaultMutableIndex wrapper when reconstructing missing index
This allows us to extract helper method that writes index file and associates it with the operation.
This commit is contained in:
parent
50164bb36f
commit
bf4a4e70b1
2 changed files with 6 additions and 7 deletions
|
@ -392,7 +392,6 @@ impl IndexSegment for MutableIndexSegment {
|
|||
pub struct DefaultMutableIndex(MutableIndexSegment);
|
||||
|
||||
impl DefaultMutableIndex {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn full(commit_id_length: usize, change_id_length: usize) -> Self {
|
||||
let mutable_segment = MutableIndexSegment::full(commit_id_length, change_id_length);
|
||||
DefaultMutableIndex(mutable_segment)
|
||||
|
|
|
@ -25,7 +25,7 @@ use itertools::Itertools;
|
|||
use tempfile::NamedTempFile;
|
||||
use thiserror::Error;
|
||||
|
||||
use super::mutable::{DefaultMutableIndex, MutableIndexSegment};
|
||||
use super::mutable::DefaultMutableIndex;
|
||||
use super::readonly::{DefaultReadonlyIndex, ReadonlyIndexSegment};
|
||||
use crate::backend::{CommitId, ObjectId};
|
||||
use crate::commit::CommitByCommitterTimestamp;
|
||||
|
@ -129,19 +129,19 @@ impl DefaultIndexStore {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut data;
|
||||
let maybe_parent_file;
|
||||
let mut mutable_index;
|
||||
match parent_op_id {
|
||||
None => {
|
||||
maybe_parent_file = None;
|
||||
data = MutableIndexSegment::full(commit_id_length, change_id_length);
|
||||
mutable_index = DefaultMutableIndex::full(commit_id_length, change_id_length);
|
||||
}
|
||||
Some(parent_op_id) => {
|
||||
let parent_file = self
|
||||
.load_index_at_operation(commit_id_length, change_id_length, &parent_op_id)
|
||||
.unwrap();
|
||||
maybe_parent_file = Some(parent_file.clone());
|
||||
data = MutableIndexSegment::incremental(parent_file)
|
||||
mutable_index = DefaultMutableIndex::incremental(parent_file)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,10 +173,10 @@ impl DefaultIndexStore {
|
|||
},
|
||||
);
|
||||
for CommitByCommitterTimestamp(commit) in commits.iter().rev() {
|
||||
data.add_commit(commit);
|
||||
mutable_index.add_commit(commit);
|
||||
}
|
||||
|
||||
let index_file = data.save_in(self.dir.clone())?;
|
||||
let index_file = mutable_index.save_in(self.dir.clone())?;
|
||||
self.associate_file_with_operation(&index_file, operation.id())?;
|
||||
tracing::info!(
|
||||
?index_file,
|
||||
|
|
Loading…
Reference in a new issue