first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+26 -20
View File
@@ -1,15 +1,21 @@
mod file_tree_state;
use std::sync::Arc;
use ignore::gitignore::Gitignore;
use galaxy_util::standardized_path::StandardizedPath;
use galaxyui_core::ModelHandle;
use crate::file_tree_store::file_tree_state::FileTreeMapStore;
use crate::{BuildTreeError, Entry, FileId, FileMetadata, Repository};
use galaxy_util::standardized_path::StandardizedPath;
use galaxyui::ModelHandle;
use ignore::gitignore::Gitignore;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct FileTreeEntry {
state_map: FileTreeMapStore,
// Wrapped in an `Arc` so cloning a `FileTreeEntry` is O(1) (a refcount
// bump) instead of deep-copying the whole tree. Mutations go through
// `Arc::make_mut`, which copies-on-write only when the store is actually
// shared with another holder (e.g. the model and a view).
state_map: Arc<FileTreeMapStore>,
root_path: Arc<StandardizedPath>,
}
@@ -38,7 +44,7 @@ impl FileTreeEntry {
}
pub fn rename_path(&mut self, path: &StandardizedPath, new_path: &StandardizedPath) -> bool {
self.state_map.rename_path(path, new_path)
Arc::make_mut(&mut self.state_map).rename_path(path, new_path)
}
pub fn load_at_path(
@@ -46,11 +52,11 @@ impl FileTreeEntry {
path: &StandardizedPath,
gitignores: &mut Vec<Gitignore>,
) -> Result<(), BuildTreeError> {
self.state_map.load_at_path(path, gitignores)
Arc::make_mut(&mut self.state_map).load_at_path(path, gitignores)
}
pub fn insert_entry_at_path(&mut self, path: Arc<StandardizedPath>, entry: Entry) {
self.state_map.insert_entry_at_path(path, entry);
Arc::make_mut(&mut self.state_map).insert_entry_at_path(path, entry);
}
pub fn child_paths(
@@ -61,16 +67,16 @@ impl FileTreeEntry {
}
pub fn get_mut(&mut self, path: &StandardizedPath) -> Option<&mut FileTreeEntryState> {
self.state_map.get_mut(path)
Arc::make_mut(&mut self.state_map).get_mut(path)
}
pub fn remove(&mut self, path: &StandardizedPath) {
self.state_map.remove(path);
Arc::make_mut(&mut self.state_map).remove(path);
}
pub fn new_for_directory(root_path: Arc<StandardizedPath>) -> Self {
Self {
state_map: FileTreeMapStore::new_for_directory(root_path.clone()),
state_map: Arc::new(FileTreeMapStore::new_for_directory(root_path.clone())),
root_path,
}
}
@@ -82,8 +88,10 @@ impl FileTreeEntry {
parent_path: &StandardizedPath,
target_path: &StandardizedPath,
) -> Option<&mut FileTreeEntryState> {
// `contains_child` is a read, so check it before `make_mut` to avoid
// a copy-on-write when the child already exists.
if self.state_map.contains_child(parent_path, target_path) {
return self.state_map.get_mut(target_path);
return Arc::make_mut(&mut self.state_map).get_mut(target_path);
}
// Child not found, create new directory entry
@@ -93,9 +101,9 @@ impl FileTreeEntry {
loaded: false,
});
self.state_map
.insert_child(Arc::new(parent_path.clone()), new_entry);
self.state_map.get_mut(target_path)
let store = Arc::make_mut(&mut self.state_map);
store.insert_child(Arc::new(parent_path.clone()), new_entry);
store.get_mut(target_path)
}
pub fn find_parent_directory(&self, path: &StandardizedPath) -> Option<Arc<StandardizedPath>> {
@@ -130,8 +138,7 @@ impl FileTreeEntry {
return None;
};
self.state_map
.insert_child(Arc::new(parent_path.clone()), new_entry)
Arc::make_mut(&mut self.state_map).insert_child(Arc::new(parent_path.clone()), new_entry)
}
pub fn insert_child_state(
@@ -139,8 +146,7 @@ impl FileTreeEntry {
parent_path: &StandardizedPath,
child_state: FileTreeEntryState,
) -> Option<Arc<StandardizedPath>> {
self.state_map
.insert_child(Arc::new(parent_path.clone()), child_state)
Arc::make_mut(&mut self.state_map).insert_child(Arc::new(parent_path.clone()), child_state)
}
/// Ensures all ancestor directories between root and `target_parent`
@@ -339,7 +345,7 @@ pub struct FileTreeDirectoryEntryState {
impl From<Entry> for FileTreeEntry {
fn from(value: Entry) -> Self {
let root_path = Arc::new(value.path().clone());
let state_map = FileTreeMapStore::from(value);
let state_map = Arc::new(FileTreeMapStore::from(value));
FileTreeEntry {
state_map,