pub struct Repository { /* private fields */ }Expand description
A handle to an on-disk cadvm repository.
Implementations§
Source§impl Repository
impl Repository
Sourcepub fn init(workdir: impl AsRef<Path>) -> Result<Repository>
pub fn init(workdir: impl AsRef<Path>) -> Result<Repository>
Initialize a brand-new repository rooted at workdir.
Sourcepub fn discover(start: impl AsRef<Path>) -> Result<Repository>
pub fn discover(start: impl AsRef<Path>) -> Result<Repository>
Open the repository containing start, searching upward for .cadvm.
Sourcepub fn open(workdir: impl AsRef<Path>) -> Result<Repository>
pub fn open(workdir: impl AsRef<Path>) -> Result<Repository>
Open a repository whose root (the directory containing .cadvm) is known.
Sourcepub fn config_path(&self) -> PathBuf
pub fn config_path(&self) -> PathBuf
Path to the repository config file.
Sourcepub fn write_head(&self, head: &Head) -> Result<()>
pub fn write_head(&self, head: &Head) -> Result<()>
Overwrite HEAD.
Sourcepub fn current_branch(&self) -> Result<Option<String>>
pub fn current_branch(&self) -> Result<Option<String>>
The branch name HEAD is attached to, if any.
Sourcepub fn read_ref(&self, branch: &str) -> Result<Option<ObjectId>>
pub fn read_ref(&self, branch: &str) -> Result<Option<ObjectId>>
Read a branch ref. Returns None if the branch has no commit yet.
Sourcepub fn write_ref(&self, branch: &str, commit: &ObjectId) -> Result<()>
pub fn write_ref(&self, branch: &str, commit: &ObjectId) -> Result<()>
Point a branch ref at a commit (creating the ref file if needed).
Sourcepub fn branch_exists(&self, branch: &str) -> bool
pub fn branch_exists(&self, branch: &str) -> bool
Whether a branch exists.
Sourcepub fn list_branches(&self) -> Result<Vec<String>>
pub fn list_branches(&self) -> Result<Vec<String>>
List all branch names, sorted.
Sourcepub fn create_branch(&self, name: &str, commit: &ObjectId) -> Result<()>
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.
Sourcepub fn delete_branch(&self, name: &str) -> Result<()>
pub fn delete_branch(&self, name: &str) -> Result<()>
Delete a branch ref. Refuses to delete the branch HEAD is on.
Sourcepub fn head_commit_id(&self) -> Result<Option<ObjectId>>
pub fn head_commit_id(&self) -> Result<Option<ObjectId>>
The commit id HEAD currently resolves to, if any.
Sourcepub fn write_commit(&self, body: &CommitBody) -> Result<ObjectId>
pub fn write_commit(&self, body: &CommitBody) -> Result<ObjectId>
Persist a commit body and return its content id.
Sourcepub fn read_commit(&self, id: &ObjectId) -> Result<Commit>
pub fn read_commit(&self, id: &ObjectId) -> Result<Commit>
Read a commit by id.
Sourcepub fn write_manifest(&self, manifest: &Manifest) -> Result<ObjectId>
pub fn write_manifest(&self, manifest: &Manifest) -> Result<ObjectId>
Persist a manifest and return its content id.
Sourcepub fn read_manifest(&self, id: &ObjectId) -> Result<Manifest>
pub fn read_manifest(&self, id: &ObjectId) -> Result<Manifest>
Read a manifest by id.
Sourcepub fn manifest_of_commit(&self, commit: &ObjectId) -> Result<Manifest>
pub fn manifest_of_commit(&self, commit: &ObjectId) -> Result<Manifest>
Read the manifest belonging to a commit.
Sourcepub fn head_manifest(&self) -> Result<Manifest>
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
impl Clone for Repository
Source§fn clone(&self) -> Repository
fn clone(&self) -> Repository
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more