Skip to content

Commit

Permalink
default_index: adopt revset engine and graph iterator modules
Browse files Browse the repository at this point in the history
The revset engine and the graph iterator are specific to the default
index implementation, so they belong in the same module.
martinvonz committed Jan 7, 2024
1 parent 0046af8 commit f0182ad
Showing 7 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/src/default_index/composite.rs
Original file line number Diff line number Diff line change
@@ -26,12 +26,13 @@ use super::entry::{
};
use super::readonly::ReadonlyIndexSegment;
use super::rev_walk::RevWalk;
use super::revset_engine;
use crate::backend::{ChangeId, CommitId};
use crate::hex_util;
use crate::index::Index;
use crate::object_id::{HexPrefix, ObjectId, PrefixResolution};
use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError};
use crate::store::Store;
use crate::{default_revset_engine, hex_util};

pub(super) trait IndexSegment: Send + Sync {
fn num_parent_commits(&self) -> u32;
@@ -299,7 +300,7 @@ impl<'a> CompositeIndex<'a> {
expression: &ResolvedExpression,
store: &Arc<Store>,
) -> Result<Box<dyn Revset<'a> + 'a>, RevsetEvaluationError> {
let revset_impl = default_revset_engine::evaluate(expression, store, *self)?;
let revset_impl = revset_engine::evaluate(expression, store, *self)?;
Ok(Box::new(revset_impl))
}
}
2 changes: 2 additions & 0 deletions lib/src/default_index/mod.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ mod entry;
mod mutable;
mod readonly;
mod rev_walk;
pub mod revset_engine;
pub mod revset_graph_iterator;
mod store;

pub use self::composite::{AsCompositeIndex, CompositeIndex, IndexLevelStats, IndexStats};
4 changes: 2 additions & 2 deletions lib/src/default_index/readonly.rs
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@ use thiserror::Error;
use super::composite::{AsCompositeIndex, CompositeIndex, IndexSegment};
use super::entry::{IndexPosition, LocalPosition, SmallIndexPositionsVec};
use super::mutable::DefaultMutableIndex;
use super::revset_engine;
use crate::backend::{ChangeId, CommitId};
use crate::default_revset_engine;
use crate::index::{Index, MutableIndex, ReadonlyIndex};
use crate::object_id::{HexPrefix, ObjectId, PrefixResolution};
use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError};
@@ -533,7 +533,7 @@ impl ReadonlyIndex for DefaultReadonlyIndex {
expression: &ResolvedExpression,
store: &Arc<Store>,
) -> Result<Box<dyn Revset<'static>>, RevsetEvaluationError> {
let revset_impl = default_revset_engine::evaluate(expression, store, self.clone())?;
let revset_impl = revset_engine::evaluate(expression, store, self.clone())?;
Ok(Box::new(revset_impl))
}

Original file line number Diff line number Diff line change
@@ -23,9 +23,9 @@ use std::sync::Arc;

use itertools::Itertools;

use super::revset_graph_iterator::RevsetGraphIterator;
use crate::backend::{ChangeId, CommitId, MillisSinceEpoch};
use crate::default_index::{AsCompositeIndex, CompositeIndex, IndexEntry, IndexPosition};
use crate::default_revset_graph_iterator::RevsetGraphIterator;
use crate::id_prefix::{IdIndex, IdIndexSource, IdIndexSourceEntry};
use crate::matchers::{EverythingMatcher, Matcher, PrefixMatcher, Visit};
use crate::object_id::{HexPrefix, PrefixResolution};
File renamed without changes.
2 changes: 0 additions & 2 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -27,8 +27,6 @@ pub mod commit_builder;
pub mod conflicts;
pub mod dag_walk;
pub mod default_index;
pub mod default_revset_engine;
pub mod default_revset_graph_iterator;
pub mod default_submodule_store;
pub mod diff;
pub mod file_util;
2 changes: 1 addition & 1 deletion lib/tests/test_default_revset_graph_iterator.rs
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@

use itertools::Itertools;
use jj_lib::commit::Commit;
use jj_lib::default_index::revset_engine::{evaluate, RevsetImpl};
use jj_lib::default_index::DefaultReadonlyIndex;
use jj_lib::default_revset_engine::{evaluate, RevsetImpl};
use jj_lib::repo::{ReadonlyRepo, Repo as _};
use jj_lib::revset::ResolvedExpression;
use jj_lib::revset_graph::RevsetGraphEdge;

0 comments on commit f0182ad

Please sign in to comment.