repo: move creation of directories .jj/* directories closer and earlier

This commit is contained in:
Martin von Zweigbergk 2021-10-13 22:37:30 -07:00
parent ca796b49f0
commit dba72af857

View File

@ -186,6 +186,11 @@ impl ReadonlyRepo {
Err(RepoInitError::DestinationExists(repo_path)) Err(RepoInitError::DestinationExists(repo_path))
} else { } else {
fs::create_dir(&repo_path).unwrap(); fs::create_dir(&repo_path).unwrap();
fs::create_dir(repo_path.join("working_copy")).unwrap();
fs::create_dir(repo_path.join("view")).unwrap();
fs::create_dir(repo_path.join("op_store")).unwrap();
fs::create_dir(repo_path.join("op_heads")).unwrap();
fs::create_dir(repo_path.join("index")).unwrap();
Ok(repo_path) Ok(repo_path)
} }
} }
@ -199,14 +204,12 @@ impl ReadonlyRepo {
let repo_settings = user_settings.with_repo(&repo_path).unwrap(); let repo_settings = user_settings.with_repo(&repo_path).unwrap();
let store = Store::new(backend); let store = Store::new(backend);
fs::create_dir(repo_path.join("working_copy")).unwrap();
let working_copy = WorkingCopy::init( let working_copy = WorkingCopy::init(
store.clone(), store.clone(),
wc_path.clone(), wc_path.clone(),
repo_path.join("working_copy"), repo_path.join("working_copy"),
); );
fs::create_dir(repo_path.join("view")).unwrap();
let signature = signature(user_settings); let signature = signature(user_settings);
let checkout_commit = backend::Commit { let checkout_commit = backend::Commit {
parents: vec![], parents: vec![],
@ -220,20 +223,17 @@ impl ReadonlyRepo {
}; };
let checkout_commit = store.write_commit(checkout_commit); let checkout_commit = store.write_commit(checkout_commit);
std::fs::create_dir(repo_path.join("op_store")).unwrap();
let op_store: Arc<dyn OpStore> = Arc::new(SimpleOpStore::init(repo_path.join("op_store"))); let op_store: Arc<dyn OpStore> = Arc::new(SimpleOpStore::init(repo_path.join("op_store")));
let op_heads_dir = repo_path.join("op_heads");
std::fs::create_dir(&op_heads_dir).unwrap();
let mut root_view = op_store::View::new(checkout_commit.id().clone()); let mut root_view = op_store::View::new(checkout_commit.id().clone());
root_view.head_ids.insert(checkout_commit.id().clone()); root_view.head_ids.insert(checkout_commit.id().clone());
root_view root_view
.public_head_ids .public_head_ids
.insert(store.root_commit_id().clone()); .insert(store.root_commit_id().clone());
let (op_heads_store, init_op) = OpHeadsStore::init(op_heads_dir, &op_store, &root_view); let (op_heads_store, init_op) =
OpHeadsStore::init(repo_path.join("op_heads"), &op_store, &root_view);
let op_heads_store = Arc::new(op_heads_store); let op_heads_store = Arc::new(op_heads_store);
fs::create_dir(repo_path.join("index")).unwrap();
let index_store = Arc::new(IndexStore::init(repo_path.join("index"))); let index_store = Arc::new(IndexStore::init(repo_path.join("index")));
let view = View::new(root_view); let view = View::new(root_view);