Skip to content

Commit

Permalink
RevsetGraphIterator: make generic over graph node type
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjmnt4n committed May 3, 2024
1 parent 19563fe commit f3c0880
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 238 deletions.
6 changes: 4 additions & 2 deletions lib/src/default_index/revset_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<I: AsCompositeIndex + Clone> RevsetImpl<I> {
pub fn iter_graph_impl(
&self,
skip_transitive_edges: bool,
) -> impl Iterator<Item = (CommitId, Vec<RevsetGraphEdge>)> {
) -> impl Iterator<Item = (CommitId, Vec<RevsetGraphEdge<CommitId>>)> {
let index = self.index.clone();
let walk = self.inner.positions();
let mut graph_walk = RevsetGraphWalk::new(walk, skip_transitive_edges);
Expand Down Expand Up @@ -147,7 +147,9 @@ impl<I: AsCompositeIndex + Clone> Revset for RevsetImpl<I> {
}))
}

fn iter_graph<'a>(&self) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge>)> + 'a>
fn iter_graph<'a>(
&self,
) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge<CommitId>>)> + 'a>
where
Self: 'a,
{
Expand Down
4 changes: 2 additions & 2 deletions lib/src/default_index/revset_graph_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl IndexGraphEdge {
IndexGraphEdge { target, edge_type }
}

fn to_revset_edge(self, index: &CompositeIndex) -> RevsetGraphEdge {
fn to_revset_edge(self, index: &CompositeIndex) -> RevsetGraphEdge<CommitId> {
RevsetGraphEdge {
target: index.entry_by_pos(self.target).commit_id(),
edge_type: self.edge_type,
Expand Down Expand Up @@ -333,7 +333,7 @@ impl<'a> RevsetGraphWalk<'a> {
}

impl RevWalk<CompositeIndex> for RevsetGraphWalk<'_> {
type Item = (CommitId, Vec<RevsetGraphEdge>);
type Item = (CommitId, Vec<RevsetGraphEdge<CommitId>>);

fn next(&mut self, index: &CompositeIndex) -> Option<Self::Item> {
let position = self.next_index_position(index)?;
Expand Down
4 changes: 3 additions & 1 deletion lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,9 @@ pub trait Revset: fmt::Debug {
where
Self: 'a;

fn iter_graph<'a>(&self) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge>)> + 'a>
fn iter_graph<'a>(
&self,
) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge<CommitId>>)> + 'a>
where
Self: 'a;

Expand Down
Loading

0 comments on commit f3c0880

Please sign in to comment.