Skip to main content

Commit

Struct Commit 

Source
pub struct Commit {
    pub id: CommitId,
    pub parents: SmallVec<[CommitId; 2]>,
    pub root: Root,
    pub seq: u64,
    pub message: Option<String>,
    pub ops: Vec<Op>,
}
Expand description

One immutable point in a branch’s history.

A commit owns a whole root, but roots are structurally shared, so the marginal cost of a commit is the path it rewrote, not the database.

Fields§

§id: CommitId

Content address: blake3(parent ids ‖ message ‖ canonical-encoded ops).

§parents: SmallVec<[CommitId; 2]>

Zero parents for the genesis commit, one normally, two for a merge.

§root: Root

The state of the database after this commit.

§seq: u64

Monotonic along the first-parent chain; the genesis commit is 0.

§message: Option<String>

Optional human-readable message. Part of the content address, so the same change under a different message is a different commit.

§ops: Vec<Op>

This commit’s change set, sorted by key.

Implementations§

Source§

impl Commit

Source

pub fn compute_id( parents: &[CommitId], message: Option<&str>, ops: &[Op], ) -> CommitId

Compute the content address of a commit from its parents, message and change set.

DESIGN §4.1 defines the id as blake3(parent ids ‖ message ‖ canonical-encoded ops). seq and wall-clock time take no part, so the same change with the same message applied to the same parents is the same commit everywhere.

The message is encoded as an optional length-prefixed string, so a commit with no message, one with an empty message and one with a real message are three different commits.

Source

pub fn first_parent(&self) -> Option<CommitId>

The first parent, i.e. the previous commit on this branch.

Trait Implementations§

Source§

impl Clone for Commit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Commit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Summarizes rather than dumping the root, which may hold millions of keys.

Auto Trait Implementations§

§

impl Forget for Commit

§

impl Freeze for Commit

§

impl Move for Commit

§

impl RefUnwindSafe for Commit

§

impl Send for Commit

§

impl Sync for Commit

§

impl Unpin for Commit

§

impl UnsafeUnpin for Commit

§

impl UnwindSafe for Commit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.