From fa5e40719c97bbf4e51df88c1236292711eda1ae Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 4 Jan 2024 16:18:04 +0900 Subject: [PATCH] object_id: extract ObjectId trait and macros to separate module I'm going to add a prefix resolution method to OpStore, but OpStore is unrelated to the index. I think ObjectId, HexPrefix, and PrefixResolution can be extracted to this module. --- cli/src/cli_util.rs | 3 +- cli/src/commands/abandon.rs | 2 +- cli/src/commands/backout.rs | 2 +- cli/src/commands/branch.rs | 3 +- cli/src/commands/checkout.rs | 2 +- cli/src/commands/chmod.rs | 3 +- cli/src/commands/commit.rs | 2 +- cli/src/commands/debug.rs | 2 +- cli/src/commands/describe.rs | 2 +- cli/src/commands/diffedit.rs | 2 +- cli/src/commands/edit.rs | 2 +- cli/src/commands/git.rs | 3 +- cli/src/commands/move.rs | 2 +- cli/src/commands/operation.rs | 2 +- cli/src/commands/rebase.rs | 3 +- cli/src/commands/resolve.rs | 3 +- cli/src/commands/restore.rs | 2 +- cli/src/commands/split.rs | 2 +- cli/src/commands/squash.rs | 2 +- cli/src/commands/unsquash.rs | 2 +- cli/src/commands/workspace.rs | 2 +- cli/src/commit_templater.rs | 3 +- cli/src/diff_util.rs | 3 +- cli/src/merge_tools/builtin.rs | 3 +- cli/src/operation_templater.rs | 2 +- cli/tests/test_git_import_export.rs | 3 +- lib/src/backend.rs | 67 +---------------------- lib/src/default_index/composite.rs | 3 +- lib/src/default_index/entry.rs | 3 +- lib/src/default_index/mod.rs | 3 +- lib/src/default_index/mutable.rs | 3 +- lib/src/default_index/readonly.rs | 3 +- lib/src/default_index/store.rs | 3 +- lib/src/default_revset_engine.rs | 3 +- lib/src/git.rs | 3 +- lib/src/git_backend.rs | 5 +- lib/src/id_prefix.rs | 6 ++- lib/src/index.rs | 3 +- lib/src/lib.rs | 1 + lib/src/local_backend.rs | 5 +- lib/src/local_working_copy.rs | 3 +- lib/src/merge.rs | 3 +- lib/src/object_id.rs | 81 ++++++++++++++++++++++++++++ lib/src/op_store.rs | 3 +- lib/src/op_walk.rs | 2 +- lib/src/refs.rs | 2 +- lib/src/repo.rs | 3 +- lib/src/revset_graph.rs | 2 +- lib/src/rewrite.rs | 3 +- lib/src/settings.rs | 3 +- lib/src/simple_op_heads_store.rs | 2 +- lib/src/simple_op_store.rs | 6 ++- lib/src/tree.rs | 4 +- lib/tests/test_commit_builder.rs | 3 +- lib/tests/test_git.rs | 5 +- lib/tests/test_id_prefix.rs | 3 +- lib/tests/test_index.rs | 3 +- lib/tests/test_local_working_copy.rs | 3 +- lib/tests/test_operations.rs | 3 +- lib/tests/test_revset.rs | 3 +- lib/testutils/src/lib.rs | 3 +- lib/testutils/src/test_backend.rs | 3 +- 62 files changed, 187 insertions(+), 132 deletions(-) create mode 100644 lib/src/object_id.rs diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index ff8e4f304..a7a391c95 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -30,7 +30,7 @@ use clap::builder::{NonEmptyStringValueParser, TypedValueParser, ValueParserFact use clap::{Arg, ArgAction, ArgMatches, Command, FromArgMatches}; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; -use jj_lib::backend::{BackendError, ChangeId, CommitId, MergedTreeId, ObjectId}; +use jj_lib::backend::{BackendError, ChangeId, CommitId, MergedTreeId}; use jj_lib::commit::Commit; use jj_lib::git::{ FailedRefExport, FailedRefExportReason, GitConfigParseError, GitExportError, GitImportError, @@ -42,6 +42,7 @@ use jj_lib::hex_util::to_reverse_hex; use jj_lib::id_prefix::IdPrefixContext; use jj_lib::matchers::{EverythingMatcher, Matcher, PrefixMatcher}; use jj_lib::merged_tree::MergedTree; +use jj_lib::object_id::ObjectId; use jj_lib::op_heads_store::{self, OpHeadResolutionError}; use jj_lib::op_store::{OpStoreError, OperationId, WorkspaceId}; use jj_lib::op_walk::OpsetEvaluationError; diff --git a/cli/src/commands/abandon.rs b/cli/src/commands/abandon.rs index c5e86162e..7ff0fa517 100644 --- a/cli/src/commands/abandon.rs +++ b/cli/src/commands/abandon.rs @@ -14,7 +14,7 @@ use std::io::Write; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use tracing::instrument; use crate::cli_util::{ diff --git a/cli/src/commands/backout.rs b/cli/src/commands/backout.rs index 1e996ec1c..d8de61397 100644 --- a/cli/src/commands/backout.rs +++ b/cli/src/commands/backout.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::rewrite::back_out_commit; use tracing::instrument; diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index abdf3c560..d8a975f1c 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -19,8 +19,9 @@ use std::str::FromStr; use clap::builder::NonEmptyStringValueParser; use itertools::Itertools; -use jj_lib::backend::{CommitId, ObjectId}; +use jj_lib::backend::CommitId; use jj_lib::git; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::{RefTarget, RemoteRef}; use jj_lib::repo::Repo; use jj_lib::revset::{self, RevsetExpression}; diff --git a/cli/src/commands/checkout.rs b/cli/src/commands/checkout.rs index cb622e4b4..f1cb7b59a 100644 --- a/cli/src/commands/checkout.rs +++ b/cli/src/commands/checkout.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use tracing::instrument; use crate::cli_util::{join_message_paragraphs, CommandError, CommandHelper, RevisionArg}; diff --git a/cli/src/commands/chmod.rs b/cli/src/commands/chmod.rs index 4d7836854..955de020e 100644 --- a/cli/src/commands/chmod.rs +++ b/cli/src/commands/chmod.rs @@ -13,8 +13,9 @@ // limitations under the License. use itertools::Itertools; -use jj_lib::backend::{ObjectId, TreeValue}; +use jj_lib::backend::TreeValue; use jj_lib::merged_tree::MergedTreeBuilder; +use jj_lib::object_id::ObjectId; use tracing::instrument; use crate::cli_util::{user_error, CommandError, CommandHelper, RevisionArg}; diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index d41f87f0b..458e8593b 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::rewrite::merge_commit_trees; use tracing::instrument; diff --git a/cli/src/commands/debug.rs b/cli/src/commands/debug.rs index 548f33cf0..86e586d61 100644 --- a/cli/src/commands/debug.rs +++ b/cli/src/commands/debug.rs @@ -17,9 +17,9 @@ use std::fmt::Debug; use std::io::Write as _; use clap::Subcommand; -use jj_lib::backend::ObjectId; use jj_lib::default_index::{AsCompositeIndex as _, DefaultIndexStore, DefaultReadonlyIndex}; use jj_lib::local_working_copy::LocalWorkingCopy; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::working_copy::WorkingCopy; use jj_lib::{op_walk, revset}; diff --git a/cli/src/commands/describe.rs b/cli/src/commands/describe.rs index 1d1ae5039..a59da7c08 100644 --- a/cli/src/commands/describe.rs +++ b/cli/src/commands/describe.rs @@ -14,7 +14,7 @@ use std::io::{self, Read, Write}; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use tracing::instrument; use crate::cli_util::{join_message_paragraphs, CommandError, CommandHelper, RevisionArg}; diff --git a/cli/src/commands/diffedit.rs b/cli/src/commands/diffedit.rs index 698b5163a..45acf1a48 100644 --- a/cli/src/commands/diffedit.rs +++ b/cli/src/commands/diffedit.rs @@ -14,8 +14,8 @@ use std::io::Write; -use jj_lib::backend::ObjectId; use jj_lib::matchers::EverythingMatcher; +use jj_lib::object_id::ObjectId; use jj_lib::rewrite::merge_commit_trees; use tracing::instrument; diff --git a/cli/src/commands/edit.rs b/cli/src/commands/edit.rs index 88c3a7010..2d3d92b83 100644 --- a/cli/src/commands/edit.rs +++ b/cli/src/commands/edit.rs @@ -14,7 +14,7 @@ use std::io::Write; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use tracing::instrument; use crate::cli_util::{CommandError, CommandHelper, RevisionArg}; diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index d98681d51..b9c3731f7 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -23,11 +23,12 @@ use std::{fmt, fs, io}; use clap::{ArgGroup, Subcommand}; use itertools::Itertools; -use jj_lib::backend::{ObjectId, TreeValue}; +use jj_lib::backend::TreeValue; use jj_lib::git::{ self, parse_gitmodules, GitBranchPushTargets, GitFetchError, GitFetchStats, GitPushError, }; use jj_lib::git_backend::GitBackend; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::RefTarget; use jj_lib::refs::{ classify_branch_push_action, BranchPushAction, BranchPushUpdate, TrackingRefPair, diff --git a/cli/src/commands/move.rs b/cli/src/commands/move.rs index c32107464..a2cf1de5a 100644 --- a/cli/src/commands/move.rs +++ b/cli/src/commands/move.rs @@ -13,7 +13,7 @@ // limitations under the License. use clap::ArgGroup; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::rewrite::merge_commit_trees; use tracing::instrument; diff --git a/cli/src/commands/operation.rs b/cli/src/commands/operation.rs index b5c8ebd1b..72da509a7 100644 --- a/cli/src/commands/operation.rs +++ b/cli/src/commands/operation.rs @@ -17,7 +17,7 @@ use std::slice; use clap::Subcommand; use itertools::Itertools as _; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::OperationId; use jj_lib::op_walk; use jj_lib::repo::Repo; diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index 6099d1f4e..437ed0c71 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -19,8 +19,9 @@ use std::sync::Arc; use clap::ArgGroup; use indexmap::IndexSet; use itertools::Itertools; -use jj_lib::backend::{CommitId, ObjectId}; +use jj_lib::backend::CommitId; use jj_lib::commit::Commit; +use jj_lib::object_id::ObjectId; use jj_lib::repo::{ReadonlyRepo, Repo}; use jj_lib::revset::{RevsetExpression, RevsetIteratorExt}; use jj_lib::rewrite::{rebase_commit, rebase_commit_with_options, EmptyBehaviour, RebaseOptions}; diff --git a/cli/src/commands/resolve.rs b/cli/src/commands/resolve.rs index 2ca605c73..3b00034aa 100644 --- a/cli/src/commands/resolve.rs +++ b/cli/src/commands/resolve.rs @@ -16,8 +16,9 @@ use std::collections::BTreeMap; use std::io::Write; use itertools::Itertools; -use jj_lib::backend::{ObjectId, TreeValue}; +use jj_lib::backend::TreeValue; use jj_lib::merge::MergedTreeValue; +use jj_lib::object_id::ObjectId; use jj_lib::repo_path::RepoPathBuf; use tracing::instrument; diff --git a/cli/src/commands/restore.rs b/cli/src/commands/restore.rs index cb83caa4a..e54fead8f 100644 --- a/cli/src/commands/restore.rs +++ b/cli/src/commands/restore.rs @@ -14,7 +14,7 @@ use std::io::Write; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::rewrite::{merge_commit_trees, restore_tree}; use tracing::instrument; diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index 21e78257f..3ed91afe5 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -13,7 +13,7 @@ // limitations under the License. use std::io::Write; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::rewrite::merge_commit_trees; use tracing::instrument; diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index cd8123e7a..c470745fb 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -13,7 +13,7 @@ // limitations under the License. use clap::parser::ValueSource; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::revset; use tracing::instrument; diff --git a/cli/src/commands/unsquash.rs b/cli/src/commands/unsquash.rs index d0140b8ea..fe6d929d5 100644 --- a/cli/src/commands/unsquash.rs +++ b/cli/src/commands/unsquash.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use jj_lib::backend::ObjectId; use jj_lib::matchers::EverythingMatcher; +use jj_lib::object_id::ObjectId; use jj_lib::rewrite::merge_commit_trees; use tracing::instrument; diff --git a/cli/src/commands/workspace.rs b/cli/src/commands/workspace.rs index ac33a37f5..cd413a300 100644 --- a/cli/src/commands/workspace.rs +++ b/cli/src/commands/workspace.rs @@ -18,8 +18,8 @@ use std::io::Write; use clap::Subcommand; use itertools::Itertools; -use jj_lib::backend::ObjectId; use jj_lib::file_util; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::WorkspaceId; use jj_lib::repo::Repo; use jj_lib::rewrite::merge_commit_trees; diff --git a/cli/src/commit_templater.rs b/cli/src/commit_templater.rs index 26c948789..50e28ecc8 100644 --- a/cli/src/commit_templater.rs +++ b/cli/src/commit_templater.rs @@ -18,10 +18,11 @@ use std::io; use std::rc::Rc; use itertools::Itertools as _; -use jj_lib::backend::{ChangeId, CommitId, ObjectId as _}; +use jj_lib::backend::{ChangeId, CommitId}; use jj_lib::commit::Commit; use jj_lib::hex_util::to_reverse_hex; use jj_lib::id_prefix::IdPrefixContext; +use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::{RefTarget, WorkspaceId}; use jj_lib::repo::Repo; use jj_lib::{git, rewrite}; diff --git a/cli/src/diff_util.rs b/cli/src/diff_util.rs index f168565f9..4e7239eb1 100644 --- a/cli/src/diff_util.rs +++ b/cli/src/diff_util.rs @@ -19,7 +19,7 @@ use std::ops::Range; use futures::{try_join, Stream, StreamExt}; use itertools::Itertools; -use jj_lib::backend::{BackendResult, ObjectId, TreeValue}; +use jj_lib::backend::{BackendResult, TreeValue}; use jj_lib::commit::Commit; use jj_lib::conflicts::{materialize_tree_value, MaterializedTreeValue}; use jj_lib::diff::{Diff, DiffHunk}; @@ -27,6 +27,7 @@ use jj_lib::files::DiffLine; use jj_lib::matchers::Matcher; use jj_lib::merge::MergedTreeValue; use jj_lib::merged_tree::{MergedTree, TreeDiffStream}; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::repo_path::{RepoPath, RepoPathBuf}; use jj_lib::settings::{ConfigResultExt as _, UserSettings}; diff --git a/cli/src/merge_tools/builtin.rs b/cli/src/merge_tools/builtin.rs index 5a65aab61..52bcfd6bb 100644 --- a/cli/src/merge_tools/builtin.rs +++ b/cli/src/merge_tools/builtin.rs @@ -4,12 +4,13 @@ use std::sync::Arc; use futures::{StreamExt, TryStreamExt}; use itertools::Itertools; -use jj_lib::backend::{BackendError, FileId, MergedTreeId, ObjectId, TreeValue}; +use jj_lib::backend::{BackendError, FileId, MergedTreeId, TreeValue}; use jj_lib::diff::{find_line_ranges, Diff, DiffHunk}; use jj_lib::files::{self, ContentHunk, MergeResult}; use jj_lib::matchers::Matcher; use jj_lib::merge::Merge; use jj_lib::merged_tree::{MergedTree, MergedTreeBuilder}; +use jj_lib::object_id::ObjectId; use jj_lib::repo_path::{RepoPath, RepoPathBuf}; use jj_lib::store::Store; use pollster::FutureExt; diff --git a/cli/src/operation_templater.rs b/cli/src/operation_templater.rs index d538ce76d..d000f331f 100644 --- a/cli/src/operation_templater.rs +++ b/cli/src/operation_templater.rs @@ -15,7 +15,7 @@ use std::io; use itertools::Itertools as _; -use jj_lib::backend::ObjectId; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::{OperationId, OperationMetadata}; use jj_lib::operation::Operation; use jj_lib::repo::ReadonlyRepo; diff --git a/cli/tests/test_git_import_export.rs b/cli/tests/test_git_import_export.rs index e5dd0dc63..d28bb2c03 100644 --- a/cli/tests/test_git_import_export.rs +++ b/cli/tests/test_git_import_export.rs @@ -14,7 +14,8 @@ use std::path::Path; use itertools::Itertools as _; -use jj_lib::backend::{CommitId, ObjectId as _}; +use jj_lib::backend::CommitId; +use jj_lib::object_id::ObjectId as _; use crate::common::TestEnvironment; diff --git a/lib/src/backend.rs b/lib/src/backend.rs index a6e99c4fd..47a4de0d1 100644 --- a/lib/src/backend.rs +++ b/lib/src/backend.rs @@ -26,75 +26,10 @@ use thiserror::Error; use crate::content_hash::ContentHash; use crate::merge::Merge; +use crate::object_id::{id_type, ObjectId}; use crate::repo_path::{RepoPath, RepoPathComponent, RepoPathComponentBuf}; use crate::signing::SignResult; -pub trait ObjectId { - fn new(value: Vec) -> Self; - fn object_type(&self) -> String; - fn from_bytes(bytes: &[u8]) -> Self; - fn as_bytes(&self) -> &[u8]; - fn to_bytes(&self) -> Vec; - fn from_hex(hex: &str) -> Self; - fn hex(&self) -> String; -} - -macro_rules! id_type { - ($vis:vis $name:ident) => { - content_hash! { - #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] - $vis struct $name(Vec); - } - $crate::backend::impl_id_type!($name); - }; -} - -macro_rules! impl_id_type { - ($name:ident) => { - impl std::fmt::Debug for $name { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - f.debug_tuple(stringify!($name)).field(&self.hex()).finish() - } - } - - impl crate::backend::ObjectId for $name { - fn new(value: Vec) -> Self { - Self(value) - } - - fn object_type(&self) -> String { - stringify!($name) - .strip_suffix("Id") - .unwrap() - .to_ascii_lowercase() - .to_string() - } - - fn from_bytes(bytes: &[u8]) -> Self { - Self(bytes.to_vec()) - } - - fn as_bytes(&self) -> &[u8] { - &self.0 - } - - fn to_bytes(&self) -> Vec { - self.0.clone() - } - - fn from_hex(hex: &str) -> Self { - Self(hex::decode(hex).unwrap()) - } - - fn hex(&self) -> String { - hex::encode(&self.0) - } - } - }; -} - -pub(crate) use {id_type, impl_id_type}; - id_type!(pub CommitId); id_type!(pub ChangeId); id_type!(pub TreeId); diff --git a/lib/src/default_index/composite.rs b/lib/src/default_index/composite.rs index ff41d4ee3..f4c41de11 100644 --- a/lib/src/default_index/composite.rs +++ b/lib/src/default_index/composite.rs @@ -26,8 +26,9 @@ use super::entry::{ }; use super::readonly::ReadonlyIndexSegment; use super::rev_walk::RevWalk; -use crate::backend::{ChangeId, CommitId, ObjectId}; +use crate::backend::{ChangeId, CommitId}; use crate::index::{HexPrefix, Index, PrefixResolution}; +use crate::object_id::ObjectId; use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError}; use crate::store::Store; use crate::{default_revset_engine, hex_util}; diff --git a/lib/src/default_index/entry.rs b/lib/src/default_index/entry.rs index be9623a63..ae9ed5084 100644 --- a/lib/src/default_index/entry.rs +++ b/lib/src/default_index/entry.rs @@ -20,7 +20,8 @@ use std::hash::{Hash, Hasher}; use smallvec::SmallVec; use super::composite::{CompositeIndex, IndexSegment}; -use crate::backend::{ChangeId, CommitId, ObjectId}; +use crate::backend::{ChangeId, CommitId}; +use crate::object_id::ObjectId; /// Global index position. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] diff --git a/lib/src/default_index/mod.rs b/lib/src/default_index/mod.rs index 5d092c1a1..7a3a10ba6 100644 --- a/lib/src/default_index/mod.rs +++ b/lib/src/default_index/mod.rs @@ -43,8 +43,9 @@ mod tests { use super::entry::SmallIndexPositionsVec; use super::mutable::MutableIndexSegment; use super::*; - use crate::backend::{ChangeId, CommitId, ObjectId}; + use crate::backend::{ChangeId, CommitId}; use crate::index::{HexPrefix, Index, PrefixResolution}; + use crate::object_id::ObjectId; /// Generator of unique 16-byte ChangeId excluding root id fn change_id_generator() -> impl FnMut() -> ChangeId { diff --git a/lib/src/default_index/mutable.rs b/lib/src/default_index/mutable.rs index 5ceda9db1..2342fca54 100644 --- a/lib/src/default_index/mutable.rs +++ b/lib/src/default_index/mutable.rs @@ -32,10 +32,11 @@ use tempfile::NamedTempFile; use super::composite::{AsCompositeIndex, CompositeIndex, IndexSegment}; use super::entry::{IndexPosition, LocalPosition, SmallIndexPositionsVec}; use super::readonly::{DefaultReadonlyIndex, ReadonlyIndexSegment}; -use crate::backend::{ChangeId, CommitId, ObjectId}; +use crate::backend::{ChangeId, CommitId}; use crate::commit::Commit; use crate::file_util::persist_content_addressed_temp_file; use crate::index::{HexPrefix, Index, MutableIndex, PrefixResolution, ReadonlyIndex}; +use crate::object_id::ObjectId; use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError}; use crate::store::Store; diff --git a/lib/src/default_index/readonly.rs b/lib/src/default_index/readonly.rs index 8c13d1e00..791847f99 100644 --- a/lib/src/default_index/readonly.rs +++ b/lib/src/default_index/readonly.rs @@ -29,9 +29,10 @@ use thiserror::Error; use super::composite::{AsCompositeIndex, CompositeIndex, IndexSegment}; use super::entry::{IndexPosition, LocalPosition, SmallIndexPositionsVec}; use super::mutable::DefaultMutableIndex; -use crate::backend::{ChangeId, CommitId, ObjectId}; +use crate::backend::{ChangeId, CommitId}; use crate::default_revset_engine; use crate::index::{HexPrefix, Index, MutableIndex, PrefixResolution, ReadonlyIndex}; +use crate::object_id::ObjectId; use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError}; use crate::store::Store; diff --git a/lib/src/default_index/store.rs b/lib/src/default_index/store.rs index 110752f09..a228d4028 100644 --- a/lib/src/default_index/store.rs +++ b/lib/src/default_index/store.rs @@ -27,13 +27,14 @@ use thiserror::Error; use super::mutable::DefaultMutableIndex; use super::readonly::{DefaultReadonlyIndex, ReadonlyIndexLoadError, ReadonlyIndexSegment}; -use crate::backend::{BackendError, BackendInitError, CommitId, ObjectId}; +use crate::backend::{BackendError, BackendInitError, CommitId}; use crate::commit::CommitByCommitterTimestamp; use crate::dag_walk; use crate::file_util::{persist_content_addressed_temp_file, IoResultExt as _, PathError}; use crate::index::{ Index, IndexReadError, IndexStore, IndexWriteError, MutableIndex, ReadonlyIndex, }; +use crate::object_id::ObjectId; use crate::op_store::{OpStoreError, OperationId}; use crate::operation::Operation; use crate::store::Store; diff --git a/lib/src/default_revset_engine.rs b/lib/src/default_revset_engine.rs index 940de2253..ed8cf505b 100644 --- a/lib/src/default_revset_engine.rs +++ b/lib/src/default_revset_engine.rs @@ -999,8 +999,9 @@ fn has_diff_from_parent( #[cfg(test)] mod tests { use super::*; - use crate::backend::{ChangeId, CommitId, ObjectId}; + use crate::backend::{ChangeId, CommitId}; use crate::default_index::DefaultMutableIndex; + use crate::object_id::ObjectId; /// Generator of unique 16-byte ChangeId excluding root id fn change_id_generator() -> impl FnMut() -> ChangeId { diff --git a/lib/src/git.rs b/lib/src/git.rs index 8ba776a2a..2ce1099c1 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -26,9 +26,10 @@ use itertools::Itertools; use tempfile::NamedTempFile; use thiserror::Error; -use crate::backend::{BackendError, CommitId, ObjectId}; +use crate::backend::{BackendError, CommitId}; use crate::commit::Commit; use crate::git_backend::GitBackend; +use crate::object_id::ObjectId; use crate::op_store::{RefTarget, RefTargetOptionExt, RemoteRef, RemoteRefState}; use crate::refs::BranchPushUpdate; use crate::repo::{MutableRepo, Repo}; diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index e91bf81b4..b7806cb45 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -32,12 +32,13 @@ use thiserror::Error; use crate::backend::{ make_root_commit, Backend, BackendError, BackendInitError, BackendLoadError, BackendResult, ChangeId, Commit, CommitId, Conflict, ConflictId, ConflictTerm, FileId, MergedTreeId, - MillisSinceEpoch, ObjectId, SecureSig, Signature, SigningFn, SymlinkId, Timestamp, Tree, - TreeId, TreeValue, + MillisSinceEpoch, SecureSig, Signature, SigningFn, SymlinkId, Timestamp, Tree, TreeId, + TreeValue, }; use crate::file_util::{IoResultExt as _, PathError}; use crate::lock::FileLock; use crate::merge::{Merge, MergeBuilder}; +use crate::object_id::ObjectId; use crate::repo_path::{RepoPath, RepoPathComponentBuf}; use crate::settings::UserSettings; use crate::stacked_table::{ diff --git a/lib/src/id_prefix.rs b/lib/src/id_prefix.rs index 8cfcf2b6c..f749e4599 100644 --- a/lib/src/id_prefix.rs +++ b/lib/src/id_prefix.rs @@ -21,9 +21,10 @@ use std::rc::Rc; use itertools::Itertools as _; use once_cell::unsync::OnceCell; -use crate::backend::{ChangeId, CommitId, ObjectId}; +use crate::backend::{ChangeId, CommitId}; use crate::hex_util; use crate::index::{HexPrefix, PrefixResolution}; +use crate::object_id::ObjectId; use crate::repo::Repo; use crate::revset::{DefaultSymbolResolver, RevsetExpression}; @@ -445,7 +446,8 @@ fn unwrap_as_short_key(key_bytes: &[u8]) -> &[u8; N] { #[cfg(test)] mod tests { use super::*; - use crate::backend::{ChangeId, ObjectId}; + use crate::backend::ChangeId; + use crate::object_id::ObjectId; #[derive(Clone, Copy, Eq, PartialEq)] struct Position(usize); diff --git a/lib/src/index.rs b/lib/src/index.rs index 86f703cbe..878130065 100644 --- a/lib/src/index.rs +++ b/lib/src/index.rs @@ -20,8 +20,9 @@ use std::sync::Arc; use thiserror::Error; -use crate::backend::{CommitId, ObjectId}; +use crate::backend::CommitId; use crate::commit::Commit; +use crate::object_id::ObjectId; use crate::op_store::OperationId; use crate::operation::Operation; use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError}; diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 193acde14..1c896dbda 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -47,6 +47,7 @@ pub mod lock; pub mod matchers; pub mod merge; pub mod merged_tree; +pub mod object_id; pub mod op_heads_store; pub mod op_store; pub mod op_walk; diff --git a/lib/src/local_backend.rs b/lib/src/local_backend.rs index c704d23e4..8d4d56bf0 100644 --- a/lib/src/local_backend.rs +++ b/lib/src/local_backend.rs @@ -28,12 +28,13 @@ use tempfile::NamedTempFile; use crate::backend::{ make_root_commit, Backend, BackendError, BackendResult, ChangeId, Commit, CommitId, Conflict, - ConflictId, ConflictTerm, FileId, MergedTreeId, MillisSinceEpoch, ObjectId, SecureSig, - Signature, SigningFn, SymlinkId, Timestamp, Tree, TreeId, TreeValue, + ConflictId, ConflictTerm, FileId, MergedTreeId, MillisSinceEpoch, SecureSig, Signature, + SigningFn, SymlinkId, Timestamp, Tree, TreeId, TreeValue, }; use crate::content_hash::blake2b_hash; use crate::file_util::persist_content_addressed_temp_file; use crate::merge::MergeBuilder; +use crate::object_id::ObjectId; use crate::repo_path::{RepoPath, RepoPathComponentBuf}; const COMMIT_ID_LENGTH: usize = 64; diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 7aa9822f3..83d3ca76b 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -42,7 +42,7 @@ use thiserror::Error; use tracing::{instrument, trace_span}; use crate::backend::{ - BackendError, FileId, MergedTreeId, MillisSinceEpoch, ObjectId, SymlinkId, TreeId, TreeValue, + BackendError, FileId, MergedTreeId, MillisSinceEpoch, SymlinkId, TreeId, TreeValue, }; use crate::commit::Commit; use crate::conflicts::{self, materialize_tree_value, MaterializedTreeValue}; @@ -56,6 +56,7 @@ use crate::matchers::{ }; use crate::merge::{Merge, MergeBuilder, MergedTreeValue}; use crate::merged_tree::{MergedTree, MergedTreeBuilder}; +use crate::object_id::ObjectId; use crate::op_store::{OperationId, WorkspaceId}; use crate::repo_path::{RepoPath, RepoPathBuf, RepoPathComponent}; use crate::settings::HumanByteSize; diff --git a/lib/src/merge.rs b/lib/src/merge.rs index 1f4c8d318..8d0542386 100644 --- a/lib/src/merge.rs +++ b/lib/src/merge.rs @@ -28,8 +28,9 @@ use itertools::Itertools; use smallvec::{smallvec_inline, SmallVec}; use crate::backend; -use crate::backend::{BackendError, FileId, ObjectId, TreeId, TreeValue}; +use crate::backend::{BackendError, FileId, TreeId, TreeValue}; use crate::content_hash::ContentHash; +use crate::object_id::ObjectId; use crate::repo_path::RepoPath; use crate::store::Store; use crate::tree::Tree; diff --git a/lib/src/object_id.rs b/lib/src/object_id.rs new file mode 100644 index 000000000..015acbd09 --- /dev/null +++ b/lib/src/object_id.rs @@ -0,0 +1,81 @@ +// Copyright 2020-2024 The Jujutsu Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![allow(missing_docs)] + +pub trait ObjectId { + fn new(value: Vec) -> Self; + fn object_type(&self) -> String; + fn from_bytes(bytes: &[u8]) -> Self; + fn as_bytes(&self) -> &[u8]; + fn to_bytes(&self) -> Vec; + fn from_hex(hex: &str) -> Self; + fn hex(&self) -> String; +} + +macro_rules! id_type { + ($vis:vis $name:ident) => { + content_hash! { + #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] + $vis struct $name(Vec); + } + $crate::object_id::impl_id_type!($name); + }; +} + +macro_rules! impl_id_type { + ($name:ident) => { + impl std::fmt::Debug for $name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + f.debug_tuple(stringify!($name)).field(&self.hex()).finish() + } + } + + impl crate::object_id::ObjectId for $name { + fn new(value: Vec) -> Self { + Self(value) + } + + fn object_type(&self) -> String { + stringify!($name) + .strip_suffix("Id") + .unwrap() + .to_ascii_lowercase() + .to_string() + } + + fn from_bytes(bytes: &[u8]) -> Self { + Self(bytes.to_vec()) + } + + fn as_bytes(&self) -> &[u8] { + &self.0 + } + + fn to_bytes(&self) -> Vec { + self.0.clone() + } + + fn from_hex(hex: &str) -> Self { + Self(hex::decode(hex).unwrap()) + } + + fn hex(&self) -> String { + hex::encode(&self.0) + } + } + }; +} + +pub(crate) use {id_type, impl_id_type}; diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index ed545895d..795f85ede 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -22,9 +22,10 @@ use itertools::Itertools as _; use once_cell::sync::Lazy; use thiserror::Error; -use crate::backend::{id_type, CommitId, ObjectId, Timestamp}; +use crate::backend::{CommitId, Timestamp}; use crate::content_hash::ContentHash; use crate::merge::Merge; +use crate::object_id::{id_type, ObjectId}; content_hash! { #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)] diff --git a/lib/src/op_walk.rs b/lib/src/op_walk.rs index 32eebfae1..5949eea7e 100644 --- a/lib/src/op_walk.rs +++ b/lib/src/op_walk.rs @@ -22,8 +22,8 @@ use std::sync::Arc; use itertools::Itertools as _; use thiserror::Error; -use crate::backend::ObjectId as _; use crate::index::HexPrefix; +use crate::object_id::ObjectId as _; use crate::op_heads_store::{OpHeadResolutionError, OpHeadsStore}; use crate::op_store::{OpStore, OpStoreError, OpStoreResult, OperationId}; use crate::operation::Operation; diff --git a/lib/src/refs.rs b/lib/src/refs.rs index effd81a02..56514312f 100644 --- a/lib/src/refs.rs +++ b/lib/src/refs.rs @@ -205,7 +205,7 @@ pub fn classify_branch_push_action(targets: TrackingRefPair) -> BranchPushAction #[cfg(test)] mod tests { use super::*; - use crate::backend::ObjectId; + use crate::object_id::ObjectId; use crate::op_store::RemoteRefState; fn new_remote_ref(target: RefTarget) -> RemoteRef { diff --git a/lib/src/repo.rs b/lib/src/repo.rs index c9b9aa0c2..f5e50183b 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -30,7 +30,7 @@ use tracing::instrument; use self::dirty_cell::DirtyCell; use crate::backend::{ Backend, BackendError, BackendInitError, BackendLoadError, BackendResult, ChangeId, CommitId, - MergedTreeId, ObjectId, SigningFn, + MergedTreeId, SigningFn, }; use crate::commit::{Commit, CommitByCommitterTimestamp}; use crate::commit_builder::CommitBuilder; @@ -40,6 +40,7 @@ use crate::file_util::{IoResultExt as _, PathError}; use crate::git_backend::GitBackend; use crate::index::{HexPrefix, Index, IndexStore, MutableIndex, PrefixResolution, ReadonlyIndex}; use crate::local_backend::LocalBackend; +use crate::object_id::ObjectId; use crate::op_heads_store::{self, OpHeadResolutionError, OpHeadsStore}; use crate::op_store::{ OpStore, OpStoreError, OperationId, RefTarget, RemoteRef, RemoteRefState, WorkspaceId, diff --git a/lib/src/revset_graph.rs b/lib/src/revset_graph.rs index 29ea2a56b..fb10bb5e6 100644 --- a/lib/src/revset_graph.rs +++ b/lib/src/revset_graph.rs @@ -296,7 +296,7 @@ mod tests { use renderdag::{Ancestor, GraphRowRenderer, Renderer as _}; use super::*; - use crate::backend::ObjectId; + use crate::object_id::ObjectId; fn id(c: char) -> CommitId { let d = u8::try_from(c).unwrap(); diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index b896ad81f..f5e61e4f5 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -22,12 +22,13 @@ use itertools::Itertools; use pollster::FutureExt; use tracing::instrument; -use crate::backend::{BackendError, BackendResult, CommitId, MergedTreeId, ObjectId}; +use crate::backend::{BackendError, BackendResult, CommitId, MergedTreeId}; use crate::commit::Commit; use crate::dag_walk; use crate::index::Index; use crate::matchers::{Matcher, Visit}; use crate::merged_tree::{MergedTree, MergedTreeBuilder}; +use crate::object_id::ObjectId; use crate::op_store::RefTarget; use crate::repo::{MutableRepo, Repo}; use crate::repo_path::RepoPath; diff --git a/lib/src/settings.rs b/lib/src/settings.rs index a07232839..22b41c271 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -21,9 +21,10 @@ use chrono::DateTime; use rand::prelude::*; use rand_chacha::ChaCha20Rng; -use crate::backend::{ChangeId, Commit, ObjectId, Signature, Timestamp}; +use crate::backend::{ChangeId, Commit, Signature, Timestamp}; use crate::fmt_util::binary_prefix; use crate::fsmonitor::FsmonitorKind; +use crate::object_id::ObjectId; use crate::signing::SignBehavior; #[derive(Debug, Clone)] diff --git a/lib/src/simple_op_heads_store.rs b/lib/src/simple_op_heads_store.rs index 7603ffed8..21a101580 100644 --- a/lib/src/simple_op_heads_store.rs +++ b/lib/src/simple_op_heads_store.rs @@ -18,8 +18,8 @@ use std::fmt::{Debug, Formatter}; use std::fs; use std::path::{Path, PathBuf}; -use crate::backend::ObjectId; use crate::lock::FileLock; +use crate::object_id::ObjectId; use crate::op_heads_store::{OpHeadsStore, OpHeadsStoreLock}; use crate::op_store::OperationId; diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 88f1f775e..645511a46 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -24,10 +24,11 @@ use prost::Message; use tempfile::NamedTempFile; use thiserror::Error; -use crate::backend::{CommitId, MillisSinceEpoch, ObjectId, Timestamp}; +use crate::backend::{CommitId, MillisSinceEpoch, Timestamp}; use crate::content_hash::blake2b_hash; use crate::file_util::persist_content_addressed_temp_file; use crate::merge::Merge; +use crate::object_id::ObjectId; use crate::op_store::{ OpStore, OpStoreError, OpStoreResult, Operation, OperationId, OperationMetadata, RefTarget, RemoteRef, RemoteRefState, RemoteView, View, ViewId, WorkspaceId, @@ -528,8 +529,9 @@ mod tests { use maplit::{btreemap, hashmap, hashset}; use super::*; - use crate::backend::{CommitId, MillisSinceEpoch, ObjectId, Timestamp}; + use crate::backend::{CommitId, MillisSinceEpoch, Timestamp}; use crate::content_hash::blake2b_hash; + use crate::object_id::ObjectId; use crate::op_store::{OperationMetadata, RefTarget, WorkspaceId}; fn create_view() -> View { diff --git a/lib/src/tree.rs b/lib/src/tree.rs index 4217abce9..6dcc0540e 100644 --- a/lib/src/tree.rs +++ b/lib/src/tree.rs @@ -24,12 +24,12 @@ use thiserror::Error; use tracing::instrument; use crate::backend::{ - BackendError, ConflictId, FileId, ObjectId, TreeEntriesNonRecursiveIterator, TreeEntry, TreeId, - TreeValue, + BackendError, ConflictId, FileId, TreeEntriesNonRecursiveIterator, TreeEntry, TreeId, TreeValue, }; use crate::files::MergeResult; use crate::matchers::{EverythingMatcher, Matcher}; use crate::merge::{trivial_merge, Merge, MergedTreeValue}; +use crate::object_id::ObjectId; use crate::repo_path::{RepoPath, RepoPathBuf, RepoPathComponent, RepoPathComponentsIter}; use crate::store::Store; use crate::{backend, files}; diff --git a/lib/tests/test_commit_builder.rs b/lib/tests/test_commit_builder.rs index 1269fb79f..eb6bc38f7 100644 --- a/lib/tests/test_commit_builder.rs +++ b/lib/tests/test_commit_builder.rs @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use jj_lib::backend::{ChangeId, MillisSinceEpoch, ObjectId, Signature, Timestamp}; +use jj_lib::backend::{ChangeId, MillisSinceEpoch, Signature, Timestamp}; use jj_lib::matchers::EverythingMatcher; use jj_lib::merged_tree::DiffSummary; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::repo_path::{RepoPath, RepoPathBuf}; use jj_lib::settings::UserSettings; diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index ccfab5a7e..75b29deb6 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -20,9 +20,7 @@ use std::{fs, thread}; use assert_matches::assert_matches; use git2::Oid; use itertools::Itertools; -use jj_lib::backend::{ - BackendError, ChangeId, CommitId, MillisSinceEpoch, ObjectId, Signature, Timestamp, -}; +use jj_lib::backend::{BackendError, ChangeId, CommitId, MillisSinceEpoch, Signature, Timestamp}; use jj_lib::commit::Commit; use jj_lib::commit_builder::CommitBuilder; use jj_lib::git; @@ -31,6 +29,7 @@ use jj_lib::git::{ GitRefUpdate, RefName, SubmoduleConfig, }; use jj_lib::git_backend::GitBackend; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::{BranchTarget, RefTarget, RemoteRef, RemoteRefState}; use jj_lib::refs::BranchPushUpdate; use jj_lib::repo::{MutableRepo, ReadonlyRepo, Repo}; diff --git a/lib/tests/test_id_prefix.rs b/lib/tests/test_id_prefix.rs index de6b6c399..d7960dded 100644 --- a/lib/tests/test_id_prefix.rs +++ b/lib/tests/test_id_prefix.rs @@ -13,10 +13,11 @@ // limitations under the License. use itertools::Itertools; -use jj_lib::backend::{CommitId, MillisSinceEpoch, ObjectId, Signature, Timestamp}; +use jj_lib::backend::{CommitId, MillisSinceEpoch, Signature, Timestamp}; use jj_lib::id_prefix::IdPrefixContext; use jj_lib::index::HexPrefix; use jj_lib::index::PrefixResolution::{AmbiguousMatch, NoMatch, SingleMatch}; +use jj_lib::object_id::ObjectId; use jj_lib::repo::Repo; use jj_lib::revset::RevsetExpression; use testutils::{TestRepo, TestRepoBackend}; diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index d9b57c6d4..71116b53a 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -16,7 +16,7 @@ use std::fs; use std::sync::Arc; use assert_matches::assert_matches; -use jj_lib::backend::{CommitId, ObjectId as _}; +use jj_lib::backend::CommitId; use jj_lib::commit::Commit; use jj_lib::commit_builder::CommitBuilder; use jj_lib::default_index::{ @@ -24,6 +24,7 @@ use jj_lib::default_index::{ DefaultMutableIndex, DefaultReadonlyIndex, IndexPosition, }; use jj_lib::index::Index as _; +use jj_lib::object_id::ObjectId as _; use jj_lib::repo::{MutableRepo, ReadonlyRepo, Repo}; use jj_lib::settings::UserSettings; use testutils::test_backend::TestBackend; diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index ea8389186..8445ea458 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -26,11 +26,12 @@ use std::path::Path; use std::sync::Arc; use itertools::Itertools; -use jj_lib::backend::{MergedTreeId, ObjectId, TreeId, TreeValue}; +use jj_lib::backend::{MergedTreeId, TreeId, TreeValue}; use jj_lib::fsmonitor::FsmonitorKind; use jj_lib::local_working_copy::LocalWorkingCopy; use jj_lib::merge::Merge; use jj_lib::merged_tree::MergedTreeBuilder; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::{OperationId, WorkspaceId}; use jj_lib::repo::{ReadonlyRepo, Repo}; use jj_lib::repo_path::{RepoPath, RepoPathBuf, RepoPathComponent}; diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index 5676dab0f..754c4d9e0 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -18,7 +18,8 @@ use std::sync::Arc; use assert_matches::assert_matches; use itertools::Itertools as _; -use jj_lib::backend::{CommitId, ObjectId}; +use jj_lib::backend::CommitId; +use jj_lib::object_id::ObjectId; use jj_lib::op_walk::{self, OpsetEvaluationError, OpsetResolutionError}; use jj_lib::operation::Operation; use jj_lib::repo::{ReadonlyRepo, Repo}; diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index 451846439..5ff2abd3a 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -21,11 +21,12 @@ use std::path::Path; use assert_matches::assert_matches; use itertools::Itertools; -use jj_lib::backend::{ChangeId, CommitId, MillisSinceEpoch, ObjectId, Signature, Timestamp}; +use jj_lib::backend::{ChangeId, CommitId, MillisSinceEpoch, Signature, Timestamp}; use jj_lib::commit::Commit; use jj_lib::git; use jj_lib::git_backend::GitBackend; use jj_lib::index::{HexPrefix, PrefixResolution}; +use jj_lib::object_id::ObjectId; use jj_lib::op_store::{RefTarget, RemoteRef, RemoteRefState, WorkspaceId}; use jj_lib::repo::Repo; use jj_lib::repo_path::RepoPath; diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index e8d998401..950c20c4d 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -22,13 +22,14 @@ use std::sync::{Arc, Once}; use itertools::Itertools; use jj_lib::backend::{ self, Backend, BackendInitError, ChangeId, CommitId, FileId, MergedTreeId, MillisSinceEpoch, - ObjectId, Signature, Timestamp, TreeValue, + Signature, Timestamp, TreeValue, }; use jj_lib::commit::Commit; use jj_lib::commit_builder::CommitBuilder; use jj_lib::git_backend::GitBackend; use jj_lib::local_backend::LocalBackend; use jj_lib::merged_tree::MergedTree; +use jj_lib::object_id::ObjectId; use jj_lib::repo::{MutableRepo, ReadonlyRepo, Repo, RepoLoader, StoreFactories}; use jj_lib::repo_path::{RepoPath, RepoPathBuf}; use jj_lib::settings::UserSettings; diff --git a/lib/testutils/src/test_backend.rs b/lib/testutils/src/test_backend.rs index a686f9164..88b36ea38 100644 --- a/lib/testutils/src/test_backend.rs +++ b/lib/testutils/src/test_backend.rs @@ -22,8 +22,9 @@ use std::sync::{Arc, Mutex, MutexGuard, OnceLock}; use async_trait::async_trait; use jj_lib::backend::{ make_root_commit, Backend, BackendError, BackendResult, ChangeId, Commit, CommitId, Conflict, - ConflictId, FileId, ObjectId, SecureSig, SigningFn, SymlinkId, Tree, TreeId, + ConflictId, FileId, SecureSig, SigningFn, SymlinkId, Tree, TreeId, }; +use jj_lib::object_id::ObjectId; use jj_lib::repo_path::{RepoPath, RepoPathBuf}; const HASH_LENGTH: usize = 10;