repo: pass in OperationMetadata to OpHeadsStore::init()

Just a little refactoring to prepare for being able to get the
username and hostname from config.
This commit is contained in:
Martin von Zweigbergk 2022-11-12 17:53:52 -08:00 committed by Martin von Zweigbergk
parent e0fe3ffd7d
commit 9f0ae4586b
2 changed files with 9 additions and 6 deletions

View file

@ -19,7 +19,6 @@ use std::sync::Arc;
use itertools::Itertools;
use thiserror::Error;
use crate::backend::Timestamp;
use crate::lock::FileLock;
use crate::op_store::{OpStore, OperationId, OperationMetadata};
use crate::operation::Operation;
@ -68,10 +67,9 @@ impl OpHeadsStore {
dir: PathBuf,
op_store: &Arc<dyn OpStore>,
root_view: &op_store::View,
operation_metadata: OperationMetadata,
) -> (Self, Operation) {
let root_view_id = op_store.write_view(root_view).unwrap();
let operation_metadata =
OperationMetadata::new("initialize repo".to_string(), Timestamp::now());
let init_operation = op_store::Operation {
view_id: root_view_id,
parents: vec![],

View file

@ -24,7 +24,7 @@ use once_cell::sync::OnceCell;
use thiserror::Error;
use self::dirty_cell::DirtyCell;
use crate::backend::{Backend, BackendError, ChangeId, CommitId};
use crate::backend::{Backend, BackendError, ChangeId, CommitId, Timestamp};
use crate::commit::Commit;
use crate::commit_builder::CommitBuilder;
use crate::dag_walk::topo_order_reverse;
@ -33,7 +33,9 @@ use crate::index::{IndexRef, MutableIndex, ReadonlyIndex};
use crate::index_store::IndexStore;
use crate::local_backend::LocalBackend;
use crate::op_heads_store::{LockedOpHeads, OpHeads, OpHeadsStore};
use crate::op_store::{BranchTarget, OpStore, OperationId, RefTarget, WorkspaceId};
use crate::op_store::{
BranchTarget, OpStore, OperationId, OperationMetadata, RefTarget, WorkspaceId,
};
use crate::operation::Operation;
use crate::rewrite::DescendantRebaser;
use crate::settings::{RepoSettings, UserSettings};
@ -136,7 +138,10 @@ impl ReadonlyRepo {
let op_heads_path = repo_path.join("op_heads");
fs::create_dir(&op_heads_path).context(&op_heads_path)?;
let (op_heads_store, init_op) = OpHeadsStore::init(op_heads_path, &op_store, &root_view);
let operation_metadata =
OperationMetadata::new("initialize repo".to_string(), Timestamp::now());
let (op_heads_store, init_op) =
OpHeadsStore::init(op_heads_path, &op_store, &root_view, operation_metadata);
let op_heads_store = Arc::new(op_heads_store);
let index_path = repo_path.join("index");