diff --git a/lib/src/default_revset_engine.rs b/lib/src/default_revset_engine.rs index 0c7e83e8e..a9fd94328 100644 --- a/lib/src/default_revset_engine.rs +++ b/lib/src/default_revset_engine.rs @@ -19,7 +19,6 @@ use std::iter::Peekable; use itertools::Itertools; use crate::backend::CommitId; -use crate::commit::Commit; use crate::default_index_store::IndexEntry; use crate::default_revset_graph_iterator::RevsetGraphIterator; use crate::matchers::{EverythingMatcher, Matcher, PrefixMatcher}; @@ -614,19 +613,6 @@ fn revset_for_commit_ids<'index>( RevsetImpl::new(Box::new(EagerRevset { index_entries })) } -pub fn revset_for_commits<'index>( - repo: &'index dyn Repo, - commits: &[&Commit], -) -> Box + 'index> { - let index = repo.index(); - let mut index_entries = commits - .iter() - .map(|commit| index.entry_by_id(commit.id()).unwrap()) - .collect_vec(); - index_entries.sort_by_key(|b| Reverse(b.position())); - Box::new(RevsetImpl::new(Box::new(EagerRevset { index_entries }))) -} - type PurePredicateFn<'index> = Box) -> bool + 'index>; impl<'index> ToPredicateFn<'index> for PurePredicateFn<'index> { diff --git a/lib/tests/test_default_revset_graph_iterator.rs b/lib/tests/test_default_revset_graph_iterator.rs index cfedce142..26a545471 100644 --- a/lib/tests/test_default_revset_graph_iterator.rs +++ b/lib/tests/test_default_revset_graph_iterator.rs @@ -14,13 +14,21 @@ use itertools::Itertools; use jujutsu_lib::commit::Commit; -use jujutsu_lib::default_revset_engine::revset_for_commits; use jujutsu_lib::default_revset_graph_iterator::RevsetGraphIterator; use jujutsu_lib::repo::Repo; -use jujutsu_lib::revset::RevsetGraphEdge; +use jujutsu_lib::revset::{Revset, RevsetExpression, RevsetGraphEdge}; use test_case::test_case; use testutils::{CommitGraphBuilder, TestRepo}; +fn revset_for_commits<'index>( + repo: &'index dyn Repo, + commits: &[&Commit], +) -> Box + 'index> { + RevsetExpression::commits(commits.iter().map(|commit| commit.id().clone()).collect()) + .evaluate(repo) + .unwrap() +} + fn direct(commit: &Commit) -> RevsetGraphEdge { RevsetGraphEdge::direct(commit.id().clone()) } diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index f883df299..aed557492 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -17,15 +17,15 @@ use std::path::Path; use assert_matches::assert_matches; use itertools::Itertools; use jujutsu_lib::backend::{CommitId, MillisSinceEpoch, ObjectId, Signature, Timestamp}; -use jujutsu_lib::default_revset_engine::revset_for_commits; +use jujutsu_lib::commit::Commit; use jujutsu_lib::git; use jujutsu_lib::op_store::{RefTarget, WorkspaceId}; use jujutsu_lib::repo::Repo; use jujutsu_lib::repo_path::RepoPath; use jujutsu_lib::revset::{ - optimize, parse, resolve_symbol, resolve_symbols, ReverseRevsetGraphIterator, RevsetAliasesMap, - RevsetError, RevsetExpression, RevsetFilterPredicate, RevsetGraphEdge, RevsetIteratorExt, - RevsetWorkspaceContext, + optimize, parse, resolve_symbol, resolve_symbols, ReverseRevsetGraphIterator, Revset, + RevsetAliasesMap, RevsetError, RevsetExpression, RevsetFilterPredicate, RevsetGraphEdge, + RevsetIteratorExt, RevsetWorkspaceContext, }; use jujutsu_lib::settings::GitSettings; use jujutsu_lib::workspace::Workspace; @@ -34,6 +34,14 @@ use testutils::{ create_random_commit, write_random_commit, CommitGraphBuilder, TestRepo, TestWorkspace, }; +fn revset_for_commits<'index>( + repo: &'index dyn Repo, + commits: &[&Commit], +) -> Box + 'index> { + RevsetExpression::commits(commits.iter().map(|commit| commit.id().clone()).collect()) + .evaluate(repo) + .unwrap() +} #[test_case(false ; "local backend")] #[test_case(true ; "git backend")] fn test_resolve_symbol_root(use_git: bool) {