Struct gix_revision::Graph
source · pub struct Graph<'find, T> { /* private fields */ }
Expand description
A graph of commits which additionally allows to associate data with commits.
It starts empty, but each access may fill it with commit information. Note that the traversal can be accelerated if a commit-graph is also made available.
Implementations§
source§impl<'find, T> Graph<'find, T>
impl<'find, T> Graph<'find, T>
sourcepub fn new<Find, E>(find: Find, cache: impl Into<Option<Graph>>) -> Selfwhere
Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Result<Option<CommitRefIter<'a>>, E> + 'find,
E: Error + Send + Sync + 'static,
pub fn new<Find, E>(find: Find, cache: impl Into<Option<Graph>>) -> Selfwhere Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Result<Option<CommitRefIter<'a>>, E> + 'find, E: Error + Send + Sync + 'static,
Create a new instance with find
to retrieve commits and optionally cache
to accelerate commit access.
sourcepub fn contains(&self, id: &oid) -> bool
pub fn contains(&self, id: &oid) -> bool
Returns true if id
has data associated with it, meaning that we processed it already.
sourcepub fn get_mut(&mut self, id: &oid) -> Option<&mut T>
pub fn get_mut(&mut self, id: &oid) -> Option<&mut T>
Returns the data associated with id
if available as mutable reference.
sourcepub fn insert(&mut self, id: ObjectId, value: T) -> Option<T>
pub fn insert(&mut self, id: ObjectId, value: T) -> Option<T>
Insert id
into the graph and associate it with value
, returning the previous value associated with it if it existed.
sourcepub fn try_lookup(&mut self, id: &oid) -> Result<Option<Commit<'_>>, Error>
pub fn try_lookup(&mut self, id: &oid) -> Result<Option<Commit<'_>>, Error>
Try to lookup id
and return a handle to it for accessing its data, but don’t fail if the commit doesn’t exist.
It’s possible that commits don’t exist if the repository is shallow.
sourcepub fn lookup(&mut self, id: &oid) -> Result<Commit<'_>, Error>
pub fn lookup(&mut self, id: &oid) -> Result<Commit<'_>, Error>
Lookup id
and return a handle to it, or fail if it doesn’t exist.
sourcepub fn insert_parents(
&mut self,
id: &oid,
new_parent_data: impl FnMut(ObjectId, u64) -> T,
update_existing: impl FnMut(ObjectId, &mut T),
first_parent: bool
) -> Result<(), Error>
pub fn insert_parents( &mut self, id: &oid, new_parent_data: impl FnMut(ObjectId, u64) -> T, update_existing: impl FnMut(ObjectId, &mut T), first_parent: bool ) -> Result<(), Error>
Insert the parents of commit named id
to the graph and associate new parents with data
by calling new_parent_data(parent_id, committer_timestamp)
, or update existing parents
data with update_existing(parent_id, &mut existing_data)
.
If first_parent
is true
, only the first parent of commits will be looked at.