Separate repository state synchronization from worktree synchronization (#27140)
This PR updates our DB schemas and wire protocol to separate the synchronization of git statuses and other repository state from the synchronization of worktrees. This paves the way for moving the code that executes git status updates out of the `worktree` crate and onto the new `GitStore`. That end goal is motivated by two (related) points: - Disentangling git status updates from the worktree's `BackgroundScanner` will allow us to implement a simpler concurrency story for those updates, hopefully fixing some known but elusive bugs (upstream state not updating after push; statuses getting out of sync in remote projects). - By moving git repository state to the project-scoped `GitStore`, we can get rid of the duplication that currently happens when two worktrees are associated with the same git repository. Co-authored-by: Max <max@zed.dev> 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
700af63c45
commit
bc1c0a2297
21 changed files with 1147 additions and 535 deletions
|
@ -18,6 +18,7 @@ use parking_lot::Mutex;
|
|||
use postage::stream::Stream;
|
||||
use pretty_assertions::assert_eq;
|
||||
use rand::prelude::*;
|
||||
use rpc::proto::WorktreeRelatedMessage;
|
||||
use serde_json::json;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::{
|
||||
|
@ -1748,7 +1749,12 @@ async fn test_random_worktree_operations_during_initial_scan(
|
|||
for (i, snapshot) in snapshots.into_iter().enumerate().rev() {
|
||||
let mut updated_snapshot = snapshot.clone();
|
||||
for update in updates.lock().iter() {
|
||||
if update.scan_id >= updated_snapshot.scan_id() as u64 {
|
||||
let scan_id = match update {
|
||||
WorktreeRelatedMessage::UpdateWorktree(update) => update.scan_id,
|
||||
WorktreeRelatedMessage::UpdateRepository(update) => update.scan_id,
|
||||
WorktreeRelatedMessage::RemoveRepository(_) => u64::MAX,
|
||||
};
|
||||
if scan_id >= updated_snapshot.scan_id() as u64 {
|
||||
updated_snapshot
|
||||
.apply_remote_update(update.clone(), &settings.file_scan_inclusions)
|
||||
.unwrap();
|
||||
|
@ -1885,7 +1891,12 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng)
|
|||
|
||||
for (i, mut prev_snapshot) in snapshots.into_iter().enumerate().rev() {
|
||||
for update in updates.lock().iter() {
|
||||
if update.scan_id >= prev_snapshot.scan_id() as u64 {
|
||||
let scan_id = match update {
|
||||
WorktreeRelatedMessage::UpdateWorktree(update) => update.scan_id,
|
||||
WorktreeRelatedMessage::UpdateRepository(update) => update.scan_id,
|
||||
WorktreeRelatedMessage::RemoveRepository(_) => u64::MAX,
|
||||
};
|
||||
if scan_id >= prev_snapshot.scan_id() as u64 {
|
||||
prev_snapshot
|
||||
.apply_remote_update(update.clone(), &settings.file_scan_inclusions)
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue