mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-15 08:40:15 +03:00
repo: move creation of OpStore out of View
We want to support loading the repo at a specific operation without first loading the head operation (like we currently do). One reason for that is of course efficiency. A possibly more important reason is that the head operation may be conflicted, depending on how we decide to deal with operation-level conflicts. In order to do that, it makes sense to move the creation of the `OpStore` outside of the `View`. That also suggests that the `.jj/view/op_store/` directory should move to `.jj/op_store/`, so this patch also does that. That's consistent with how `.jj/store/` is outside of `.jj/working_copy/`.
This commit is contained in:
parent
e2e9fe8f0d
commit
5a32118af1
@ -26,8 +26,10 @@ use crate::evolution::{EvolutionRef, MutableEvolution, ReadonlyEvolution};
|
||||
use crate::git_store::GitStore;
|
||||
use crate::index::{IndexRef, MutableIndex, ReadonlyIndex};
|
||||
use crate::local_store::LocalStore;
|
||||
use crate::op_store::OpStore;
|
||||
use crate::operation::Operation;
|
||||
use crate::settings::{RepoSettings, UserSettings};
|
||||
use crate::simple_op_store::SimpleOpStore;
|
||||
use crate::store;
|
||||
use crate::store::{Store, StoreError};
|
||||
use crate::store_wrapper::StoreWrapper;
|
||||
@ -191,8 +193,12 @@ impl ReadonlyRepo {
|
||||
is_pruned: false,
|
||||
};
|
||||
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 view = ReadonlyView::init(
|
||||
store.clone(),
|
||||
op_store,
|
||||
repo_path.join("view"),
|
||||
checkout_commit.id().clone(),
|
||||
);
|
||||
@ -254,7 +260,8 @@ impl ReadonlyRepo {
|
||||
wc_path.clone(),
|
||||
repo_path.join("working_copy"),
|
||||
);
|
||||
let view = ReadonlyView::load(store.clone(), repo_path.join("view"));
|
||||
let op_store: Arc<dyn OpStore> = Arc::new(SimpleOpStore::load(repo_path.join("op_store")));
|
||||
let view = ReadonlyView::load(store.clone(), op_store, repo_path.join("view"));
|
||||
let repo = ReadonlyRepo {
|
||||
repo_path,
|
||||
wc_path,
|
||||
|
@ -26,7 +26,6 @@ use crate::lock::FileLock;
|
||||
use crate::op_store;
|
||||
use crate::op_store::{OpStore, OpStoreResult, OperationId, OperationMetadata};
|
||||
use crate::operation::Operation;
|
||||
use crate::simple_op_store::SimpleOpStore;
|
||||
use crate::store::{CommitId, Timestamp};
|
||||
use crate::store_wrapper::StoreWrapper;
|
||||
|
||||
@ -361,10 +360,12 @@ fn merge_op_heads(
|
||||
}
|
||||
|
||||
impl ReadonlyView {
|
||||
pub fn init(store: Arc<StoreWrapper>, path: PathBuf, checkout: CommitId) -> Self {
|
||||
std::fs::create_dir(path.join("op_store")).unwrap();
|
||||
|
||||
let op_store = Arc::new(SimpleOpStore::init(path.join("op_store")));
|
||||
pub fn init(
|
||||
store: Arc<StoreWrapper>,
|
||||
op_store: Arc<dyn OpStore>,
|
||||
path: PathBuf,
|
||||
checkout: CommitId,
|
||||
) -> Self {
|
||||
let mut root_view = op_store::View::new(checkout.clone());
|
||||
root_view.head_ids.insert(checkout);
|
||||
let root_view_id = op_store.write_view(&root_view).unwrap();
|
||||
@ -389,8 +390,7 @@ impl ReadonlyView {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load(store: Arc<StoreWrapper>, path: PathBuf) -> Self {
|
||||
let op_store: Arc<dyn OpStore> = Arc::new(SimpleOpStore::load(path.join("op_store")));
|
||||
pub fn load(store: Arc<StoreWrapper>, op_store: Arc<dyn OpStore>, path: PathBuf) -> Self {
|
||||
let op_heads_dir = path.join("op_heads");
|
||||
let (op_id, _operation, view) =
|
||||
get_single_op_head(&store, &op_store, &op_heads_dir).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user