Skip to main content

Repository

Struct Repository 

Source
pub struct Repository { /* private fields */ }
Expand description

A handle to an on-disk cadvm repository.

Implementations§

Source§

impl Repository

Source

pub fn init(workdir: impl AsRef<Path>) -> Result<Repository>

Initialize a brand-new repository rooted at workdir.

Source

pub fn discover(start: impl AsRef<Path>) -> Result<Repository>

Open the repository containing start, searching upward for .cadvm.

Source

pub fn open(workdir: impl AsRef<Path>) -> Result<Repository>

Open a repository whose root (the directory containing .cadvm) is known.

Source

pub fn workdir(&self) -> &Path

Repository root (the directory that contains .cadvm).

Source

pub fn cadvm_dir(&self) -> &Path

The .cadvm directory.

Source

pub fn store(&self) -> &Store

The shared object store.

Source

pub fn config_path(&self) -> PathBuf

Path to the repository config file.

Source

pub fn tmp_dir(&self) -> PathBuf

The tmp/ scratch directory.

Source

pub fn read_head(&self) -> Result<Head>

Read the current HEAD.

Source

pub fn write_head(&self, head: &Head) -> Result<()>

Overwrite HEAD.

Source

pub fn current_branch(&self) -> Result<Option<String>>

The branch name HEAD is attached to, if any.

Source

pub fn read_ref(&self, branch: &str) -> Result<Option<ObjectId>>

Read a branch ref. Returns None if the branch has no commit yet.

Source

pub fn write_ref(&self, branch: &str, commit: &ObjectId) -> Result<()>

Point a branch ref at a commit (creating the ref file if needed).

Source

pub fn branch_exists(&self, branch: &str) -> bool

Whether a branch exists.

Source

pub fn list_branches(&self) -> Result<Vec<String>>

List all branch names, sorted.

Source

pub fn create_branch(&self, name: &str, commit: &ObjectId) -> Result<()>

Create a new branch pointing at commit. Errors if it already exists or the name is invalid.

Source

pub fn delete_branch(&self, name: &str) -> Result<()>

Delete a branch ref. Refuses to delete the branch HEAD is on.

Source

pub fn head_commit_id(&self) -> Result<Option<ObjectId>>

The commit id HEAD currently resolves to, if any.

Source

pub fn write_commit(&self, body: &CommitBody) -> Result<ObjectId>

Persist a commit body and return its content id.

Source

pub fn read_commit(&self, id: &ObjectId) -> Result<Commit>

Read a commit by id.

Source

pub fn write_manifest(&self, manifest: &Manifest) -> Result<ObjectId>

Persist a manifest and return its content id.

Source

pub fn read_manifest(&self, id: &ObjectId) -> Result<Manifest>

Read a manifest by id.

Source

pub fn manifest_of_commit(&self, commit: &ObjectId) -> Result<Manifest>

Read the manifest belonging to a commit.

Source

pub fn head_manifest(&self) -> Result<Manifest>

The manifest HEAD points to, or an empty manifest if there are no commits.

Trait Implementations§

Source§

impl Clone for Repository

Source§

fn clone(&self) -> Repository

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Repository

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.