mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
revset: pass IndexEntry iterator to graph iterator
The graph iterator is specific to the index implementation, and it needs access to `IndexEntry`, which `Revset::iter()` will soon not yield.
This commit is contained in:
parent
0b506d8461
commit
c8f387d5b3
3 changed files with 12 additions and 10 deletions
|
@ -74,7 +74,7 @@ impl<'index> Revset<'index> for RevsetImpl<'index> {
|
|||
}
|
||||
|
||||
fn iter_graph(&self) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge>)> + '_> {
|
||||
Box::new(RevsetGraphIterator::new(self))
|
||||
Box::new(RevsetGraphIterator::new(self.inner.iter()))
|
||||
}
|
||||
|
||||
fn change_id_index(&self) -> Box<dyn ChangeIdIndex + 'index> {
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::collections::{BTreeMap, HashSet};
|
|||
use crate::backend::CommitId;
|
||||
use crate::default_index_store::{IndexEntry, IndexPosition};
|
||||
use crate::nightly_shims::BTreeMapExt;
|
||||
use crate::revset::{Revset, RevsetGraphEdge, RevsetGraphEdgeType};
|
||||
use crate::revset::{RevsetGraphEdge, RevsetGraphEdgeType};
|
||||
|
||||
// Given an iterator over some set of revisions, yields the same revisions with
|
||||
// associated edge types.
|
||||
|
@ -101,9 +101,11 @@ pub struct RevsetGraphIterator<'revset, 'index> {
|
|||
}
|
||||
|
||||
impl<'revset, 'index> RevsetGraphIterator<'revset, 'index> {
|
||||
pub fn new(revset: &'revset dyn Revset<'index>) -> RevsetGraphIterator<'revset, 'index> {
|
||||
pub fn new(
|
||||
input_set_iter: Box<dyn Iterator<Item = IndexEntry<'index>> + 'revset>,
|
||||
) -> RevsetGraphIterator<'revset, 'index> {
|
||||
RevsetGraphIterator {
|
||||
input_set_iter: revset.iter(),
|
||||
input_set_iter,
|
||||
look_ahead: Default::default(),
|
||||
min_position: IndexPosition::MAX,
|
||||
edges: Default::default(),
|
||||
|
|
|
@ -66,7 +66,7 @@ fn test_graph_iterator_linearized(skip_transitive_edges: bool) {
|
|||
let root_commit = repo.store().root_commit();
|
||||
|
||||
let revset = revset_for_commits(repo.as_ref(), &[&commit_a, &commit_d]);
|
||||
let commits = RevsetGraphIterator::new(revset.as_ref())
|
||||
let commits = RevsetGraphIterator::new(revset.iter())
|
||||
.set_skip_transitive_edges(skip_transitive_edges)
|
||||
.collect_vec();
|
||||
assert_eq!(commits.len(), 2);
|
||||
|
@ -105,7 +105,7 @@ fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) {
|
|||
let root_commit = repo.store().root_commit();
|
||||
|
||||
let revset = revset_for_commits(repo.as_ref(), &[&commit_a, &commit_b, &commit_c, &commit_f]);
|
||||
let commits = RevsetGraphIterator::new(revset.as_ref())
|
||||
let commits = RevsetGraphIterator::new(revset.iter())
|
||||
.set_skip_transitive_edges(skip_transitive_edges)
|
||||
.collect_vec();
|
||||
assert_eq!(commits.len(), 4);
|
||||
|
@ -155,7 +155,7 @@ fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) {
|
|||
let root_commit = repo.store().root_commit();
|
||||
|
||||
let revset = revset_for_commits(repo.as_ref(), &[&commit_a, &commit_c, &commit_e]);
|
||||
let commits = RevsetGraphIterator::new(revset.as_ref())
|
||||
let commits = RevsetGraphIterator::new(revset.iter())
|
||||
.set_skip_transitive_edges(skip_transitive_edges)
|
||||
.collect_vec();
|
||||
assert_eq!(commits.len(), 3);
|
||||
|
@ -195,7 +195,7 @@ fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) {
|
|||
let root_commit = repo.store().root_commit();
|
||||
|
||||
let revset = revset_for_commits(repo.as_ref(), &[&commit_b, &commit_f]);
|
||||
let commits = RevsetGraphIterator::new(revset.as_ref())
|
||||
let commits = RevsetGraphIterator::new(revset.iter())
|
||||
.set_skip_transitive_edges(skip_transitive_edges)
|
||||
.collect_vec();
|
||||
assert_eq!(commits.len(), 2);
|
||||
|
@ -238,7 +238,7 @@ fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) {
|
|||
let repo = tx.commit();
|
||||
|
||||
let revset = revset_for_commits(repo.as_ref(), &[&commit_c, &commit_d, &commit_f]);
|
||||
let commits = RevsetGraphIterator::new(revset.as_ref())
|
||||
let commits = RevsetGraphIterator::new(revset.iter())
|
||||
.set_skip_transitive_edges(skip_transitive_edges)
|
||||
.collect_vec();
|
||||
assert_eq!(commits.len(), 3);
|
||||
|
@ -296,7 +296,7 @@ fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) {
|
|||
repo.as_ref(),
|
||||
&[&commit_a, &commit_d, &commit_g, &commit_h, &commit_j],
|
||||
);
|
||||
let commits = RevsetGraphIterator::new(revset.as_ref())
|
||||
let commits = RevsetGraphIterator::new(revset.iter())
|
||||
.set_skip_transitive_edges(skip_transitive_edges)
|
||||
.collect_vec();
|
||||
assert_eq!(commits.len(), 5);
|
||||
|
|
Loading…
Reference in a new issue