Skip to main content

KnitRepository

Struct KnitRepository 

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

A non-pack knit repository, accessed through a transport rooted at .bzr/repository.

Implementations§

Source§

impl KnitRepository

Source

pub fn open(transport: SharedTransport) -> Result<Self, RepositoryError>

Open the knit repository whose .bzr/repository directory is rooted at transport.

Source

pub fn create( transport: SharedTransport, format: &'static RepositoryFormat, ) -> Result<Self, RepositoryError>

Create an empty knit repository of format at transport and open it. The stores create their files lazily on first write, so only the format marker and knits/ directory are written here.

Source

pub fn format(&self) -> &'static RepositoryFormat

The format this repository was opened as.

Source

pub fn all_revision_ids(&self) -> Result<Vec<Vec<u8>>, RepositoryError>

All revision ids, sorted.

Source

pub fn get_parent_map( &self, revision_ids: &[Vec<u8>], ) -> Result<HashMap<Vec<u8>, Vec<Vec<u8>>>, RepositoryError>

The stored parent ids of each of revision_ids (present ones only), read from the revisions kndx index.

Source

pub fn get_revision( &self, revision_id: &[u8], ) -> Result<Revision, RepositoryError>

Read and parse a revision (XML, serializer v5).

Source

pub fn get_inventory( &self, revision_id: &[u8], ) -> Result<MutableInventory, RepositoryError>

Read the inventory for a revision as an in-memory MutableInventory.

Source

pub fn get_file_text( &self, file_id: &[u8], revision: &[u8], ) -> Result<Vec<u8>, RepositoryError>

Read the file text for (file_id, revision).

Source

pub fn add_revision( &mut self, revision: &Revision, parents: &[Vec<u8>], ) -> Result<(), RepositoryError>

Add a revision, serialised to XML (v5).

Source

pub fn add_signature( &mut self, revision_id: &[u8], signature: &[u8], ) -> Result<(), RepositoryError>

Add a signature text for revision_id (the clearsigned testament) to the signatures knit.

Source

pub fn get_signature_text( &self, revision_id: &[u8], ) -> Result<Option<Vec<u8>>, RepositoryError>

The signature text stored for revision_id, or None if unsigned.

Source

pub fn add_inventory_from_entries( &mut self, revision_id: &[u8], parents: &[Vec<u8>], _root_id: &[u8], entries: &[Entry], ) -> Result<Vec<u8>, RepositoryError>

Build the inventory from entries, serialise it to XML, and add it.

Source

pub fn add_inventory_by_delta( &mut self, basis_revision_id: &[u8], delta: &InventoryDelta, new_revision_id: &[u8], parents: &[Vec<u8>], ) -> Result<Vec<u8>, RepositoryError>

Build the inventory for new_revision_id by applying delta to the basis inventory, then serialise and store it.

Source

pub fn add_text( &mut self, file_id: &[u8], revision: &[u8], parents: &[(Vec<u8>, Vec<u8>)], bytes: &[u8], ) -> Result<(), RepositoryError>

Add a file text, keyed by (file_id, revision).

Trait Implementations§

Source§

impl Repository for KnitRepository

Source§

fn format(&self) -> &'static RepositoryFormat

The format this repository was opened as.
Source§

fn as_any(&self) -> &dyn Any

Downcast support, so a backend’s format-specific fast path can recover a same-format source (e.g. another Pack2aRepository). Each backend returns self; a downcast to a different concrete type fails and the caller uses the generic path. Used by try_fetch_from implementations, not by the generic fetcher.
Source§

fn all_revision_ids(&self) -> Result<Vec<Vec<u8>>, RepositoryError>

All revision ids in this repository, sorted.
Source§

fn get_parent_map( &self, revision_ids: &[Vec<u8>], ) -> Result<HashMap<Vec<u8>, Vec<Vec<u8>>>, RepositoryError>

The stored parent ids of each of revision_ids, as a map. Revision ids not present in the repository are omitted from the result. The parents come straight from the revision store’s index (no body deserialisation), which is the raw graph data callers build a revision graph from.
Source§

fn get_revision(&self, revision_id: &[u8]) -> Result<Revision, RepositoryError>

Read and parse a revision by id.
Source§

fn get_inventory( &self, revision_id: &[u8], ) -> Result<Box<dyn Inventory>, RepositoryError>

Read the inventory for a revision.
Source§

fn get_file_text( &self, file_id: &[u8], revision: &[u8], ) -> Result<Vec<u8>, RepositoryError>

Read the full text of a versioned file at a given revision.
Source§

fn start_write_group(&mut self) -> Result<(), RepositoryError>

Open a write group: a batch of additions flushed atomically by Repository::commit_write_group.
Source§

fn add_revision( &mut self, revision: &Revision, parents: &[Vec<u8>], ) -> Result<(), RepositoryError>

Add a revision to the open write group, serialising it with the format’s own revision serializer (bencode for 2a, XML for knit-pack).
Source§

fn add_inventory_from_entries( &mut self, revision_id: &[u8], parents: &[Vec<u8>], root_id: &[u8], entries: &[Entry], ) -> Result<Vec<u8>, RepositoryError>

Build the inventory for a revision from entries and add it to the open write group, returning the inventory sha1 to record on the revision. Each format stores the inventory in its own representation (a CHK inventory for 2a, serialised XML for knit-pack).
Source§

fn add_inventory_by_delta( &mut self, basis_revision_id: &[u8], delta: &InventoryDelta, new_revision_id: &[u8], parents: &[Vec<u8>], ) -> Result<Vec<u8>, RepositoryError>

Build the inventory for new_revision_id by applying delta to the already-committed basis_revision_id inventory, adding it to the open write group and returning its sha1. Formats that can share storage (2a’s CHK inventory) write only the changed pages; others fall back to re-serialising the whole inventory.
Source§

fn add_text( &mut self, file_id: &[u8], revision: &[u8], parents: &[(Vec<u8>, Vec<u8>)], bytes: &[u8], ) -> Result<(), RepositoryError>

Add a file text (keyed by (file_id, revision)) to the open write group.
Source§

fn add_signature_text( &mut self, revision_id: &[u8], signature: &[u8], ) -> Result<(), RepositoryError>

Add a signature text for revision_id to the open write group.
Source§

fn get_signature_text( &self, revision_id: &[u8], ) -> Result<Option<Vec<u8>>, RepositoryError>

The signature text stored for revision_id, or None if unsigned.
Source§

fn commit_write_group(&mut self) -> Result<(), RepositoryError>

Flush the open write group, committing its additions.
Source§

fn try_fetch_from( &mut self, _source: &dyn Repository, _revision_ids: &[Vec<u8>], ) -> Result<bool, RepositoryError>

Try to copy revision_ids (topologically ordered, already filtered to revisions absent here) from source into this repository using a format-specific fast path, opening and committing the write group itself. Read more
Source§

fn has_revision(&self, revision_id: &[u8]) -> Result<bool, RepositoryError>

Whether revision_id is present in this repository. Defaults to a single-key get_parent_map lookup; backends may override with a cheaper index probe.
Source§

fn revision_tree( &self, revision_id: &[u8], ) -> Result<RevisionTree, RepositoryError>

A read-only view of the tree at revision_id: its inventory paired with the revision id. This is the basis a commit builds its inventory delta against.
Source§

fn get_file_text_at_path( &self, path: &str, revision: &[u8], ) -> Result<Vec<u8>, RepositoryError>

Read the full text of the file at tree-relative path in revision, resolving the path to a file id through that revision’s inventory. Errors with RepositoryError::NoSuchRevision if path is not in the tree (reusing the closest variant for “not found”).
Source§

fn pack(&mut self) -> Result<(), RepositoryError>

Combine the repository’s packs into a single pack. Read more
Source§

fn autopack(&mut self) -> Result<bool, RepositoryError>

Repack the smallest packs if the repository has accumulated too many, per the pack-distribution heuristic. Returns whether a repack happened. Read more
Source§

fn check(&self) -> Result<CheckResult, RepositoryError>

Check the integrity of this repository, returning a report of any inconsistencies (see CheckResult). Format-neutral: it cross-checks the data every format exposes through this trait.
Source§

fn reconcile(&mut self) -> Result<ReconcileResult, RepositoryError>

Reconcile this repository: regenerate its storage keeping only the data reachable from its revisions, discarding garbage (e.g. inventories or texts left behind by an interrupted operation), and report what was dropped (see ReconcileResult). Read more
Source§

fn add_fallback_repository( &mut self, _fallback: Box<dyn Repository>, ) -> Result<(), RepositoryError>

Add a fallback repository consulted for objects this one lacks. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Ungil for T
where T: Send,