diff --git a/Cargo.lock b/Cargo.lock index 1b4a6f10fc5..95ca7dc8c42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2635,6 +2635,28 @@ dependencies = [ "whoami", ] +[[package]] +name = "jj-core" +version = "0.44.0" +dependencies = [ + "assert_matches", + "bstr", + "criterion", + "either", + "eyre", + "futures 0.3.33", + "globset", + "hashbrown 0.17.1", + "indexmap", + "insta", + "itertools 0.15.0", + "maplit", + "pollster", + "regex", + "smallvec", + "thiserror 2.0.19", +] + [[package]] name = "jj-lib" version = "0.44.0" @@ -2645,7 +2667,6 @@ dependencies = [ "bstr", "chrono", "clru", - "criterion", "digest 0.10.7", "dunce", "either", @@ -2655,12 +2676,12 @@ dependencies = [ "gix", "gix-ignore", "globset", - "hashbrown 0.17.1", "indexmap", "indoc", "insta", "interim", "itertools 0.15.0", + "jj-core", "jj-lib-proc-macros", "maplit", "memchr", diff --git a/Cargo.toml b/Cargo.toml index ad90a9fba29..1641b3e79dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,14 @@ cargo-features = [] [workspace] resolver = "3" -members = ["cli", "lib", "lib/gen-protos", "lib/proc-macros", "lib/testutils"] +members = [ + "cli", + "core", + "lib", + "lib/gen-protos", + "lib/proc-macros", + "lib/testutils", +] [workspace.package] version = "0.44.0" @@ -139,6 +146,7 @@ winreg = "0.56" # put all inter-workspace libraries, i.e. those that use 'path = ...' here in # their own (alphabetically sorted) block +jj-core = { path = "core", version = "0.44.0" } jj-lib = { path = "lib", version = "0.44.0", default-features = false } jj-lib-proc-macros = { path = "lib/proc-macros", version = "0.44.0" } testutils = { path = "lib/testutils" } diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 00000000000..c70da7b8c97 --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "jj-core" +version.workspace = true +license.workspace = true +rust-version.workspace = true +edition.workspace = true +readme.workspace = true +homepage.workspace = true +repository.workspace = true +documentation.workspace = true +categories.workspace = true +keywords.workspace = true + +[[bench]] +name = "diff_bench" +harness = false + +[dependencies] +bstr = { workspace = true } +either = { workspace = true } +futures = { workspace = true } +globset = { workspace = true } +hashbrown = { workspace = true } +indexmap = { workspace = true } +itertools = { workspace = true } +regex = { workspace = true } +smallvec = { workspace = true } +thiserror = { workspace = true } + +[dev-dependencies] +assert_matches = { workspace = true } +criterion = { workspace = true } +eyre = { workspace = true } +insta = { workspace = true } +maplit = { workspace = true } +pollster = { workspace = true } + +[lints] +workspace = true diff --git a/lib/benches/diff_bench.rs b/core/benches/diff_bench.rs similarity index 99% rename from lib/benches/diff_bench.rs rename to core/benches/diff_bench.rs index c1c8bf4b4ed..0a104331cc1 100644 --- a/lib/benches/diff_bench.rs +++ b/core/benches/diff_bench.rs @@ -2,7 +2,7 @@ use criterion::BenchmarkId; use criterion::Criterion; use criterion::criterion_group; use criterion::criterion_main; -use jj_lib::diff; +use jj_core::diff; fn unchanged_lines(count: usize) -> (String, String) { let mut lines = vec![]; diff --git a/lib/src/dag_walk.rs b/core/src/dag_walk.rs similarity index 100% rename from lib/src/dag_walk.rs rename to core/src/dag_walk.rs diff --git a/lib/src/dag_walk_async.rs b/core/src/dag_walk_async.rs similarity index 100% rename from lib/src/dag_walk_async.rs rename to core/src/dag_walk_async.rs diff --git a/lib/src/diff.rs b/core/src/diff.rs similarity index 100% rename from lib/src/diff.rs rename to core/src/diff.rs diff --git a/lib/src/hex_util.rs b/core/src/hex_util.rs similarity index 100% rename from lib/src/hex_util.rs rename to core/src/hex_util.rs diff --git a/core/src/lib.rs b/core/src/lib.rs new file mode 100644 index 00000000000..ade500f8555 --- /dev/null +++ b/core/src/lib.rs @@ -0,0 +1,32 @@ +// Copyright 2026 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. + +//! The core library powering the Jujutsu Version Control System. It contains +//! all "base" types such as `Commit` and the `Backend` trait. + +#![warn(missing_docs)] +#![forbid(unsafe_code)] +#![deny(unused_must_use)] + +pub mod dag_walk; +pub mod dag_walk_async; +pub mod diff; +pub mod hex_util; +pub mod str_util; + +#[cfg(test)] +mod tests { + // Copied from `testutils::TestResult` to remove dependency cycle. + pub type TestResult = eyre::Result; +} diff --git a/lib/src/str_util.rs b/core/src/str_util.rs similarity index 100% rename from lib/src/str_util.rs rename to core/src/str_util.rs diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 152fc1700c5..ed2b49765f1 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -14,7 +14,6 @@ readme = { workspace = true } include = [ "/LICENSE", - "/benches/", "/src/", "/tests/", "!*.pending-snap", @@ -25,10 +24,6 @@ include = [ [[test]] name = "runner" -[[bench]] -name = "diff_bench" -harness = false - [dependencies] async-trait = { workspace = true } blake2 = { workspace = true } @@ -43,10 +38,10 @@ futures = { workspace = true } gix = { workspace = true, optional = true } gix-ignore = { workspace = true } globset = { workspace = true } -hashbrown = { workspace = true } indexmap = { workspace = true } interim = { workspace = true } itertools = { workspace = true } +jj-core = { workspace = true } jj-lib-proc-macros = { workspace = true } maplit = { workspace = true } memchr = { workspace = true } @@ -79,7 +74,6 @@ winreg = { workspace = true } [dev-dependencies] assert_matches = { workspace = true } -criterion = { workspace = true } eyre = { workspace = true } indoc = { workspace = true } insta = { workspace = true } diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 5ed1381c8f0..34fd1479501 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -40,12 +40,12 @@ pub mod conflict_labels; pub mod conflicts; pub mod converge; pub mod copies; -pub mod dag_walk; -pub mod dag_walk_async; +pub use jj_core::dag_walk; +pub use jj_core::dag_walk_async; pub mod default_backend_factories; pub mod default_index; pub mod default_submodule_store; -pub mod diff; +pub use jj_core::diff; pub mod diff_presentation; pub mod dsl_util; pub(crate) mod eol; @@ -68,7 +68,7 @@ pub mod gitignore; pub mod gpg_signing; pub mod graph; pub mod graph_dominators; -pub mod hex_util; +pub use jj_core::hex_util; pub mod id_prefix; pub mod index; pub mod iter_util; @@ -107,7 +107,7 @@ pub mod simple_op_store; pub mod ssh_signing; pub mod stacked_table; pub mod store; -pub mod str_util; +pub use jj_core::str_util; pub mod submodule_store; #[cfg(feature = "testing")] pub mod test_signing_backend;