Move repository state RPC handlers to the GitStore (#27391)
This is another in the series of PRs to make the GitStore own all repository state and enable better concurrency control for git repository scans. After this PR, the `RepositoryEntry`s stored in worktree snapshots are used only as a staging ground for local GitStores to pull from after git-related events; non-local worktrees don't store them at all, although this is not reflected in the types. GitTraversal and other places that need information about repositories get it from the GitStore. The GitStore also takes over handling of the new UpdateRepository and RemoveRepository messages. However, repositories are still discovered and scanned on a per-worktree basis, and we're still identifying them by the (worktree-specific) project entry ID of their working directory. - [x] Remove WorkDirectory from RepositoryEntry - [x] Remove worktree IDs from repository-related RPC messages - [x] Handle UpdateRepository and RemoveRepository RPCs from the GitStore Release Notes: - N/A --------- Co-authored-by: Max <max@zed.dev> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
1e8b50f471
commit
6924720b35
22 changed files with 1387 additions and 1399 deletions
|
@ -793,31 +793,6 @@ pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
|
|||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum WorktreeRelatedMessage {
|
||||
UpdateWorktree(UpdateWorktree),
|
||||
UpdateRepository(UpdateRepository),
|
||||
RemoveRepository(RemoveRepository),
|
||||
}
|
||||
|
||||
impl From<UpdateWorktree> for WorktreeRelatedMessage {
|
||||
fn from(value: UpdateWorktree) -> Self {
|
||||
Self::UpdateWorktree(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UpdateRepository> for WorktreeRelatedMessage {
|
||||
fn from(value: UpdateRepository) -> Self {
|
||||
Self::UpdateRepository(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RemoveRepository> for WorktreeRelatedMessage {
|
||||
fn from(value: RemoveRepository) -> Self {
|
||||
Self::RemoveRepository(value)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
|
||||
let mut done = false;
|
||||
|
||||
|
@ -924,20 +899,6 @@ pub fn split_repository_update(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn split_worktree_related_message(
|
||||
message: WorktreeRelatedMessage,
|
||||
) -> Box<dyn Iterator<Item = WorktreeRelatedMessage> + Send> {
|
||||
match message {
|
||||
WorktreeRelatedMessage::UpdateWorktree(message) => {
|
||||
Box::new(split_worktree_update(message).map(WorktreeRelatedMessage::UpdateWorktree))
|
||||
}
|
||||
WorktreeRelatedMessage::UpdateRepository(message) => {
|
||||
Box::new(split_repository_update(message).map(WorktreeRelatedMessage::UpdateRepository))
|
||||
}
|
||||
WorktreeRelatedMessage::RemoveRepository(update) => Box::new([update.into()].into_iter()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue