pub struct Commit {
pub format_version: u16,
pub parents: Vec<ContentHash>,
pub tree: BTreeMap<String, TreeEntry>,
pub author: String,
pub message: String,
pub resolves: Option<ContentHash>,
}Expand description
A content-addressed commit: parents, a path→entry tree, metadata.
Fields§
§format_version: u16Wire-format version; see FORMAT_VERSION.
parents: Vec<ContentHash>Parent commit ids (0 = root, 2+ = merge).
tree: BTreeMap<String, TreeEntry>Path → entry, sorted (BTreeMap) so serialization is canonical.
Author identity string (key-backed from L8 onward).
message: StringCommit message.
resolves: Option<ContentHash>The commit whose TreeEntry::Conflict this commit resolves,
when it is a resolution — resolution-as-linked-change,
as metadata on the existing shape (DECISIONS.md D15: never a new merge
substrate). A conflict is a value (invariant 6): the link points
at the conflicted commit, which stays in history untouched.
Additive (default + skip_serializing_if), so commits written
before the field existed decode as None and re-serialize
byte-identically — invariant 1.
Implementations§
Source§impl Commit
impl Commit
Sourcepub fn is_conflicted(&self) -> bool
pub fn is_conflicted(&self) -> bool
Whether any tree entry is an unresolved TreeEntry::Conflict.
Sourcepub fn validate_resolves(&self, store: &dyn ChunkStore) -> Result<(), ViewError>
pub fn validate_resolves(&self, store: &dyn ChunkStore) -> Result<(), ViewError>
Validates this commit’s resolves link against store.
A Some link must name a commit the store holds whose tree still
carries an unresolved TreeEntry::Conflict — anything else is
refused, never silently dropped: a dangling link admitted once
would replay forever as a claim about a conflict nobody can load.
None validates trivially (most commits resolve nothing).
§Errors
Returns ViewError::Resolution when the link is dangling or the
referenced commit has no conflict to resolve.
Sourcepub fn put(&self, store: &mut dyn ChunkStore) -> Result<ContentHash, ViewError>
pub fn put(&self, store: &mut dyn ChunkStore) -> Result<ContentHash, ViewError>
Stores this commit in store and returns its content address.
§Errors
Propagates ViewError::Store from the underlying store.
Sourcepub fn get(store: &dyn ChunkStore, id: &ContentHash) -> Result<Self, ViewError>
pub fn get(store: &dyn ChunkStore, id: &ContentHash) -> Result<Self, ViewError>
Loads the commit at id from store, verifying its address.
§Errors
Returns ViewError::Store on lookup/verification failure and
ViewError::Decode when the bytes are not a commit.