Type Alias MutTxn

Source
pub type MutTxn<'env, R> = GenericTxn<MutTxn<'env, ()>, R>;
Expand description

A mutable transaction on a repository.

Aliased Type§

pub struct MutTxn<'env, R> { /* private fields */ }

Implementations§

Source§

impl<'env, R: Rng> MutTxn<'env, R>

Branches and commits.

Source

pub fn open_branch<'name>(&mut self, name: &str) -> Result<Branch>

Open a branch by name, creating an empty branch with that name if the name doesn’t exist.

Source

pub fn commit_branch(&mut self, branch: Branch) -> Result<()>

Commit a branch. This is a extremely important thing to do on branches, and it is not done automatically when committing transactions.

I repeat: not calling this method before committing a transaction might cause database corruption.

Source

pub fn rename_branch( &mut self, branch: &mut Branch, new_name: &str, ) -> Result<()>

Rename a branch. The branch still needs to be committed after this operation.

Source

pub fn commit(self) -> Result<()>

Commit a transaction. Be careful to commit all open branches before.

Source§

impl<'env, R: Rng> MutTxn<'env, R>

Low-level operations on mutable transactions.

Source

pub fn drop_branch(&mut self, branch: &str) -> Result<bool>

Delete a branch, destroying its associated graph and patch set.

Source

pub fn put_nodes( &mut self, branch: &mut Branch, key: Key<PatchId>, edge: &Edge, ) -> Result<bool>

Add a binding to the graph of a branch. All edges must be inserted twice, once in each direction, and this method only inserts one direction.

Source

pub fn put_nodes_with_rev( &mut self, branch: &mut Branch, key: Key<PatchId>, edge: Edge, ) -> Result<bool>

Same as put_nodes, but also adds the reverse edge.

Source

pub fn del_nodes( &mut self, branch: &mut Branch, key: Key<PatchId>, edge: Option<&Edge>, ) -> Result<bool>

Delete a binding from a graph. If edge is None, delete the smallest binding with key at least key.

Source

pub fn del_nodes_with_rev( &mut self, branch: &mut Branch, key: Key<PatchId>, edge: Edge, ) -> Result<bool>

Same as del_nodes, but also deletes the reverse edge.

Source

pub fn put_tree(&mut self, key: &FileId<'_>, edge: Inode) -> Result<bool>

Add a file or directory into the tree database, with parent key.parent_inode, name key.basename and inode Inode (usually randomly generated, as Inodes have no relation with patches or branches).

All bindings inserted here must have the reverse inserted into the revtree database. If (key, edge) is inserted here, then (edge, key) must be inserted into revtree.

Source

pub fn del_tree( &mut self, key: &FileId<'_>, edge: Option<Inode>, ) -> Result<bool>

Delete a file or directory from the tree database. Similarly to the comments in the documentation of the put_tree method, the reverse binding must be delete from the revtree database.

Source

pub fn put_revtree(&mut self, key: Inode, value: &FileId<'_>) -> Result<bool>

Add a file into the revtree database (see the documentation of the put_tree method).

Source

pub fn del_revtree( &mut self, key: Inode, value: Option<&FileId<'_>>, ) -> Result<bool>

Delete a file from the revtree database (see the documentation of the put_tree method).

Source

pub fn del_inodes( &mut self, key: Inode, value: Option<FileHeader>, ) -> Result<bool>

Delete a binding from the inodes database, i.e. the correspondence between branch graphs and the file tree.

All bindings in inodes must have their reverse in revinodes (without the FileMetadata). del_revinodes must be called immediately before or immediately after calling this method.

Source

pub fn replace_inodes(&mut self, key: Inode, value: FileHeader) -> Result<bool>

Replace a binding in the inodes database, or insert a new one if key doesn’t exist yet in that database.

All bindings in inodes must have their reverse inserted in revinodes (without the FileMetadata).

Source

pub fn replace_revinodes( &mut self, key: Key<PatchId>, value: Inode, ) -> Result<bool>

Replace a binding in the revinodes database, or insert a new one if key doesnt exist yet in that database.

All bindings in revinodes must have their reverse inserted inodes (with an extra FileMetadata).

Source

pub fn del_revinodes( &mut self, key: Key<PatchId>, value: Option<Inode>, ) -> Result<bool>

Delete a binding from the revinodes database, i.e. the correspondence between the file tree and branch graphs.

All bindings in revinodes must have their reverse in inodes (with an extra FileMetadata). del_inodes must be called immediately before or immediately after calling this method.

Source

pub fn put_contents( &mut self, key: Key<PatchId>, value: UnsafeValue, ) -> Result<bool>

Add the contents of a line. Note that this table is common to all branches.

Source

pub fn del_contents( &mut self, key: Key<PatchId>, value: Option<UnsafeValue>, ) -> Result<bool>

Remove the contents of a line.

Source

pub fn put_internal(&mut self, key: HashRef<'_>, value: PatchId) -> Result<bool>

Register the internal identifier of a patch. The put_external method must be called immediately after, or immediately before this method.

Source

pub fn del_internal(&mut self, key: HashRef<'_>) -> Result<bool>

Unregister the internal identifier of a patch. Remember to also unregister its external id.

Source

pub fn put_external(&mut self, key: PatchId, value: HashRef<'_>) -> Result<bool>

Register the extern identifier of a patch. The put_internal method must be called immediately after, or immediately before this method.

Source

pub fn del_external(&mut self, key: PatchId) -> Result<bool>

Unregister the extern identifier of a patch. Remember to also unregister its internal id.

Source

pub fn put_patches( &mut self, branch: &mut Db<PatchId, ApplyTimestamp>, value: PatchId, time: ApplyTimestamp, ) -> Result<bool>

Add a patch id to a branch. This doesn’t apply the patch, it only registers it as applied. The put_revpatches method must be called on the same branch immediately before, or immediately after.

Source

pub fn del_patches( &mut self, branch: &mut Db<PatchId, ApplyTimestamp>, value: PatchId, ) -> Result<bool>

Delete a patch id from a branch. This doesn’t unrecord the patch, it only removes it from the patch set. The del_revpatches method must be called on the same branch immediately before, or immediately after.

Source

pub fn put_revpatches( &mut self, branch: &mut Db<ApplyTimestamp, PatchId>, time: ApplyTimestamp, value: PatchId, ) -> Result<bool>

Add a patch id to a branch. This doesn’t apply the patch, it only registers it as applied. The put_patches method must be called on the same branch immediately before, or immediately after.

Source

pub fn del_revpatches( &mut self, revbranch: &mut Db<ApplyTimestamp, PatchId>, timestamp: ApplyTimestamp, value: PatchId, ) -> Result<bool>

Delete a patch id from a branch. This doesn’t unrecord the patch, it only removes it from the patch set. The del_patches method must be called on the same branch immediately before, or immediately after.

Source

pub fn put_revdep(&mut self, patch: PatchId, revdep: PatchId) -> Result<bool>

Register a reverse dependency. All dependencies of all patches applied on at least one branch must be registered in this database, i.e. if a depends on b, then (b, a) must be inserted here.

Source

pub fn put_dep(&mut self, patch: PatchId, dep: PatchId) -> Result<bool>

Register a dependency. All dependencies of all patches applied on at least one branch must be registered in this database, i.e. if a depends on b, then (b, a) must be inserted here.

Source

pub fn del_revdep( &mut self, patch: PatchId, revdep: Option<PatchId>, ) -> Result<bool>

Remove a reverse dependency. Only call this method when the patch with identifier patch is not applied to any branch.

Source

pub fn del_dep(&mut self, patch: PatchId, dep: Option<PatchId>) -> Result<bool>

Remove a dependency. Only call this method when the patch with identifier patch is not applied to any branch.

Source

pub fn put_cemetery( &mut self, key: Key<PatchId>, edge: &Edge, patch: PatchId, ) -> Result<bool>

Add an edge to the cemetery.

Source

pub fn del_cemetery( &mut self, key: Key<PatchId>, edge: &Edge, patch: PatchId, ) -> Result<bool>

Delete an edge from the cemetery.

Source

pub fn put_touched_file( &mut self, file: Key<PatchId>, patch: PatchId, ) -> Result<bool>

Add the relation “patch patch touches file file”.

Source

pub fn del_touched_file( &mut self, file: Key<PatchId>, patch: PatchId, ) -> Result<bool>

Delete all mentions of patch in the table of touched files.

Source

pub fn put_partials(&mut self, name: &str, path: Key<PatchId>) -> Result<bool>

Add a partial path to a branch.

Source

pub fn del_partials(&mut self, name: &str) -> Result<bool>

Remove a partial path from a branch.

Source

pub fn alloc_value(&mut self, slice: &[u8]) -> Result<UnsafeValue>

Allocate a string (to be inserted in the contents database).

Source§

impl<'env, R: Rng> MutTxn<'env, R>

Source

pub fn mark_inode_moved(&mut self, inode: Inode)

Source

pub fn create_new_inode(&self) -> Inode

Create an inode that doesn’t exist in the repository, but doesn’t put it into the repository.

Source

pub fn add_inode( &mut self, inode: Option<Inode>, path: &Path, is_dir: bool, ) -> Result<()>

Source

pub fn inode_is_ancestor_of(&self, a: Inode, b: Inode) -> bool

Source

pub fn move_file( &mut self, path: &Path, path_: &Path, is_dir: bool, ) -> Result<()>

Source

pub fn rec_delete(&mut self, key: Inode) -> Result<bool>

Source

pub fn remove_file(&mut self, path: &Path) -> Result<()>

Removes a file from the repository.

Source§

impl<'env, R: Rng> MutTxn<'env, R>

Source

pub fn remove_redundant_edges( &mut self, branch: &mut Branch, forward: &[(Key<PatchId>, Edge)], ) -> Result<()>

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn record( &mut self, state: &mut RecordState, branch: &Branch, working_copy: &Path, prefix: Option<&Path>, ) -> Result<()>

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn apply( &mut self, branch: &mut Branch, patch: &Patch, patch_id: PatchId, timestamp: ApplyTimestamp, ) -> Result<()>

Applies a patch to a repository. “new_patches” are patches that just this repository has, and the remote repository doesn’t have.

Source

pub fn reconnect_parents_children( &mut self, branch: &mut Branch, patch_id: PatchId, to: Key<PatchId>, parents: &mut HashSet<Key<PatchId>>, children: &mut HashSet<Edge>, ) -> Result<()>

Add pseudo edges from all keys of parents to all dest of the edges in children, with the same edge flags as in children, plus PSEUDO_EDGE.

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn apply_patches<F, P: ToPrefixes>( &mut self, branch: &mut Branch, r: &Path, remote_patches: &[(Hash, Patch)], partial_paths: P, f: F, ) -> Result<()>
where F: FnMut(usize, &Hash),

Assumes all patches have been downloaded. The third argument remote_patches needs to contain at least all the patches we want to apply, and the fourth one local_patches at least all the patches the other repository doesn’t have.

Source

pub fn apply_patches_rec( &mut self, branch: &mut Branch, patches: &[(Hash, Patch)], patch_hash: &Hash, patch: &Patch, new_patches_count: &mut usize, ) -> Result<()>

Lower-level applier. This function only applies patches as found in patches_dir, following dependencies recursively. It outputs neither the repository nor the “changes file” of the branch, necessary to exchange patches locally or over HTTP.

Source

pub fn apply_local_patch( &mut self, branch: &mut Branch, working_copy: &Path, hash: &Hash, patch: &Patch, inode_updates: &HashSet<InodeUpdate>, is_pending: bool, ) -> Result<PatchId>

Apply a patch from a local record: register it, give it a hash, and then apply.

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn list_conflict_files( &mut self, branch_name: &str, prefixes: &[&str], ) -> Result<Vec<PathBuf>>

Collect names of files with conflicts

As conflicts have an internal representation, it can be determined exactly which files contain conflicts.

Source

pub fn output_repository( &mut self, branch: &mut Branch, working_copy: &Path, prefixes: &Prefixes, pending: &Patch, local_pending: &HashSet<InodeUpdate>, ) -> Result<()>

Source

pub fn output_repository_no_pending( &mut self, branch: &mut Branch, working_copy: &Path, prefixes: &Prefixes, ) -> Result<()>

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn remove_up_context_repair( &mut self, branch: &mut Branch, key: Key<PatchId>, patch_id: PatchId, edges: &mut HashMap<Key<PatchId>, Edge>, ) -> Result<()>

Source

pub fn remove_down_context_repair( &mut self, branch: &mut Branch, key: Key<PatchId>, patch_id: PatchId, edges: &mut HashMap<Key<PatchId>, Edge>, ) -> Result<()>

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn unrecord( &mut self, branch: &mut Branch, patch_id: PatchId, patch: &Patch, ) -> Result<bool>

Source

pub fn unapply( &mut self, branch: &mut Branch, patch_id: PatchId, patch: &Patch, unused_in_other_branch: bool, ) -> Result<()>

Unrecord the patch, returning true if and only if another branch still uses this patch.

Source§

impl<'env, T: Rng> MutTxn<'env, T>

Source

pub fn output_changes_file<P: AsRef<Path>>( &mut self, branch: &Branch, path: P, ) -> Result<()>

Source

pub fn branch_patches( &mut self, branch: &Branch, ) -> HashSet<(Hash, ApplyTimestamp)>

Source

pub fn fork(&mut self, branch: &Branch, new_name: &str) -> Result<Branch>

Source

pub fn add_file<P: AsRef<Path>>(&mut self, path: P, is_dir: bool) -> Result<()>

Source

pub fn file_nodes_fold<A, F: FnMut(A, Key<PatchId>) -> A>( &self, branch: &Branch, init: A, f: F, ) -> Result<A>