QMAUTRB6R5R7ABWT2JIDEA7LMILZOS3PGPZIF3YUFKRVLW6HGKTQC 6YZAVBWU6E5FYOI5JGEIPXGZLIKAW6LS2AOFIQWEE5DMOPPCD5PQC WT3GA27PQ2AOAIGK65O3Q4DMX4AZDVNULBLRL6GF4QW6QCASUEAAC 4WO3ZJM2RNYZCBPS7FGYAEBELYD57OSS7LEUYCWGZBCAY272SNQQC PTFDJ567XGGF26TE7KVQT7WPZIWV737DBO24VFIPEWPVAVKEKADQC AMPZ2BXK4IGUZO3OPBRSJ6Z4GI5K4PRFMLUGTR6AP4FKKRWQG7LQC V55EAIWQXWER2HWKZHPJBV7DDJMSPSPWSO3FSSAYODJHVDBHUN6QC NRCUG4R2NIM2ANIETSUZ7WZDXFOOCMJ73ROP5MDYJA4RUT4PYA4QC Y5ATDI2HRWTTYJAVUR7SVWQVB4ZKKDZF3UVE4JJQFZ7RX7H7VPJQC HOJZI52YIXKAYF766WR3SAOIFZH6YRMDOUE23VWEYNBZRBGEU25AC MJDGPSHGF62FTVWZBE7MFNJTUQD42OBVJEOSVPBT553UFJLTEMXQC ZVI4AWERNOTDJ3765HJXRBZT57XPNKVONQ6TGOGNPOL2VN42KMJQC #[allow(dead_code)] // TODO rm once `view_decoded` is fully implemented#[derive(Debug, Default)]pub struct State {pub selected_sections: Vec<usize>,pub expanded_unchanged_sections: Vec<usize>,pub collapsed_changed_sections: Vec<usize>,}#[derive(Debug, Clone)]pub enum Action {}pub fn update(_state: &mut State, _action: Action) {}pub fn view<'a>(state: &'a State, file: &'a File) -> Element<'a, Action> {match file {File::Decoded(decoded_file) => view_decoded(state, decoded_file),File::Undecodable(undecodable_file) => {view_undecodable(state, undecodable_file)}}}/// [`File`] is not part of [`State`] so it can be stored separately (i.e. in a/// cache, where it's immutable once set, unlike [`State`] which can change with [`Action`]s)
UnknownEncoding,}#[derive(Debug)]pub enum DiffWithContents {Add,Edit {line: usize,deleted: bool,contents: String,},Replacement {line: usize,/// Deleted linechange_contents: String,/// Added linesreplacement_contents: String,},Del,Undel,}#[allow(dead_code)] // TODO rm once `view_undecodable` is implemented#[derive(Debug)]pub enum DiffWithoutContents {// _________________________________________________________________________// Cases that never have contents:Move,SolveNameConflict,UnsolveNameConflict,SolveOrderConflict,UnsolveOrderConflict,ResurrectZombines,AddRoot,DelRoot,// _________________________________________________________________________// Cases that normally have contents, but in these cases the contents are// not decodable:Edit {line: usize,deleted: bool,contents: UndecodableContents,},Replacement {line: usize,/// Deleted linechange_contents: UndecodableContents,/// Added linesreplacement_contents: UndecodableContents,},}#[allow(dead_code)] // TODO rm once `view_undecodable` is implemented#[derive(Debug)]pub enum UndecodableContents {/// Short byte sequence of unknown encoding encoded with base64 for/// display. Must be shorter than [`crate::repo::MAX_LEN_BASE64_DISPLAY`]ShortBase64(String),
pub fn combine_decoded_contents(
pub fn from_repo_changed_file(changed_file: &repo::ChangedFile,) -> (Vec<DiffWithContents>, Vec<DiffWithoutContents>) {changed_file.iter().fold((vec![], vec![]), |(mut with, mut without), diff| {match diff {repo::ChangedFileDiff::Move => {without.push(DiffWithoutContents::Move);},repo::ChangedFileDiff::Del => {with.push(DiffWithContents::Del);},repo::ChangedFileDiff::Undel => {with.push(DiffWithContents::Undel);},repo::ChangedFileDiff::Add => {with.push(DiffWithContents::Add);},repo::ChangedFileDiff::SolveNameConflict => {without.push(DiffWithoutContents::Move);},repo::ChangedFileDiff::UnsolveNameConflict => {without.push(DiffWithoutContents::Move);},repo::ChangedFileDiff::Edit { line, deleted, contents } => match contents{repo::Contents::Decoded(lines) => {with.push(DiffWithContents::Edit {line: *line,deleted: *deleted,contents: lines.clone(),});},repo::Contents::ShortBase64(short) => {without.push(DiffWithoutContents::Edit {line: *line,deleted: *deleted,contents: UndecodableContents::ShortBase64(short.clone()),});},repo::Contents::UnknownEncoding(_bytes) => {without.push(DiffWithoutContents::Edit {line: *line,deleted: *deleted,contents: UndecodableContents::UnknownEncoding,});},},repo::ChangedFileDiff::Replacement { line, change_contents, replacement_contents } => match (change_contents, replacement_contents) {(repo::Contents::Decoded(change), repo::Contents::Decoded(replacement)) => {with.push(DiffWithContents::Replacement {line: *line,change_contents: change.clone(),replacement_contents: replacement.clone(),});},(repo::Contents::ShortBase64(change), repo::Contents::ShortBase64(replacement)) => {without.push(DiffWithoutContents::Replacement {line: *line,change_contents: UndecodableContents::ShortBase64(change.clone()),replacement_contents: UndecodableContents::ShortBase64(replacement.clone()),});},(repo::Contents::UnknownEncoding(_change), repo::Contents::UnknownEncoding(_replacement)) => {without.push(DiffWithoutContents::Replacement {line: *line,change_contents: UndecodableContents::UnknownEncoding,replacement_contents: UndecodableContents::UnknownEncoding,});},_ => {unimplemented!("The change and replacement have different encoding!");}},repo::ChangedFileDiff::SolveOrderConflict => {without.push(DiffWithoutContents::SolveOrderConflict);},repo::ChangedFileDiff::UnsolveOrderConflict => {without.push(DiffWithoutContents::UnsolveOrderConflict);},repo::ChangedFileDiff::ResurrectZombines => {without.push(DiffWithoutContents::ResurrectZombines);},repo::ChangedFileDiff::AddRoot => {without.push(DiffWithoutContents::AddRoot);},repo::ChangedFileDiff::DelRoot => {without.push(DiffWithoutContents::DelRoot);},};(with, without)})}fn combine_decoded_contents(
}pub fn diffs_from_repo_diffs(changed_file: &repo::ChangedFile,) -> (Vec<DiffWithContents>, Vec<DiffWithoutContents>) {changed_file.iter().fold((vec![], vec![]), |(mut with, mut without), diff| {match diff {repo::ChangedFileDiff::Move => {without.push(DiffWithoutContents::Move);},repo::ChangedFileDiff::Del => {with.push(DiffWithContents::Del);},repo::ChangedFileDiff::Undel => {with.push(DiffWithContents::Undel);},repo::ChangedFileDiff::Add => {with.push(DiffWithContents::Add);},repo::ChangedFileDiff::SolveNameConflict => {without.push(DiffWithoutContents::Move);},repo::ChangedFileDiff::UnsolveNameConflict => {without.push(DiffWithoutContents::Move);},repo::ChangedFileDiff::Edit { line, deleted, contents } => match contents{repo::Contents::Decoded(lines) => {with.push(DiffWithContents::Edit {line: *line,deleted: *deleted,contents: lines.clone(),});},repo::Contents::ShortBase64(short) => {without.push(DiffWithoutContents::Edit {line: *line,deleted: *deleted,contents: UndecodableContents::ShortBase64(short.clone()),});},repo::Contents::UnknownEncoding(_bytes) => {without.push(DiffWithoutContents::Edit {line: *line,deleted: *deleted,contents: UndecodableContents::UnknownEncoding,});},},repo::ChangedFileDiff::Replacement { line, change_contents, replacement_contents } => match (change_contents, replacement_contents) {(repo::Contents::Decoded(change), repo::Contents::Decoded(replacement)) => {with.push(DiffWithContents::Replacement {line: *line,change_contents: change.clone(),replacement_contents: replacement.clone(),});},(repo::Contents::ShortBase64(change), repo::Contents::ShortBase64(replacement)) => {without.push(DiffWithoutContents::Replacement {line: *line,change_contents: UndecodableContents::ShortBase64(change.clone()),replacement_contents: UndecodableContents::ShortBase64(replacement.clone()),});},(repo::Contents::UnknownEncoding(_change), repo::Contents::UnknownEncoding(_replacement)) => {without.push(DiffWithoutContents::Replacement {line: *line,change_contents: UndecodableContents::UnknownEncoding,replacement_contents: UndecodableContents::UnknownEncoding,});},_ => {unimplemented!("The change and replacement have different encoding!");}},repo::ChangedFileDiff::SolveOrderConflict => {without.push(DiffWithoutContents::SolveOrderConflict);},repo::ChangedFileDiff::UnsolveOrderConflict => {without.push(DiffWithoutContents::UnsolveOrderConflict);},repo::ChangedFileDiff::ResurrectZombines => {without.push(DiffWithoutContents::ResurrectZombines);},repo::ChangedFileDiff::AddRoot => {without.push(DiffWithoutContents::AddRoot);},repo::ChangedFileDiff::DelRoot => {without.push(DiffWithoutContents::DelRoot);},};(with, without)})
#[derive(Debug)]pub enum DiffWithContents {Add,Edit {line: usize,deleted: bool,contents: String,},Replacement {line: usize,/// Deleted linechange_contents: String,/// Added linesreplacement_contents: String,},Del,Undel,}#[allow(dead_code)] // TODO rm once `view_undecodable` is implemented#[derive(Debug)]pub enum DiffWithoutContents {// _________________________________________________________________________// Cases that never have contents:Move,SolveNameConflict,UnsolveNameConflict,SolveOrderConflict,UnsolveOrderConflict,ResurrectZombines,AddRoot,DelRoot,// _________________________________________________________________________// Cases that normally have contents, but in these cases the contents are// not decodable:Edit {line: usize,deleted: bool,contents: UndecodableContents,},Replacement {line: usize,/// Deleted linechange_contents: UndecodableContents,/// Added linesreplacement_contents: UndecodableContents,},}#[allow(dead_code)] // TODO rm once `view_undecodable` is implemented#[derive(Debug)]pub enum UndecodableContents {/// Short byte sequence of unknown encoding encoded with base64 for/// display. Must be shorter than [`crate::repo::MAX_LEN_BASE64_DISPLAY`]ShortBase64(String),UnknownEncoding,}#[allow(dead_code)] // TODO rm once `view_decoded` is fully implemented#[derive(Debug, Default)]pub struct State {pub selected_sections: Vec<usize>,pub expanded_unchanged_sections: Vec<usize>,pub collapsed_changed_sections: Vec<usize>,}#[derive(Debug)]pub enum Section {Unchanged(Lines),/// `deleted` and `added` are together because for/// `ChangedFileDiffWithContents::Replacement` they begin on the same line/// numberChanged {deleted: Lines,added: Lines,},}
}}/// INVARIANT: There must be no new-lines in any of the strings, the source/// string must be split on those.pub type Lines = Vec<String>;#[derive(Debug, Clone)]pub enum Msg {}pub fn update(_state: &mut State, _msg: Msg) {}pub fn view<'a>(state: &'a State, file: &'a File) -> Element<'a, Msg> {match file {File::Decoded(decoded_file) => view_decoded(state, decoded_file),File::Undecodable(undecodable_file) => {view_undecodable(state, undecodable_file)}