1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2025 LunaOS Contributors
// SPDX-License-Identifier: Apache-2.0
//! Git-style branching for LCPFS.
//!
//! This module provides git-like branching capabilities for LCPFS datasets,
//! leveraging the copy-on-write (COW) nature of the filesystem to enable
//! zero-copy branch creation and efficient merging.
//!
//! # Overview
//!
//! The branching system provides:
//!
//! - **Zero-copy branch creation**: Due to COW semantics, creating a branch is
//! nearly instantaneous regardless of dataset size
//! - **Three-way merge**: Full merge support with conflict detection
//! - **Commit tracking**: Git-style commits with BLAKE3 hashes
//! - **Cherry-pick**: Apply commits from one branch to another
//! - **History viewing**: Log, file history, and branch statistics
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ BranchManager │
//! │ (Unified API combining all branching operations) │
//! └─────────────────────────────────────────────────────────────────┘
//! │
//! ┌──────────────────────┼──────────────────────┐
//! ▼ ▼ ▼
//! ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
//! │ BranchRegistry │ │ CommitStore │ │ MergeEngine │
//! │ (Branch meta) │ │ (Commit hash) │ │ (3-way merge) │
//! └─────────────────┘ └─────────────────┘ └─────────────────┘
//! │ │ │
//! └──────────────────────┼──────────────────────┘
//! ▼
//! ┌─────────────────────┐
//! │ DatasetProvider │
//! │ (COW filesystem) │
//! └─────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```rust,ignore
//! use lcpfs::branch::BranchManager;
//!
//! // Create a branch manager with a dataset provider
//! let mut manager = BranchManager::new(provider, "user@example.com");
//!
//! // Create and checkout a new branch
//! manager.checkout_new("feature-xyz")?;
//!
//! // Make changes and commit
//! manager.commit("Add new feature", changes)?;
//!
//! // Switch back to main
//! manager.checkout("main")?;
//!
//! // Merge the feature branch
//! let result = manager.merge("feature-xyz")?;
//! if result.has_conflicts() {
//! // Handle conflicts...
//! }
//! ```
//!
//! # Modules
//!
//! - `types`: Core types (Branch, Commit, FileChange, MergeResult, etc.)
//! - `registry`: Branch registry for tracking branch metadata
//! - `ops`: Branch operations (create, checkout, delete)
//! - `commit`: Commit tracking with BLAKE3 hashes
//! - `merge`: Three-way merge with conflict detection
//! - `cherrypick`: Cherry-pick commits across branches
//! - `log`: History viewing and statistics
//! - `manager`: Unified BranchManager API
// Re-export main types
pub use ;
pub use ;
pub use ;
pub use BranchManager;
pub use ;
pub use ;
pub use BranchRegistry;
pub use ;