diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 1e7387fe6..9ef0bf628 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -244,22 +244,6 @@ content_hash! { } } -impl OperationMetadata { - pub fn new(description: String, start_time: Timestamp) -> Self { - let end_time = Timestamp::now(); - let hostname = whoami::hostname(); - let username = whoami::username(); - OperationMetadata { - start_time, - end_time, - description, - hostname, - username, - tags: Default::default(), - } - } -} - #[derive(Debug, Error)] pub enum OpStoreError { #[error("Operation not found")] diff --git a/lib/src/repo.rs b/lib/src/repo.rs index ce1521f5c..4a2e70220 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -33,9 +33,7 @@ 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, OperationMetadata, RefTarget, WorkspaceId, -}; +use crate::op_store::{BranchTarget, OpStore, OperationId, RefTarget, WorkspaceId}; use crate::operation::Operation; use crate::rewrite::DescendantRebaser; use crate::settings::{RepoSettings, UserSettings}; @@ -139,7 +137,7 @@ impl ReadonlyRepo { let op_heads_path = repo_path.join("op_heads"); fs::create_dir(&op_heads_path).context(&op_heads_path)?; let operation_metadata = - OperationMetadata::new("initialize repo".to_string(), Timestamp::now()); + crate::transaction::create_op_metadata(Timestamp::now(), "initialize repo".to_string()); 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); diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 04b35d971..acfa1ee05 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -97,7 +97,7 @@ impl Transaction { let view_id = base_repo.op_store().write_view(view.store_view()).unwrap(); let mut operation_metadata = - OperationMetadata::new(self.description.clone(), self.start_time.clone()); + create_op_metadata(self.start_time.clone(), self.description.clone()); operation_metadata.tags = self.tags.clone(); let parents = self.parent_ops.iter().map(|op| op.id().clone()).collect(); let store_operation = op_store::Operation { @@ -119,6 +119,20 @@ impl Transaction { } } +pub fn create_op_metadata(start_time: Timestamp, description: String) -> OperationMetadata { + let end_time = Timestamp::now(); + let hostname = whoami::hostname(); + let username = whoami::username(); + OperationMetadata { + start_time, + end_time, + description, + hostname, + username, + tags: Default::default(), + } +} + struct NewRepoData { operation: Operation, view: View,