Type Definition libpijul_compat::MutTxn
source · pub type MutTxn<'env, R> = GenericTxn<MutTxn<'env, ()>, R>;
Expand description
A mutable transaction on a repository.
Implementations§
source§impl<'env, R: Rng> MutTxn<'env, R>
impl<'env, R: Rng> MutTxn<'env, R>
Branches and commits.
sourcepub fn open_branch<'name>(&mut self, name: &str) -> Result<Branch>
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.
sourcepub fn commit_branch(&mut self, branch: Branch) -> Result<()>
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§impl<'env, R: Rng> MutTxn<'env, R>
impl<'env, R: Rng> MutTxn<'env, R>
Low-level operations on mutable transactions.
sourcepub fn drop_branch(&mut self, branch: &str) -> Result<bool>
pub fn drop_branch(&mut self, branch: &str) -> Result<bool>
Delete a branch, destroying its associated graph and patch set.
sourcepub fn put_nodes(
&mut self,
branch: &mut Branch,
key: Key<PatchId>,
edge: &Edge
) -> Result<bool>
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.
sourcepub fn put_nodes_with_rev(
&mut self,
branch: &mut Branch,
key: Key<PatchId>,
edge: Edge
) -> Result<bool>
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.
sourcepub fn del_nodes(
&mut self,
branch: &mut Branch,
key: Key<PatchId>,
edge: Option<&Edge>
) -> Result<bool>
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
.
sourcepub fn del_nodes_with_rev(
&mut self,
branch: &mut Branch,
key: Key<PatchId>,
edge: Edge
) -> Result<bool>
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.
sourcepub fn put_tree(&mut self, key: &FileId<'_>, edge: Inode) -> Result<bool>
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 Inode
s 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.
sourcepub fn del_tree(&mut self, key: &FileId<'_>, edge: Option<Inode>) -> Result<bool>
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.
sourcepub fn put_revtree(&mut self, key: Inode, value: &FileId<'_>) -> Result<bool>
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).
sourcepub fn del_revtree(
&mut self,
key: Inode,
value: Option<&FileId<'_>>
) -> Result<bool>
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).
sourcepub fn del_inodes(
&mut self,
key: Inode,
value: Option<FileHeader>
) -> Result<bool>
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.
sourcepub fn replace_inodes(&mut self, key: Inode, value: FileHeader) -> Result<bool>
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
).
sourcepub fn replace_revinodes(
&mut self,
key: Key<PatchId>,
value: Inode
) -> Result<bool>
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
).
sourcepub fn del_revinodes(
&mut self,
key: Key<PatchId>,
value: Option<Inode>
) -> Result<bool>
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.
sourcepub fn put_contents(
&mut self,
key: Key<PatchId>,
value: UnsafeValue
) -> Result<bool>
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.
sourcepub fn del_contents(
&mut self,
key: Key<PatchId>,
value: Option<UnsafeValue>
) -> Result<bool>
pub fn del_contents(
&mut self,
key: Key<PatchId>,
value: Option<UnsafeValue>
) -> Result<bool>
Remove the contents of a line.
sourcepub fn put_internal(&mut self, key: HashRef<'_>, value: PatchId) -> Result<bool>
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.
sourcepub fn del_internal(&mut self, key: HashRef<'_>) -> Result<bool>
pub fn del_internal(&mut self, key: HashRef<'_>) -> Result<bool>
Unregister the internal identifier of a patch. Remember to also unregister its external id.
sourcepub fn put_external(&mut self, key: PatchId, value: HashRef<'_>) -> Result<bool>
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.
sourcepub fn del_external(&mut self, key: PatchId) -> Result<bool>
pub fn del_external(&mut self, key: PatchId) -> Result<bool>
Unregister the extern identifier of a patch. Remember to also unregister its internal id.
sourcepub fn put_patches(
&mut self,
branch: &mut Db<PatchId, ApplyTimestamp>,
value: PatchId,
time: ApplyTimestamp
) -> Result<bool>
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.
sourcepub fn del_patches(
&mut self,
branch: &mut Db<PatchId, ApplyTimestamp>,
value: PatchId
) -> Result<bool>
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.
sourcepub fn put_revpatches(
&mut self,
branch: &mut Db<ApplyTimestamp, PatchId>,
time: ApplyTimestamp,
value: PatchId
) -> Result<bool>
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.
sourcepub fn del_revpatches(
&mut self,
revbranch: &mut Db<ApplyTimestamp, PatchId>,
timestamp: ApplyTimestamp,
value: PatchId
) -> Result<bool>
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.
sourcepub fn put_revdep(&mut self, patch: PatchId, revdep: PatchId) -> Result<bool>
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.
sourcepub fn put_dep(&mut self, patch: PatchId, dep: PatchId) -> Result<bool>
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.
sourcepub fn del_revdep(
&mut self,
patch: PatchId,
revdep: Option<PatchId>
) -> Result<bool>
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.
sourcepub fn del_dep(&mut self, patch: PatchId, dep: Option<PatchId>) -> Result<bool>
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.
sourcepub fn put_cemetery(
&mut self,
key: Key<PatchId>,
edge: &Edge,
patch: PatchId
) -> Result<bool>
pub fn put_cemetery(
&mut self,
key: Key<PatchId>,
edge: &Edge,
patch: PatchId
) -> Result<bool>
Add an edge to the cemetery.
sourcepub fn del_cemetery(
&mut self,
key: Key<PatchId>,
edge: &Edge,
patch: PatchId
) -> Result<bool>
pub fn del_cemetery(
&mut self,
key: Key<PatchId>,
edge: &Edge,
patch: PatchId
) -> Result<bool>
Delete an edge from the cemetery.
sourcepub fn put_touched_file(
&mut self,
file: Key<PatchId>,
patch: PatchId
) -> Result<bool>
pub fn put_touched_file(
&mut self,
file: Key<PatchId>,
patch: PatchId
) -> Result<bool>
Add the relation “patch patch
touches file file
”.
sourcepub fn del_touched_file(
&mut self,
file: Key<PatchId>,
patch: PatchId
) -> Result<bool>
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.
sourcepub fn put_partials(&mut self, name: &str, path: Key<PatchId>) -> Result<bool>
pub fn put_partials(&mut self, name: &str, path: Key<PatchId>) -> Result<bool>
Add a partial path to a branch.
sourcepub fn del_partials(&mut self, name: &str) -> Result<bool>
pub fn del_partials(&mut self, name: &str) -> Result<bool>
Remove a partial path from a branch.
sourcepub fn alloc_value(&mut self, slice: &[u8]) -> Result<UnsafeValue>
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>
impl<'env, R: Rng> MutTxn<'env, R>
pub fn mark_inode_moved(&mut self, inode: Inode)
sourcepub fn create_new_inode(&self) -> Inode
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.
pub fn add_inode(
&mut self,
inode: Option<Inode>,
path: &Path,
is_dir: bool
) -> Result<()>
pub fn inode_is_ancestor_of(&self, a: Inode, b: Inode) -> bool
pub fn move_file(&mut self, path: &Path, path_: &Path, is_dir: bool) -> Result<()>
pub fn rec_delete(&mut self, key: Inode) -> Result<bool>
sourcepub fn remove_file(&mut self, path: &Path) -> Result<()>
pub fn remove_file(&mut self, path: &Path) -> Result<()>
Removes a file from the repository.
source§impl<'env, T: Rng> MutTxn<'env, T>
impl<'env, T: Rng> MutTxn<'env, T>
sourcepub fn apply(
&mut self,
branch: &mut Branch,
patch: &Patch,
patch_id: PatchId,
timestamp: ApplyTimestamp
) -> Result<()>
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.
sourcepub 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<()>
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>
impl<'env, T: Rng> MutTxn<'env, T>
sourcepub 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),
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.
sourcepub fn apply_patches_rec(
&mut self,
branch: &mut Branch,
patches: &[(Hash, Patch)],
patch_hash: &Hash,
patch: &Patch,
new_patches_count: &mut usize
) -> Result<()>
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§impl<'env, T: Rng> MutTxn<'env, T>
impl<'env, T: Rng> MutTxn<'env, T>
sourcepub fn list_conflict_files(
&mut self,
branch_name: &str,
prefixes: &[&str]
) -> Result<Vec<PathBuf>>
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.