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KWGFTLQC WXQBBQ2ACNPKCTDF7OTBLP342324ZIOJK42PUO2KT2IYVJ2ETCMAC UR4J677RWA3OFG6HQTD46BUUE5YFPSBEFCJAEM5OMT4V5A7SBNNQC JZXYSIYDPBWQZCAMGDZ5BFMN6SU73EVVDIYEGTDJN6DVOSBNHN4QC 3XRG4BB6V5V4DICZCMOZMLQNTANWKPO7BBRATTXOZLRNSEUQIA5AC WAOGSCOJ5A372BZKHEYD2BCDBCENNVLFYW3INKUOOAZMDADDIFIQC WH57EHNML4OTGQQZBT2SG6SOFTBOD6OJPJYHJVGPH22CSSOE25AAC YK3MOJJLRYEKZ4FUCNJ3YKMTKOINWIYOJKR3ER7IRSGTC7O6FJZQC 5O4FWCFP4ZPAS7WKSYPHN76ML3O2S4JUOYWOV2ETD4TF2H6KZ6AQC VCNKFNUF7OWVSWC6I5D25KUZ3XZZICZ3LHWVPF2N5ZSP7LQ2JOUQC WT3GA27PQ2AOAIGK65O3Q4DMX4AZDVNULBLRL6GF4QW6QCASUEAAC 6YZAVBWU6E5FYOI5JGEIPXGZLIKAW6LS2AOFIQWEE5DMOPPCD5PQC add: _,path,} => {changes.entry(path.clone()).or_default().insert(ChangedFileDiff::Move);}
add,path: old_path,} => match add {change::Atom::NewVertex(add) => {let FileMetadata {basename: new_path,metadata: _,..} = FileMetadata::read(&diff.contents[add.start.0.into()..add.end.0.into()],);changes.entry(new_path.to_string()).or_default().insert(ChangedFileDiff::Move {old_path: old_path.clone(),},);}change::Atom::EdgeMap(_edge_map) => todo!(),},
DiffWithContents::Del => el(text("Deleted")),
DiffWithContents::Del { contents } => {if let Some(contents) = contents {let line_num = 1;let lines = contents_to_lines(contents);let max_line_num = line_num + lines.len();let line_num_digits = max_line_num.to_string().len();let lines_view =lines.into_iter().enumerate().map(|(ix, line)| {line_view(LineKind::Deleted,line_num + ix,line_num_digits,line,)});el(column(lines_view))} else {el(text("Deleted"))}}
let task = reindex_selection(
// // Add a diff that would make `reindex_selection` expect that the file// doesn't exist{let changed_file = BTreeSet::from_iter([repo::ChangedFileDiff::Del {contents: None,}]);assert!(!diff::should_file_exist(&changed_file));ready_state.repo.changed_files.insert("changed_1.rs".to_string(), changed_file);}let mut task = reindex_selection(
assert!(task.is_none());assert!(state.files.diffs_cache.inner.is_empty());
assert!(task.is_some());let msg = await_next_msg(&mut task).await;assert_matches!(&msg,crate::Msg::File(file::Msg::SrcFileDoesntExist { .. }));// The file will be assembled from the diffassert_matches!(state.files.diffs_cache.inner.peek(&file::id_parts_hash("changed_1.rs", file::Kind::Changed)),Some(file::Diff::Loaded(_)));// Clear the cache for next test casestate.files.diffs_cache.inner.clear();
file::load_src_file_if_not_cached(ctx.files, id);}
if diff::should_file_exist(diffs) {file::load_src_file_if_not_cached(ctx.files, id);Task::none()} else {file::src_file_doesnt_exist(ctx.files, id, diffs).map(crate::Msg::File)}} else {Task::none()};
file::load_src_file_if_not_cached(files,file::Id {path: path.clone(),file_kind: file::Kind::Changed,},);}
let id = file::Id {path: path.clone(),file_kind: file::Kind::Changed,};if diff::should_file_exist(diffs) {file::load_src_file_if_not_cached(files, id);Task::none()} else {file::src_file_doesnt_exist(files, id, diffs).map(Msg::File)}} else {Task::none()};
}}pub fn src_file_doesnt_exist(state: &mut State,id: Id,changed_file: &repo::ChangedFile,) -> Task<Msg> {let id_hash = id_hash(&id);if !state.diffs_cache.inner.contains(&id_hash) {let content = diff::FileContent::Decoded(Cow::from(""));let file = diff::init_file(content, Some(changed_file));diffs_cache_put(&mut state.diffs_cache, id_hash, Diff::Loaded(file));return Task::done(Msg::SrcFileDoesntExist { id });
repo::ChangedFileDiff::Del => {with.push(DiffWithContents::Del);
repo::ChangedFileDiff::Del { contents } => {let contents = match contents {Some(repo::Contents::Decoded(lines) | repo::Contents::ShortBase64(lines)) => Some(lines.clone()),Some(repo::Contents::UnknownEncoding(_)) | None => None};without.push(DiffWithoutContents::Del);with.push(DiffWithContents::Del{ contents });
/// Returns true if any of the changed file's diffs has contentspub fn any_diff_has_contents(changed_file: &repo::ChangedFile) -> bool {let (with_contents, _without_contents) =from_repo_changed_file(changed_file);!with_contents.is_empty()
/// Returns true if from the diffs imply that the file should exist.pub fn should_file_exist(changed_file: &repo::ChangedFile) -> bool {for change in changed_file {match change {repo::ChangedFileDiff::Del { .. }| repo::ChangedFileDiff::AddRoot| repo::ChangedFileDiff::DelRoot => return false,repo::ChangedFileDiff::Move { .. }| repo::ChangedFileDiff::Undel| repo::ChangedFileDiff::Add| repo::ChangedFileDiff::SolveNameConflict| repo::ChangedFileDiff::UnsolveNameConflict| repo::ChangedFileDiff::Edit { .. }| repo::ChangedFileDiff::Replacement { .. }| repo::ChangedFileDiff::SolveOrderConflict| repo::ChangedFileDiff::UnsolveOrderConflict| repo::ChangedFileDiff::ResurrectZombines => {}}}true
let deleted: Vec<_> = file_lines.map(str::to_string).collect();
let lines: Vec<_> = file_lines.map(str::to_string).collect();let max_line_num = lines.len();sections.push(Section::Unchanged(lines));return Combined {sections,max_line_num,};}DiffWithContents::Del { contents } => {let deleted = contents.as_deref().map(contents_to_lines).unwrap_or_default();