use super::{DirEntryInfo, StatInfo, WalkDirsUtf8};
#[derive(Debug, Clone)]
pub struct ProcessPathInfo {
pub abspath: Vec<u8>,
pub kind: Option<crate::osutils::Kind>,
pub stat: StatInfo,
}
#[derive(Debug, Default)]
pub struct ProcessEntryState {
pub source_index: Option<usize>,
pub target_index: usize,
pub include_unchanged: bool,
pub want_unversioned: bool,
pub partial: bool,
pub supports_tree_reference: bool,
pub root_abspath: Vec<u8>,
pub searched_specific_files: std::collections::HashSet<Vec<u8>>,
pub search_specific_files: std::collections::HashSet<Vec<u8>>,
pub search_specific_file_parents: std::collections::HashSet<Vec<u8>>,
pub searched_exact_paths: std::collections::HashSet<Vec<u8>>,
pub seen_ids: std::collections::HashSet<Vec<u8>>,
pub new_dirname_to_file_id: std::collections::HashMap<Vec<u8>, Vec<u8>>,
pub old_dirname_to_file_id: std::collections::HashMap<Vec<u8>, Vec<u8>>,
pub last_source_parent: Option<(Vec<u8>, Option<Vec<u8>>)>,
pub last_target_parent: Option<(Vec<u8>, Option<Vec<u8>>)>,
}
#[derive(Debug, Clone)]
pub struct DirstateChange {
pub file_id: Vec<u8>,
pub old_path: Option<Vec<u8>>,
pub new_path: Option<Vec<u8>>,
pub content_change: bool,
pub old_versioned: bool,
pub new_versioned: bool,
pub source_parent_id: Option<Vec<u8>>,
pub target_parent_id: Option<Vec<u8>>,
pub old_basename: Option<Vec<u8>>,
pub new_basename: Option<Vec<u8>>,
pub source_kind: Option<crate::osutils::Kind>,
pub target_kind: Option<crate::osutils::Kind>,
pub source_exec: Option<bool>,
pub target_exec: Option<bool>,
}
#[derive(Debug)]
pub enum ProcessEntryError {
DirstateCorrupt(String),
BadFileKind {
path: Vec<u8>,
mode: u32,
},
Internal(String),
}
impl std::fmt::Display for ProcessEntryError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProcessEntryError::DirstateCorrupt(s) => write!(f, "dirstate corrupt: {}", s),
ProcessEntryError::BadFileKind { path, mode } => write!(
f,
"bad file kind for {}: mode {:o}",
String::from_utf8_lossy(path),
mode
),
ProcessEntryError::Internal(s) => write!(f, "process_entry: {}", s),
}
}
}
impl std::error::Error for ProcessEntryError {}
#[derive(Debug)]
pub struct IterChangesIter {
pub(super) phase: IterPhase,
pub(super) current_root: Option<(Vec<u8>, Vec<u8>)>,
pub(super) root_processed: bool,
pub(super) walker: Option<WalkDirsUtf8>,
pub(super) block_index: usize,
pub(super) staged_walker_block: Option<(Vec<u8>, Vec<u8>, Vec<DirEntryInfo>)>,
pub(super) merge_entry_index: usize,
pub(super) merge_path_index: usize,
pub(super) merge_path_handled: bool,
pub(super) merge_advance_entry: bool,
pub(super) merge_advance_path: bool,
pub(super) pending: std::collections::VecDeque<DirstateChange>,
pub(super) parents_drain_started: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum IterPhase {
PickRoot,
ProcessRoot,
WalkSubtree,
DrainParents,
Done,
}
impl Default for IterChangesIter {
fn default() -> Self {
Self::new()
}
}
impl IterChangesIter {
pub fn new() -> Self {
Self {
phase: IterPhase::PickRoot,
current_root: None,
root_processed: false,
walker: None,
block_index: 0,
staged_walker_block: None,
merge_entry_index: 0,
merge_path_index: 0,
merge_path_handled: false,
merge_advance_entry: true,
merge_advance_path: true,
pending: std::collections::VecDeque::new(),
parents_drain_started: false,
}
}
}