add untracked files
[?]
Feb 12, 2025, 11:54 AM
EC3TVL4X6VZZVLOKUN63LC73ADPHBHMZO7QMDXGX2ZPURVI4B4XQCDependencies
- [2]
6YZAVBWUInitial commit - [3]
KLR5FRIBadd fs state read/write of repos - [4]
IQDCHWCPload a pijul repo - [5]
SWWE2R6Mdisplay basic repo stuff - [6]
WT3GA27Padd cursor with selection - [7]
DVKSPF7Rtrack selected file path together with an index - [8]
UB2ITZJSrefresh changed files on FS changes
Change contents
- edit in crates/libflowers_client/src/repo.rs at line 1
use std::borrow::Cow; - replacement in crates/libflowers_client/src/repo.rs at line 3
use std::{borrow::Cow, ops::Deref, path::PathBuf};use std::ops::Deref;use std::path::PathBuf; - edit in crates/libflowers_client/src/repo.rs at line 6
use canonical_path::CanonicalPathBuf; - replacement in crates/libflowers_client/src/repo.rs at line 9
use pijul::change::{Author, ChangeHeader, Hunk, Local};use pijul::change::{BaseHunk, LocalChange};use pijul::Hash;use pijul::change::{Author, BaseHunk, ChangeHeader, Hunk, Local, LocalChange};use pijul::{Hash, MutTxnT, TxnT, TxnTExt}; - edit in crates/libflowers_client/src/repo.rs at line 17
pub untracked_files: BTreeSet<String>, - edit in crates/libflowers_client/src/repo.rs at line 34
let untracked_files = untracked_files(&state); - edit in crates/libflowers_client/src/repo.rs at line 38
untracked_files, - edit in crates/libflowers_client/src/repo.rs at line 44
// TODO: Optimize by using the notify event info about what file has changedstate.untracked_files = untracked_files(&state); - replacement in crates/libflowers_client/src/repo.rs at line 47
let changed_files = changed_files(&diff);state.changed_files = changed_files;state.changed_files = changed_files(&diff); - edit in crates/libflowers_client/src/repo.rs at line 55
use pijul::TxnT; - edit in crates/libflowers_client/src/repo.rs at line 64
use pijul::MutTxnT;use pijul::TxnT; - edit in crates/libflowers_client/src/repo.rs at line 170
}).collect()}fn untracked_files(repo: &pijul::Repository) -> BTreeSet<String> {let repo_path = CanonicalPathBuf::canonicalize(&repo.path).unwrap();let txn = repo.pristine.arc_txn_begin().unwrap();let threads = std::thread::available_parallelism().unwrap().get();let txn_ = txn.clone();repo.working_copy.iterate_prefix_rec(repo_path.clone(),repo_path.clone(),false,threads,move |path, _| {use path_slash::PathExt;let path_str = path.to_slash_lossy();path_str.is_empty() || txn.read().is_tracked(&path_str).unwrap()},).unwrap().filter_map(move |path| {let (path, _) = path.unwrap();use path_slash::PathExt;let path_str = path.to_slash_lossy();if !txn_.read().is_tracked(&path_str).unwrap() {Some(path_str.into_owned())} else {None} - replacement in crates/libflowers_client/src/cursor.rs at line 8
Channel,File { ix: usize, path: String },UntrackedFile { ix: usize, path: String },ChangedFile { ix: usize, path: String }, - edit in crates/libflowers_client/Cargo.toml at line 18
[dependencies.canonical-path]workspace = true - edit in crates/libflowers_client/Cargo.toml at line 21
workspace = true[dependencies.path-slash] - edit in crates/flowers_ui/src/main.rs at line 24[4.1181]→[8.468:514](∅→∅),[8.514]→[5.5009:5041](∅→∅),[5.5009]→[5.5009:5041](∅→∅),[5.5041]→[6.538:581](∅→∅)
let repo = repo::load(repo_path.clone());// dbg!(repo::diff(&repo));let cursor = cursor::State::default(); - replacement in crates/flowers_ui/src/main.rs at line 46
fs_watch.watch(repo_path, RecursiveMode::Recursive).unwrap();fs_watch.watch(&repo_path, RecursiveMode::Recursive).unwrap(); - edit in crates/flowers_ui/src/main.rs at line 52
let repo = repo::load(repo_path);// dbg!(repo::diff(&repo));let cursor = cursor::State::default(); - replacement in crates/flowers_ui/src/main.rs at line 58
fs_watch,_fs_watch: fs_watch, - replacement in crates/flowers_ui/src/main.rs at line 68
fs_watch: Debouncer<RecommendedWatcher, RecommendedCache>,_fs_watch: Debouncer<RecommendedWatcher, RecommendedCache>, - replacement in crates/flowers_ui/src/main.rs at line 86
let changed_file_path =|ix| state.repo.changed_files.iter().nth(ix).unwrap().clone();let untracked_file_selection = |ix: usize| -> cursor::Selection {let path = state.repo.untracked_files.iter().nth(ix).unwrap().clone();cursor::Selection::UntrackedFile { ix, path }};let changed_file_selection = |ix: usize| -> cursor::Selection {let path = state.repo.changed_files.iter().nth(ix).unwrap().clone();cursor::Selection::ChangedFile { ix, path }}; - edit in crates/flowers_ui/src/main.rs at line 98
// Re-index cursor selectionif let Some(selection) = state.cursor.selection.as_ref() {// Try to find the file with the same name. If not found, remove// selectionstate.cursor.selection = match selection {cursor::Selection::UntrackedFile { ix: _, path } => state.repo.untracked_files.iter().enumerate().find(|(_ix, file_path)| *file_path == path).map(|(ix, path)| cursor::Selection::UntrackedFile {ix,path: path.clone(),}),cursor::Selection::ChangedFile { ix: _, path } => state.repo.changed_files.iter().enumerate().find(|(_ix, file_path)| *file_path == path).map(|(ix, path)| cursor::Selection::ChangedFile {ix,path: path.clone(),}),};} - replacement in crates/flowers_ui/src/main.rs at line 127
state.cursor.selection =Some(match state.cursor.selection.as_ref() {Some(cursor::Selection::Channel) => {if state.repo.changed_files.is_empty() {cursor::Selection::Channelstate.cursor.selection = match state.cursor.selection.as_ref() {Some(cursor::Selection::UntrackedFile { ix, path: _ }) => {let new_selection =if state.repo.untracked_files.len().saturating_sub(1)== *ix{if state.repo.changed_files.is_empty() {let ix = 0;untracked_file_selection(ix)} else {let ix = 0;changed_file_selection(ix)} - replacement in crates/flowers_ui/src/main.rs at line 141[6.1100]→[7.161:328](∅→∅),[7.328]→[6.1155:1203](∅→∅),[6.1155]→[6.1155:1203](∅→∅),[6.1203]→[7.329:400](∅→∅)
let ix = 0;let path = changed_file_path(ix);cursor::Selection::File { ix, path }}}Some(cursor::Selection::File { ix, path: _ }) => {let ix = ix + 1;untracked_file_selection(ix)};Some(new_selection)}Some(cursor::Selection::ChangedFile { ix, path: _ }) => {let new_selection = - replacement in crates/flowers_ui/src/main.rs at line 151
cursor::Selection::Channelif state.repo.untracked_files.is_empty() {let ix = 0;changed_file_selection(ix)} else {let ix = 0;untracked_file_selection(ix)} - replacement in crates/flowers_ui/src/main.rs at line 160
let path = changed_file_path(ix);cursor::Selection::File { ix, path }changed_file_selection(ix)};Some(new_selection)}None => {if state.repo.untracked_files.is_empty() {if state.repo.changed_files.is_empty() {None} else {let ix = 0;Some(changed_file_selection(ix)) - edit in crates/flowers_ui/src/main.rs at line 172
} else {let ix = 0;Some(untracked_file_selection(ix)) - replacement in crates/flowers_ui/src/main.rs at line 176
None => cursor::Selection::Channel,})}} - replacement in crates/flowers_ui/src/main.rs at line 180
state.cursor.selection =Some(match state.cursor.selection.as_ref() {Some(cursor::Selection::Channel) | None => {state.cursor.selection = match state.cursor.selection.as_ref() {Some(cursor::Selection::UntrackedFile { ix, path: _ }) => {let new_selection = if 0 == *ix { - replacement in crates/flowers_ui/src/main.rs at line 184
cursor::Selection::Channellet ix = state.repo.untracked_files.len() - 1;untracked_file_selection(ix) - replacement in crates/flowers_ui/src/main.rs at line 188
let path = changed_file_path(ix);cursor::Selection::File { ix, path }changed_file_selection(ix) - replacement in crates/flowers_ui/src/main.rs at line 190[6.2204]→[6.2204:2226](∅→∅),[6.2226]→[7.775:846](∅→∅),[7.846]→[6.2285:2378](∅→∅),[6.2285]→[6.2285:2378](∅→∅)
}Some(cursor::Selection::File { ix, path: _ }) => {if 0 == *ix {cursor::Selection::Channel} else {let ix = ix - 1;untracked_file_selection(ix)};Some(new_selection)}Some(cursor::Selection::ChangedFile { ix, path: _ }) => {let new_selection = if 0 == *ix {if state.repo.untracked_files.is_empty() {let ix = state.repo.changed_files.len() - 1;changed_file_selection(ix) - replacement in crates/flowers_ui/src/main.rs at line 202
let ix = *ix - 1;let path = changed_file_path(ix);cursor::Selection::File { ix, path }let ix = state.repo.untracked_files.len() - 1;untracked_file_selection(ix)}} else {let ix = ix - 1;changed_file_selection(ix)};Some(new_selection)}None => {if state.repo.changed_files.is_empty() {if state.repo.untracked_files.is_empty() {None} else {let ix = state.repo.untracked_files.len() - 1;Some(untracked_file_selection(ix)) - edit in crates/flowers_ui/src/main.rs at line 219
} else {let ix = state.repo.changed_files.len() - 1;Some(changed_file_selection(ix)) - replacement in crates/flowers_ui/src/main.rs at line 223
})}} - edit in crates/flowers_ui/src/main.rs at line 254
let is_channel_selected = matches!(state.cursor.selection.as_ref(),Some(cursor::Selection::Channel)); - replacement in crates/flowers_ui/src/main.rs at line 258
button(text(channel)).on_press(Message::CursorSelect(cursor::Selection::Channel)).style(selectable_button_style(is_channel_selected)),button(text(channel)), /* TODO* .on_press(Message) */ - edit in crates/flowers_ui/src/main.rs at line 263
let untracked_files =Element::from(column(state.repo.untracked_files.iter().enumerate().map(|(ix, path)| {let is_selected = matches!(state.cursor.selection.as_ref() ,Some(cursor::Selection::UntrackedFile{ix: selected_ix, path:_}) if &ix == selected_ix);Element::from(button(text(path)).on_press(Message::CursorSelect(cursor::Selection::UntrackedFile{ix, path: path.clone()},)).style(selectable_button_style(is_selected)),)},))); - replacement in crates/flowers_ui/src/main.rs at line 283
Some(cursor::Selection::File{ix: selected_ix, path:_}) if &ix == selected_ixSome(cursor::Selection::ChangedFile{ix: selected_ix, path:_}) if &ix == selected_ix - replacement in crates/flowers_ui/src/main.rs at line 288
cursor::Selection::File{ix, path: path.clone()},cursor::Selection::ChangedFile{ix, path: path.clone()}, - edit in crates/flowers_ui/src/main.rs at line 305
Element::from(horizontal_rule(1)),Element::from(text("Untracked:")),untracked_files, - edit in crates/flowers_ui/src/main.rs at line 309
Element::from(text("Changed:")), - edit in Cargo.toml at line 23
[workspace.dependencies.canonical-path]version = "2.0" - edit in Cargo.toml at line 38
[workspace.dependencies.path-slash]version = "0.2" - edit in Cargo.lock at line 2163
"canonical-path", - edit in Cargo.lock at line 2166
"path-slash 0.2.1", - replacement in Cargo.lock at line 2216
"path-slash","path-slash 0.1.5", - edit in Cargo.lock at line 2902
[[package]]name = "path-slash"version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42"