allow to rm added files

[?]
Feb 15, 2025, 6:25 PM
ELG3UDT6OJFEYSJR7HZEC65IUWBMGPPPCXEW3CDW5T74R6KC5LIAC

Dependencies

  • [2] 6YZAVBWU Initial commit
  • [3] WT3GA27P add cursor with selection
  • [4] UB2ITZJS refresh changed files on FS changes
  • [5] EC3TVL4X add untracked files
  • [6] KT5UYXGK fix selection after adding file, add changed file diffs
  • [7] SWWE2R6M display basic repo stuff
  • [8] KLR5FRIB add fs state read/write of repos

Change contents

  • replacement in justfile at line 33
    [2.381][2.381:392]()
    doc_check:
    [2.381]
    [2.392]
    doc-check:
  • replacement in crates/libflowers_client/src/repo.rs at line 68
    [5.441][5.441:494]()
    state.untracked_files = untracked_files(&state);
    [5.441]
    [4.46]
    state.untracked_files = untracked_files(state);
  • replacement in crates/libflowers_client/src/repo.rs at line 167
    [6.1232][6.1232:1474]()
    let path = if let Ok(path) =
    path.as_path().strip_prefix(&repo_path.as_path())
    {
    path
    } else {
    return;
    };
    let path_str = path_slash::PathExt::to_slash_lossy(path);
    [6.1232]
    [6.1474]
    let path_str = path_slash::PathExt::to_slash_lossy(path.as_path());
  • edit in crates/libflowers_client/src/repo.rs at line 173
    [6.1664]
    [6.1664]
    }
    txn.commit().unwrap();
    }
    pub fn rm(repo: &mut pijul::Repository, path_str: &str) {
    let mut txn = repo.pristine.mut_txn_begin().unwrap();
    let full_path = {
    let mut p = repo.path.clone();
    p.push(path_str);
    p
    };
    let path = full_path.canonicalize().unwrap();
    let path_str = path_slash::PathExt::to_slash_lossy(path.as_path());
    if txn.is_tracked(&path_str).unwrap() {
    txn.remove_file(&path_str).unwrap();
  • edit in crates/flowers_ui/src/main.rs at line 85
    [6.4637]
    [3.735]
    RmAddedFile,
  • edit in crates/flowers_ui/src/main.rs at line 270
    [6.7537]
    [3.2657]
    Message::RmAddedFile => {
    if let Some(cursor::Selection::ChangedFile { ix, path }) =
    state.cursor.selection.as_ref()
    {
    let file = state.repo.changed_files.iter().nth(*ix).unwrap();
    if let repo::ChangedFileDiff::Add = &file.diff {
    repo::rm(&mut state.repo.state, path);
    let file = file.clone();
    // Remove from changed files
    let removed = state.repo.changed_files.remove(&file);
    debug_assert!(
    removed,
    "{:?} not found in {:?}",
    file, state.repo.changed_files
    );
    // Update untracked files
    state.repo.untracked_files.insert(file.path);
    // Select the next changed file, if any
    state.cursor.selection =
    if state.repo.changed_files.is_empty() {
    None
    } else {
    let ix = cmp::min(
    *ix,
    state.repo.changed_files.len() - 1,
    );
    Some(changed_file_selection(state, ix))
    };
    }
    }
    }
  • edit in crates/flowers_ui/src/main.rs at line 314
    [6.7598]
    [3.3009]
    "x" => Some(Message::RmAddedFile),