pub struct GenericTxn<T, R> { /* private fields */ }
Expand description
Common type for both mutable transactions (MutTxn
) and immutable
transaction (Txn
). All of Txn
’s methods are also MutTxn
’s
methods.
Implementations§
Source§impl<U: Transaction, R> GenericTxn<U, R>
impl<U: Transaction, R> GenericTxn<U, R>
Source§impl<'env, R: Rng> GenericTxn<MutTxn<'env, ()>, R>
Branches and commits.
impl<'env, R: Rng> GenericTxn<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<U: Transaction, R> GenericTxn<U, R>
impl<U: Transaction, R> GenericTxn<U, R>
Sourcepub fn has_branch(&self, name: &str) -> bool
pub fn has_branch(&self, name: &str) -> bool
Does this repository has a branch called name
?
Sourcepub fn get_branch<'name>(&self, name: &str) -> Option<Branch>
pub fn get_branch<'name>(&self, name: &str) -> Option<Branch>
Get the branch with the given name, if it exists.
Sourcepub fn get_nodes<'a>(
&'a self,
branch: &Branch,
key: Key<PatchId>,
edge: Option<&Edge>,
) -> Option<&'a Edge>
pub fn get_nodes<'a>( &'a self, branch: &Branch, key: Key<PatchId>, edge: Option<&Edge>, ) -> Option<&'a Edge>
Return the first edge of this key
if edge
is None
, and
a pointer to the edge in the database if edge
is Some
.
Sourcepub fn iter_nodes<'a>(
&'a self,
branch: &'a Branch,
key: Option<(Key<PatchId>, Option<&Edge>)>,
) -> NodesIterator<'a, U>
pub fn iter_nodes<'a>( &'a self, branch: &'a Branch, key: Option<(Key<PatchId>, Option<&Edge>)>, ) -> NodesIterator<'a, U>
An iterator over keys and edges, in branch branch
, starting
from key and edge specified by key
. If key
is None
, the
iterations start from the first key and first edge. If key
is of the form Some(a, None)
, they start from the first edge
of key a
. If key
is of the from Some(a, Some(b))
, they
start from the first key and edge that is at least (a, b)
.
pub fn iter_parents<'a>( &'a self, branch: &'a Branch, key: Key<PatchId>, flag: EdgeFlags, ) -> ParentsIterator<'a, U>
Sourcepub fn iter_branches<'a>(
&'a self,
key: Option<&SmallStr<'_>>,
) -> BranchIterator<'a, U>
pub fn iter_branches<'a>( &'a self, key: Option<&SmallStr<'_>>, ) -> BranchIterator<'a, U>
An iterator over branches in the database, starting from the given branch name.
Sourcepub fn iter_partials<'a>(&'a self, branch: &str) -> PartialsIterator<'a, U>
pub fn iter_partials<'a>(&'a self, branch: &str) -> PartialsIterator<'a, U>
An iterator over branches in the database, starting from the given branch name.
Sourcepub fn iter_patches<'a>(
&'a self,
branch: &'a Branch,
key: Option<PatchId>,
) -> PatchesIterator<'a, U>
pub fn iter_patches<'a>( &'a self, branch: &'a Branch, key: Option<PatchId>, ) -> PatchesIterator<'a, U>
An iterator over patches in a branch, in the alphabetical order of their hash.
Sourcepub fn rev_iter_applied<'a>(
&'a self,
branch: &'a Branch,
key: Option<ApplyTimestamp>,
) -> RevAppliedIterator<'a, U>
pub fn rev_iter_applied<'a>( &'a self, branch: &'a Branch, key: Option<ApplyTimestamp>, ) -> RevAppliedIterator<'a, U>
An iterator over patches in a branch, in the reverse order in which they were applied.
Sourcepub fn iter_applied<'a>(
&'a self,
branch: &'a Branch,
key: Option<ApplyTimestamp>,
) -> AppliedIterator<'a, U>
pub fn iter_applied<'a>( &'a self, branch: &'a Branch, key: Option<ApplyTimestamp>, ) -> AppliedIterator<'a, U>
An iterator over patches in a branch in the order in which they were applied.
Sourcepub fn iter_tree<'a>(
&'a self,
key: Option<(&FileId<'_>, Option<Inode>)>,
) -> TreeIterator<'a, U>
pub fn iter_tree<'a>( &'a self, key: Option<(&FileId<'_>, Option<Inode>)>, ) -> TreeIterator<'a, U>
An iterator over files and directories currently tracked by
Pijul, starting from the given FileId
. The Inode
s returned
by the iterator can be used to form new FileId
s and traverse
the tree from top to bottom.
The set of tracked files is changed by the following operations: outputting the repository, adding, deleting and moving files. It is not related to branches, but only to the files actually present on the file system.
Sourcepub fn iter_revtree<'a>(
&'a self,
key: Option<(Inode, Option<&FileId<'_>>)>,
) -> RevtreeIterator<'a, U>
pub fn iter_revtree<'a>( &'a self, key: Option<(Inode, Option<&FileId<'_>>)>, ) -> RevtreeIterator<'a, U>
An iterator over files and directories, following directories in the opposite direction.
Sourcepub fn iter_inodes<'a>(
&'a self,
key: Option<(Inode, Option<FileHeader>)>,
) -> InodesIterator<'a, U>
pub fn iter_inodes<'a>( &'a self, key: Option<(Inode, Option<FileHeader>)>, ) -> InodesIterator<'a, U>
An iterator over the “inodes” database, which contains correspondences between files on the filesystem and the files in the graph.
Sourcepub fn iter_external<'a>(
&'a self,
key: Option<(PatchId, Option<HashRef<'_>>)>,
) -> ExternalIterator<'a, U>
pub fn iter_external<'a>( &'a self, key: Option<(PatchId, Option<HashRef<'_>>)>, ) -> ExternalIterator<'a, U>
Iterator over the PatchId
to Hash
correspondence.
Sourcepub fn iter_internal<'a>(
&'a self,
key: Option<(HashRef<'_>, Option<PatchId>)>,
) -> InternalIterator<'a, U>
pub fn iter_internal<'a>( &'a self, key: Option<(HashRef<'_>, Option<PatchId>)>, ) -> InternalIterator<'a, U>
Iterator over the Hash
to PatchId
correspondence.
Sourcepub fn iter_revdep<'a>(
&'a self,
key: Option<(PatchId, Option<PatchId>)>,
) -> RevdepIterator<'a, U>
pub fn iter_revdep<'a>( &'a self, key: Option<(PatchId, Option<PatchId>)>, ) -> RevdepIterator<'a, U>
Iterator over reverse dependencies ((k, v)
is in the reverse
dependency table if v
depends on k
, and both are in at
least one branch).
Sourcepub fn iter_dep<'a>(
&'a self,
key: Option<(PatchId, Option<PatchId>)>,
) -> DepIterator<'a, U>
pub fn iter_dep<'a>( &'a self, key: Option<(PatchId, Option<PatchId>)>, ) -> DepIterator<'a, U>
Iterator over dependencies.
Sourcepub fn iter_contents<'a>(
&'a self,
key: Option<Key<PatchId>>,
) -> ContentsIterator<'a, U>
pub fn iter_contents<'a>( &'a self, key: Option<Key<PatchId>>, ) -> ContentsIterator<'a, U>
An iterator over line contents (common to all branches).
Sourcepub fn iter_cemetery<'a>(
&'a self,
key: Key<PatchId>,
edge: Edge,
) -> CemeteryIterator<'a, U>
pub fn iter_cemetery<'a>( &'a self, key: Key<PatchId>, edge: Edge, ) -> CemeteryIterator<'a, U>
An iterator over edges in the cemetery.
Sourcepub fn iter_touched<'a>(&'a self, key: Key<PatchId>) -> TouchedIterator<'a, U>
pub fn iter_touched<'a>(&'a self, key: Key<PatchId>) -> TouchedIterator<'a, U>
An iterator over patches that touch a certain file.
Sourcepub fn get_touched<'a>(&'a self, key: Key<PatchId>, patch: PatchId) -> bool
pub fn get_touched<'a>(&'a self, key: Key<PatchId>, patch: PatchId) -> bool
Tell whether a patch touches a file
Sourcepub fn get_tree<'a>(&'a self, key: &FileId<'_>) -> Option<Inode>
pub fn get_tree<'a>(&'a self, key: &FileId<'_>) -> Option<Inode>
Get the Inode
of a give FileId
. A FileId
is itself
composed of an inode and a name, hence this can be used to
traverse the tree of tracked files from top to bottom.
Sourcepub fn get_revtree<'a>(&'a self, key: Inode) -> Option<FileId<'a>>
pub fn get_revtree<'a>(&'a self, key: Inode) -> Option<FileId<'a>>
Get the parent FileId
of a given Inode
. A FileId
is
itself composed of an Inode
and a name, so this can be used
to traverse the tree of tracked files from bottom to top
(starting from a leaf).
Sourcepub fn get_inodes<'a>(&'a self, key: Inode) -> Option<FileHeader>
pub fn get_inodes<'a>(&'a self, key: Inode) -> Option<FileHeader>
Get the key in branches for the given Inode
, as well as
meta-information on the file (permissions, and whether it has
been moved or deleted compared to the branch).
This table is updated every time the repository is output, and when files are moved or deleted. It is meant to be synchronised with the current branch (if any).
Sourcepub fn get_revinodes(&self, key: Key<PatchId>) -> Option<Inode>
pub fn get_revinodes(&self, key: Key<PatchId>) -> Option<Inode>
Get the Inode
corresponding to key
in branches (see the
documentation for get_inodes
).
Sourcepub fn get_contents<'a>(&'a self, key: Key<PatchId>) -> Option<Value<'a, U>>
pub fn get_contents<'a>(&'a self, key: Key<PatchId>) -> Option<Value<'a, U>>
Get the contents of a line.
Sourcepub fn get_internal(&self, key: HashRef<'_>) -> Option<PatchId>
pub fn get_internal(&self, key: HashRef<'_>) -> Option<PatchId>
Get the PatchId
(or internal patch identifier) of the
provided patch hash.
Sourcepub fn get_external<'a>(&'a self, key: PatchId) -> Option<HashRef<'a>>
pub fn get_external<'a>(&'a self, key: PatchId) -> Option<HashRef<'a>>
Get the HashRef
(external patch identifier) of the provided
internal patch identifier.
Sourcepub fn get_patch(
&self,
patch_set: &Db<PatchId, ApplyTimestamp>,
patchid: PatchId,
) -> Option<ApplyTimestamp>
pub fn get_patch( &self, patch_set: &Db<PatchId, ApplyTimestamp>, patchid: PatchId, ) -> Option<ApplyTimestamp>
Get the patch number in the branch. Patch numbers are guaranteed to always increase when a new patch is applied, but are not necessarily consecutive.
Sourcepub fn get_revdep(
&self,
patch: PatchId,
dep: Option<PatchId>,
) -> Option<PatchId>
pub fn get_revdep( &self, patch: PatchId, dep: Option<PatchId>, ) -> Option<PatchId>
Get the smallest patch id that depends on patch
(and is at
least dep
in alphabetical order if dep
, is Some
).
Sourcepub fn get_dep(&self, patch: PatchId, dep: Option<PatchId>) -> Option<PatchId>
pub fn get_dep(&self, patch: PatchId, dep: Option<PatchId>) -> Option<PatchId>
Get the smallest patch id that patch
depends on (and is at
least dep
in alphabetical order if dep
, is Some
).
Sourcepub fn debug<W>(&self, branch_name: &str, w: &mut W, exclude_parents: bool)where
W: Write,
pub fn debug<W>(&self, branch_name: &str, w: &mut W, exclude_parents: bool)where
W: Write,
Dump the graph of a branch into a writer, in dot format.
Sourcepub fn debug_folders<W>(&self, branch_name: &str, w: &mut W)where
W: Write,
pub fn debug_folders<W>(&self, branch_name: &str, w: &mut W)where
W: Write,
Dump the graph of a branch into a writer, in dot format.
Source§impl<'env, R: Rng> GenericTxn<MutTxn<'env, ()>, R>
Low-level operations on mutable transactions.
impl<'env, R: Rng> GenericTxn<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> GenericTxn<MutTxn<'env, ()>, R>
impl<'env, R: Rng> GenericTxn<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<A: Transaction, R> GenericTxn<A, R>
impl<A: Transaction, R> GenericTxn<A, R>
Sourcepub fn list_files(&self, inode: Inode) -> Result<Vec<PathBuf>>
pub fn list_files(&self, inode: Inode) -> Result<Vec<PathBuf>>
Returns a vector containing all files in the repository.
Sourcepub fn list_files_under_inode(
&self,
inode: Inode,
) -> Vec<(SmallString, Option<Key<PatchId>>, Inode)>
pub fn list_files_under_inode( &self, inode: Inode, ) -> Vec<(SmallString, Option<Key<PatchId>>, Inode)>
Returns a list of files under the given inode.
Sourcepub fn list_files_under_node(
&self,
branch: &Branch,
key: Key<PatchId>,
) -> BTreeMap<Key<PatchId>, Vec<(FileMetadata, &str)>>
pub fn list_files_under_node( &self, branch: &Branch, key: Key<PatchId>, ) -> BTreeMap<Key<PatchId>, Vec<(FileMetadata, &str)>>
Returns a list of files under the given inode.
pub fn is_directory(&self, inode: &Inode) -> bool
Sourcepub fn find_inode(&self, path: &Path) -> Result<Inode>
pub fn find_inode(&self, path: &Path) -> Result<Inode>
Find the inode corresponding to that path, or return an error if there’s no such inode.
pub fn file_names( &self, branch: &Branch, key: Key<PatchId>, ) -> Vec<(Key<PatchId>, FileMetadata, &str)>
pub fn prefix_keys( &self, branch: &Branch, path: &str, ) -> Result<Vec<Key<PatchId>>>
Source§impl<U: Transaction, R> GenericTxn<U, R>
impl<U: Transaction, R> GenericTxn<U, R>
pub fn new_patch<I: Iterator<Item = Hash>>( &self, branch: &Branch, authors: Vec<String>, name: String, description: Option<String>, timestamp: DateTime<Utc>, changes: Vec<Change<ChangeContext<Hash>>>, extra_dependencies: I, flag: PatchFlags, ) -> Patch
pub fn dependencies<'a, I: Iterator<Item = &'a Change<ChangeContext<Hash>>>>( &self, branch: &Branch, changes: I, ) -> HashSet<Hash>
pub fn minimize_deps(&self, deps: &HashSet<Hash>) -> HashSet<Hash>
Source§impl<A: Transaction, R> GenericTxn<A, R>
impl<A: Transaction, R> GenericTxn<A, R>
Sourcepub fn external_key(&self, key: &Key<PatchId>) -> Option<Key<Option<Hash>>>
pub fn external_key(&self, key: &Key<PatchId>) -> Option<Key<Option<Hash>>>
Gets the external key corresponding to the given key, returning an owned vector. If the key is just a patch internal hash, it returns the corresponding external hash.
pub fn external_hash(&self, key: PatchId) -> HashRef<'_>
Sourcepub fn new_internal(&self, ext: HashRef<'_>) -> PatchId
pub fn new_internal(&self, ext: HashRef<'_>) -> PatchId
Create a new internal patch id, register it in the “external” and “internal” bases, and write the result in its second argument (“result”).
Source§impl<A: Transaction, R> GenericTxn<A, R>
impl<A: Transaction, R> GenericTxn<A, R>
Source§impl<'a, A: Transaction + 'a, R> GenericTxn<A, R>
impl<'a, A: Transaction + 'a, R> GenericTxn<A, R>
Source§impl<A: Transaction, R: Rng> GenericTxn<A, R>
impl<A: Transaction, R: Rng> GenericTxn<A, R>
Source§impl<U: Transaction, R> GenericTxn<U, R>
impl<U: Transaction, R> GenericTxn<U, R>
pub fn globalize_change( &self, change: Change<Rc<RefCell<ChangeContext<PatchId>>>>, ) -> Change<ChangeContext<Hash>>
pub fn globalize_record( &self, change: Record<Rc<RefCell<ChangeContext<PatchId>>>>, ) -> Record<ChangeContext<Hash>>
Source§impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
impl<'env, T: Rng> GenericTxn<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<U: Transaction, R> GenericTxn<U, R>
impl<U: Transaction, R> GenericTxn<U, R>
Sourcepub fn find_alive_ancestors(
&self,
find_alive: &mut FindAlive,
branch: &Branch,
alive: &mut Vec<Key<PatchId>>,
file_ancestor: &mut Option<Key<PatchId>>,
files: &mut Vec<(Key<PatchId>, Edge)>,
) -> bool
pub fn find_alive_ancestors( &self, find_alive: &mut FindAlive, branch: &Branch, alive: &mut Vec<Key<PatchId>>, file_ancestor: &mut Option<Key<PatchId>>, files: &mut Vec<(Key<PatchId>, Edge)>, ) -> bool
Recursively find all ancestors by doing a DFS, and collect all edges until finding an alive ancestor.
Returns whether or not at least one traversed vertex was dead
(or otherwise said, returns false
if and only if there all
vertices in find_alive
are alive).
Sourcepub fn find_alive_descendants(
&self,
find_alive: &mut FindAlive,
branch: &Branch,
alive: &mut Vec<Key<PatchId>>,
) -> bool
pub fn find_alive_descendants( &self, find_alive: &mut FindAlive, branch: &Branch, alive: &mut Vec<Key<PatchId>>, ) -> bool
Recursively find all descendants by doing a DFS on deleted edges (including folder edges), and collect all edges until finding an alive or zombie descendant.
Returns whether or not at least one traversed vertex was dead
(or otherwise said, returns false
if and only if there all
vertices in find_alive
are alive).
Sourcepub fn find_alive_nonfolder_descendants(
&self,
branch: &Branch,
find_alive: &mut FindAlive,
alive: &mut HashSet<Key<PatchId>>,
file: &mut Option<Key<PatchId>>,
current: Key<PatchId>,
)
pub fn find_alive_nonfolder_descendants( &self, branch: &Branch, find_alive: &mut FindAlive, alive: &mut HashSet<Key<PatchId>>, file: &mut Option<Key<PatchId>>, current: Key<PatchId>, )
Find the alive descendants of current
. cache
is here to
avoid cycles, and alive
is an accumulator of the
result. Since this search stops at files, if the file
containing these lines is ever hit, it will be put in file
.
Sourcepub fn find_alive_nonfolder_ancestors(
&self,
branch: &Branch,
find_alive: &mut FindAlive,
alive: &mut HashSet<Key<PatchId>>,
file: &mut Option<Key<PatchId>>,
current: Key<PatchId>,
)
pub fn find_alive_nonfolder_ancestors( &self, branch: &Branch, find_alive: &mut FindAlive, alive: &mut HashSet<Key<PatchId>>, file: &mut Option<Key<PatchId>>, current: Key<PatchId>, )
Find the alive ancestors of current
. cache
is here to
avoid cycles, and alive
is an accumulator of the
result. Since this search stops at files, if the file
containing these lines is ever hit, it will be put in file
.
Source§impl<U: Transaction, R> GenericTxn<U, R>
impl<U: Transaction, R> GenericTxn<U, R>
Sourcepub fn internal_hash(&self, e: &Option<Hash>, internal: PatchId) -> PatchId
pub fn internal_hash(&self, e: &Option<Hash>, internal: PatchId) -> PatchId
Return the patch id corresponding to e
, or internal
if e==None
.
Sourcepub fn internal_key(
&self,
key: &Key<Option<Hash>>,
internal: PatchId,
) -> Key<PatchId>
pub fn internal_key( &self, key: &Key<Option<Hash>>, internal: PatchId, ) -> Key<PatchId>
Fetch the internal key for this external key (or internal
if
key.patch
is None
).
pub fn internal_key_unwrap(&self, key: &Key<Option<Hash>>) -> Key<PatchId>
Source§impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
impl<'env, T: Rng> GenericTxn<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<()>
pub fn apply_patches<F, P: ToPrefixes>( &mut self, branch: &mut Branch, r: &Path, remote_patches: &[(Hash, Patch)], partial_paths: P, f: F, ) -> Result<()>
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> GenericTxn<MutTxn<'env, ()>, T>
impl<'env, T: Rng> GenericTxn<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.
pub fn output_repository( &mut self, branch: &mut Branch, working_copy: &Path, prefixes: &Prefixes, pending: &Patch, local_pending: &HashSet<InodeUpdate>, ) -> Result<()>
pub fn output_repository_no_pending( &mut self, branch: &mut Branch, working_copy: &Path, prefixes: &Prefixes, ) -> Result<()>
Source§impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
pub fn remove_up_context_repair( &mut self, branch: &mut Branch, key: Key<PatchId>, patch_id: PatchId, edges: &mut HashMap<Key<PatchId>, Edge>, ) -> Result<()>
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> GenericTxn<MutTxn<'env, ()>, T>
impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
Source§impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
impl<'env, T: Rng> GenericTxn<MutTxn<'env, ()>, T>
pub fn output_changes_file<P: AsRef<Path>>( &mut self, branch: &Branch, path: P, ) -> Result<()>
pub fn branch_patches( &mut self, branch: &Branch, ) -> HashSet<(Hash, ApplyTimestamp)>
pub fn fork(&mut self, branch: &Branch, new_name: &str) -> Result<Branch>
pub fn add_file<P: AsRef<Path>>(&mut self, path: P, is_dir: bool) -> Result<()>
pub fn file_nodes_fold<A, F: FnMut(A, Key<PatchId>) -> A>( &self, branch: &Branch, init: A, f: F, ) -> Result<A>
Source§impl<T: Transaction, R> GenericTxn<T, R>
impl<T: Transaction, R> GenericTxn<T, R>
Sourcepub fn is_alive(&self, branch: &Branch, key: Key<PatchId>) -> bool
pub fn is_alive(&self, branch: &Branch, key: Key<PatchId>) -> bool
Tells whether a key
is alive in branch
, i.e. is either the
root, or all its ingoing edges are alive.
Sourcepub fn is_alive_or_zombie(&self, branch: &Branch, key: Key<PatchId>) -> bool
pub fn is_alive_or_zombie(&self, branch: &Branch, key: Key<PatchId>) -> bool
Tells whether a key
is alive or zombie in branch
, i.e. is
either the root, or has at least one of its incoming alive
edge is alive.
Sourcepub fn has_edge(
&self,
branch: &Branch,
key: Key<PatchId>,
min: EdgeFlags,
max: EdgeFlags,
) -> bool
pub fn has_edge( &self, branch: &Branch, key: Key<PatchId>, min: EdgeFlags, max: EdgeFlags, ) -> bool
Test whether key
has a neighbor with flag flag0
. If
include_pseudo
, this includes pseudo-neighbors.
Sourcepub fn get_file<'a>(
&'a self,
branch: &Branch,
key: Key<PatchId>,
) -> Vec<Key<PatchId>>
pub fn get_file<'a>( &'a self, branch: &Branch, key: Key<PatchId>, ) -> Vec<Key<PatchId>>
Tells which paths (of folder nodes) a key is in.