show changed files diffs (only Edit atm)

[?]
Apr 15, 2025, 5:15 PM
AMPZ2BXK4IGUZO3OPBRSJ6Z4GI5K4PRFMLUGTR6AP4FKKRWQG7LQC

Dependencies

  • [2] 6YZAVBWU Initial commit
  • [3] IQDCHWCP load a pijul repo
  • [4] 3GZPRZXC s/-/_ in crate paths
  • [5] SWWE2R6M display basic repo stuff
  • [6] WT3GA27P add cursor with selection
  • [7] UB2ITZJS refresh changed files on FS changes
  • [8] KT5UYXGK fix selection after adding file, add changed file diffs
  • [9] S2NVIFXR allow to enter record msg
  • [10] W7IUT3ZV start recording impl
  • [11] YBJRDOTC make all repo actions async
  • [12] 2VUX5BTD load identity
  • [13] A5YBC77V record!
  • [14] Z2CJPWZE focus record message text_editor on spawn
  • [15] D7A7MSIH allow to defer or abandon record, add buttons
  • [16] 4WO3ZJM2 show untracked files' contents
  • [17] BJXUYQ2Y show untracked file contents in read-only text editor
  • [18] CFYW3HGZ wip: display changed files
  • [19] W4LFX7IH group diffs by file name
  • [20] PTFDJ567 add untracked files encoding
  • [21] EC3TVL4X add untracked files

Change contents

  • replacement in crates/libflowers_client/src/repo.rs at line 19
    [10.20][13.180:282]()
    working_copy, ChannelMutTxnT, ChannelTxnT, Hash, HashSet, MutTxnT,
    MutTxnTExt, TxnT, TxnTExt,
    [10.20]
    [10.93]
    working_copy, ChannelMutTxnT, ChannelTxnT, Encoding, Hash, HashSet,
    MutTxnT, MutTxnTExt, TxnT, TxnTExt,
  • edit in crates/libflowers_client/src/repo.rs at line 45
    [19.221]
    [8.262]
    pub const MAX_LEN_BASE64_DISPLAY: usize = 4096;
  • replacement in crates/libflowers_client/src/repo.rs at line 58
    [16.229][16.229:256]()
    contents: Vec<u8>,
    [16.229]
    [16.256]
    contents: Contents,
  • edit in crates/libflowers_client/src/repo.rs at line 66
    [8.575]
    [11.312]
    }
    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
    pub enum Contents {
    Decoded(String),
    /// Short byte sequence of unknown encoding encoded with base64 for display.
    /// Must be shorter than [`MAX_LEN_BASE64_DISPLAY`]
    ShortBase64(String),
    UnknownEncoding(Vec<u8>),
  • replacement in crates/libflowers_client/src/repo.rs at line 509
    [16.560][8.3056:3085](),[8.3056][8.3056:3085]()
    encoding: _,
    [16.560]
    [16.561]
    encoding,
  • replacement in crates/libflowers_client/src/repo.rs at line 521
    [16.1058][16.1058:1089]()
    let contents =
    [16.1058]
    [16.1089]
    let raw_contents =
  • edit in crates/libflowers_client/src/repo.rs at line 524
    [16.1202]
    [16.1202]
    let contents = try_decode_contents(raw_contents, encoding);
  • edit in crates/libflowers_client/src/repo.rs at line 639
    [11.4519]
    fn try_decode_contents(raw: Vec<u8>, encoding: &Option<Encoding>) -> Contents {
    match encoding {
    Some(encoding) => {
    let decoded = encoding.decode(&raw);
    Contents::Decoded(decoded.to_string())
    }
    None => {
    if raw.len() <= MAX_LEN_BASE64_DISPLAY {
    let encoded =
    format!("b{}", data_encoding::BASE64.encode(&raw));
    Contents::ShortBase64(encoded)
    } else {
    Contents::UnknownEncoding(raw)
    }
    }
    }
    }
  • edit in crates/libflowers_client/src/lib.rs at line 1
    [2.1360][6.8:24]()
    pub mod cursor;
  • edit in crates/flowers_ui/src/main.rs at line 1
    [2.2763]
    [5.4814]
    mod cursor;
  • replacement in crates/flowers_ui/src/main.rs at line 5
    [12.447][12.447:496]()
    use libflowers_client::{cursor, identity, repo};
    [12.447]
    [16.1478]
    use libflowers_client::repo::MAX_LEN_BASE64_DISPLAY;
    use libflowers_client::{identity, repo};
  • replacement in crates/flowers_ui/src/main.rs at line 10
    [16.1523][14.23:43](),[3.1025][14.23:43](),[14.43][16.1524:1603](),[16.1603][14.110:113](),[14.110][14.110:113]()
    use iced::widget::{
    self, button, column, horizontal_rule, row, scrollable, text, text_editor,
    };
    [16.1523]
    [6.437]
    use iced::widget::{self, button, column, row, scrollable, text, text_editor};
  • edit in crates/flowers_ui/src/main.rs at line 17
    [8.4614]
    [7.351]
    use std::collections::BTreeMap;
  • edit in crates/flowers_ui/src/main.rs at line 25
    [2.2835]
    [2.2835]
    const SPACING: u16 = 10;
  • edit in crates/flowers_ui/src/main.rs at line 98
    [16.2347]
    [7.1520]
    changed_files_contents: BTreeMap::default(),
  • edit in crates/flowers_ui/src/main.rs at line 115
    [16.2459]
    [15.58]
    /// Keyed by file name matching `repo::ChangedFiles`
    changed_files_contents: ChangedFilesContents,
  • edit in crates/flowers_ui/src/main.rs at line 130
    [20.217][20.217:261](),[20.261][16.2705:2706](),[16.2705][16.2705:2706]()
    const MAX_LEN_BASE64_DISPLAY: usize = 4096;
  • edit in crates/flowers_ui/src/main.rs at line 138
    [20.507]
    [20.507]
    type ChangedFilesContents = BTreeMap<String, ChangedFileContents>;
  • edit in crates/flowers_ui/src/main.rs at line 141
    [20.508]
    [20.508]
    /// The order of the vec matches `repo::ChangedFile`
    type ChangedFileContents = Vec<Option<FileEditorContent>>;
  • edit in crates/flowers_ui/src/main.rs at line 177
    [17.122]
    [6.735]
    ChangedFileContentsAction {
    file: String,
    ix: usize,
    action: text_editor::Action,
    },
  • edit in crates/flowers_ui/src/main.rs at line 528
    [19.4197]
    [13.5329]
    state.changed_files_contents = BTreeMap::default();
  • edit in crates/flowers_ui/src/main.rs at line 616
    [20.1696]
    [17.1071]
    }
    }
    Task::none()
    }
    Message::ChangedFileContentsAction { file, ix, action } => {
    // Read-only
    if !action.is_edit() {
    if let Some(contents) =
    state.changed_files_contents.get_mut(&file)
    {
    if let Some(content) = contents.get_mut(ix) {
    match content {
    Some(FileEditorContent::Decoded(content)) => {
    content.perform(action);
    }
    _ => panic!("Unexpected content: {content:?}"),
    }
    }
  • edit in crates/flowers_ui/src/main.rs at line 644
    [11.14895]
    [11.14895]
    state.changed_files_contents =
    changed_files_contents(&repo.changed_files);
  • edit in crates/flowers_ui/src/main.rs at line 685
    [11.15096]
    [11.15096]
    state.changed_files_contents =
    changed_files_contents(&changed_files);
  • edit in crates/flowers_ui/src/main.rs at line 728
    [11.16466]
    [11.16466]
    }
    }
    }
    fn changed_files_contents(
    changed_files: &repo::ChangedFiles,
    ) -> ChangedFilesContents {
    changed_files
    .iter()
    .map(|(file, diffs)| {
    let contents = diffs
    .iter()
    .map(|diff| match diff {
    repo::ChangedFileDiff::Move => None,
    repo::ChangedFileDiff::Del => None,
    repo::ChangedFileDiff::Undel => None,
    repo::ChangedFileDiff::Add => None,
    repo::ChangedFileDiff::SolveNameConflict => None,
    repo::ChangedFileDiff::UnsolveNameConflict => None,
    repo::ChangedFileDiff::Edit {
    line: _,
    deleted: _,
    contents,
    } => Some(contents_to_file_editor_content(contents)),
    repo::ChangedFileDiff::Replacement => None,
    repo::ChangedFileDiff::SolveOrderConflict => None,
    repo::ChangedFileDiff::UnsolveOrderConflict => None,
    repo::ChangedFileDiff::ResurrectZombines => None,
    repo::ChangedFileDiff::AddRoot => None,
    repo::ChangedFileDiff::DelRoot => None,
    })
    .collect();
    (file.clone(), contents)
    })
    .collect()
    }
    fn contents_to_file_editor_content(
    contents: &repo::Contents,
    ) -> FileEditorContent {
    match contents {
    repo::Contents::Decoded(content) => {
    FileEditorContent::Decoded(text_editor::Content::with_text(content))
  • edit in crates/flowers_ui/src/main.rs at line 772
    [11.16476]
    [6.2657]
    repo::Contents::ShortBase64(short) => {
    FileEditorContent::ShortBase64(short.clone())
    }
    repo::Contents::UnknownEncoding(_vec) => {
    FileEditorContent::UnknownEncoding
    }
  • replacement in crates/flowers_ui/src/main.rs at line 919
    [18.90][18.90:170](),[18.329][18.329:364]()
    let changed_file = repo.changed_files.iter().nth(*ix).unwrap();
    let diff = "todo";
    [18.90]
    [18.364]
    let (file_name, diffs) =
    repo.changed_files.iter().nth(*ix).unwrap();
    let file_editor_contents =
    state.changed_files_contents.get(file_name).unwrap();
    let diffs = diffs.iter().enumerate().map(|(ix, diff)| {
    let file_editor_content =
    file_editor_contents.get(ix).unwrap();
    view_diff(diff, file_editor_content, file_name, ix)
    });
  • replacement in crates/flowers_ui/src/main.rs at line 930
    [18.447][18.447:495]()
    el(scrollable(text(diff))),
    [18.447]
    [18.495]
    el(scrollable(column(diffs).spacing(SPACING))),
  • replacement in crates/flowers_ui/src/main.rs at line 939
    [15.3580][15.3580:3733](),[15.3733][20.2327:2365](),[20.2365][15.3771:3842](),[15.3771][15.3771:3842]()
    el(horizontal_rule(1)),
    el(text("Untracked:")),
    untracked_files,
    el(horizontal_rule(1)),
    el(text("Changes:")),
    changed_files,
    el(horizontal_rule(1)),
    [15.3580]
    [15.3842]
    el(column([el(text("Untracked files:")), untracked_files])),
    el(column([el(text("Changed files:")), changed_files])),
  • replacement in crates/flowers_ui/src/main.rs at line 943
    [15.3878][15.3878:3923]()
    .width(Length::FillPortion(1))),
    [15.3878]
    [16.9739]
    .width(Length::FillPortion(1))
    .spacing(SPACING)),
  • replacement in crates/flowers_ui/src/main.rs at line 947
    [15.3998][11.18274:18286](),[16.9850][11.18274:18286](),[11.18274][11.18274:18286]()
    ]))
    [16.9850]
    [9.1940]
    ])
    .spacing(SPACING))
  • edit in crates/flowers_ui/src/main.rs at line 954
    [6.4175]
    [6.4175]
    fn view_diff<'a>(
    diff: &'a repo::ChangedFileDiff,
    content: &'a Option<FileEditorContent>,
    file: &'a String,
    ix: usize,
    ) -> Element<'a, Message> {
    match content {
    Some(content) => match content {
    FileEditorContent::Decoded(content) => el(text_editor(content)
    .on_action(move |action| Message::ChangedFileContentsAction {
    file: file.clone(),
    ix,
    action,
    })),
    FileEditorContent::ShortBase64(short) => el(text(short)),
    FileEditorContent::UnknownEncoding => el(text(format!("{diff:?}"))),
    },
    None => el(text(format!("{diff:?}"))),
    }
    }
  • file move: cursor.rs (----------)cursor.rs (----------)
    [4.154]
    [6.26]