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<Store>`, but I'm trying to change that.
This commit is contained in:
Martin von Zweigbergk 2023-01-28 22:36:00 -08:00 committed by Martin von Zweigbergk
parent 3d965f22ab
commit 5fecb396aa

View file

@ -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),
}
}