From 5fecb396aa27006eeb58a30fc7da256872bc8b99 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 28 Jan 2023 22:36:00 -0800 Subject: [PATCH] working_copy: write tree_state file on init I don't think there's a good reason not to write the `.jj/working_copy/tree_state` file on init. Being able to assume that the file exists means that we won't need the store object to to lazily load the `TreeState` object. Well, except that `TreeState` keeps an `Arc`, but I'm trying to change that. --- lib/src/working_copy.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index 681f7a8af..6bac9ee39 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -1035,12 +1035,14 @@ impl WorkingCopy { .open(state_path.join("checkout")) .unwrap(); file.write_all(&proto.encode_to_vec()).unwrap(); + let tree_state = + TreeState::init(store.clone(), working_copy_path.clone(), state_path.clone()); WorkingCopy { store, working_copy_path, state_path, checkout_state: OnceCell::new(), - tree_state: OnceCell::new(), + tree_state: OnceCell::with_value(tree_state), } }