Elffuss BraidHub

utopia-ia/elffuss-braid public

38b3e04f7d4a · 3.6 KiBRawPermalink
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 UtopiaIA
3
4//! The semantic core of elffuss-braid: what a change list means, and what
5//! committing, admitting and landing a changeset do.
6//!
7//! Everything here reads and writes through the [`Objects`] trait and does no
8//! I/O of its own, so the same code runs over the local store, a remote one, or
9//! memory.
10//!
11//! - [`read_tree`], [`write_tree`], [`read_changeset`], [`read_changes`]:
12//! typed access to stored objects.
13//! - [`apply`] and [`diff`]: a change list, and the two trees it connects.
14//! - [`commit`] and [`admit`]: creating a changeset, and the check a store
15//! runs before it accepts one.
16//! - [`first_parent_chain_contains`], [`is_ancestor`] and [`merge_base`]:
17//! ancestry, walking history.
18//! - [`History`]: the same ancestry queries with generation numbers and skip
19//! pointers, the history of a path ([`History::path_log`]) with
20//! changed-path filters, and [`History::blame`], all answered with derived
21//! data ([`DerivedKey`], [`DerivedIndex`]) computed when missing.
22//! - [`merge3`]: three-way merges of file contents.
23//! - [`land`]: landing a change on a branch, with conflicts reported as data.
24//! - [`merge`]: merging two changesets into a merge changeset, with the same
25//! rules and conflicts as landing.
26//!
27//! # Files and directories
28//!
29//! A change list is per file: each change sets one path to a file, an
30//! executable, a symlink or a gitlink, or deletes it. Directories follow from
31//! the files: a change below a missing directory creates it, and a directory
32//! left without entries by a change is removed, as git has no empty
33//! directories. Braid trees never hold an empty subdirectory: no change list
34//! makes one, and the git bridge drops them when it converts git trees.
35//!
36//! A path has at most [`MAX_PATH_DEPTH`] names. This is a store policy, not
37//! part of the hashed format: [`apply`] and [`admit`] refuse deeper paths, so
38//! no stored tree is deeper, and every walk over a tree stops with
39//! [`Error::TooDeep`] beyond it. The walks keep their own stacks rather than
40//! recursing, so the limit does not depend on the size of the thread's stack.
41//!
42//! # Costs
43//!
44//! [`apply`], [`diff`], [`admit`], [`land`] and [`merge`] read only the
45//! directories on the changed paths, so their cost follows the size of the
46//! change times the depth of the tree, plus the size of each directory they
47//! touch. The free ancestry functions walk history and are proportional to
48//! the distance they cover; [`History`] reads derived data instead, so its
49//! queries cost what they visit once that data exists.
50//!
51//! [`Objects`]: braid_format::Objects
52
53#![forbid(unsafe_code)]
54
55mod access;
56mod ancestry;
57mod apply;
58mod blame;
59mod bloom;
60mod commit;
61mod derived;
62mod diff;
63mod error;
64mod history;
65mod land;
66mod merge;
67mod path;
68mod tree_merge;
69
70#[cfg(test)]
71mod testing;
72
73pub use access::{
74 EMPTY_TREE, entry_at, read_blob, read_changes, read_changeset, read_object, read_tree,
75 stat_object, write_tree,
76};
77pub use ancestry::{
78 GraphNode, first_parent_chain_contains, is_ancestor, merge_base, merge_bases, skip_height,
79};
80pub use apply::apply;
81pub use blame::{Blame, LineChange, line_diff};
82pub use commit::{admit, commit};
83pub use derived::{DerivedIndex, DerivedKey, MemoryIndex};
84pub use diff::diff;
85pub use error::{ApplyProblem, Error, StoreError};
86pub use history::{DeriveReport, History};
87pub use land::{AGENT, Conflict, ConflictKind, LandOutcome, REBASED_FROM, land};
88pub use merge::{BINARY_SNIFF_BYTES, ConflictHunk, HunkSide, MergeResult, is_binary, merge3};
89pub use path::MAX_PATH_DEPTH;
90pub use tree_merge::{MergeOutcome, merge};