forked from mirrors/jj
revset: add iterator of (CommitId, ChangeId) pairs, use it in id_index
There are a few more places where we need these pairs.
This commit is contained in:
parent
4d39fdf614
commit
5b568cabcc
3 changed files with 15 additions and 7 deletions
|
@ -93,6 +93,14 @@ impl<'index> Revset<'index> for RevsetImpl<'index> {
|
|||
Box::new(self.inner.iter().map(|index_entry| index_entry.commit_id()))
|
||||
}
|
||||
|
||||
fn commit_change_ids(&self) -> Box<dyn Iterator<Item = (CommitId, ChangeId)> + '_> {
|
||||
Box::new(
|
||||
self.inner
|
||||
.iter()
|
||||
.map(|index_entry| (index_entry.commit_id(), index_entry.change_id())),
|
||||
)
|
||||
}
|
||||
|
||||
fn iter_graph(&self) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge>)> + '_> {
|
||||
Box::new(RevsetGraphIterator::new(self.inner.iter()))
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::backend::{self, ChangeId, CommitId, ObjectId};
|
|||
use crate::index::{HexPrefix, PrefixResolution};
|
||||
use crate::op_store::WorkspaceId;
|
||||
use crate::repo::Repo;
|
||||
use crate::revset::{DefaultSymbolResolver, RevsetExpression, RevsetIteratorExt};
|
||||
use crate::revset::{DefaultSymbolResolver, RevsetExpression};
|
||||
|
||||
struct PrefixDisambiguationError;
|
||||
|
||||
|
@ -48,14 +48,11 @@ impl DisambiguationData {
|
|||
.evaluate(repo)
|
||||
.map_err(|_| PrefixDisambiguationError)?;
|
||||
|
||||
// TODO: We should be able to get the change IDs from the revset, without having
|
||||
// to read the whole commit objects
|
||||
let mut commit_id_vec = vec![];
|
||||
let mut change_id_vec = vec![];
|
||||
for commit in revset.iter().commits(repo.store()) {
|
||||
let commit = commit.map_err(|_| PrefixDisambiguationError)?;
|
||||
commit_id_vec.push((commit.id().clone(), ()));
|
||||
change_id_vec.push((commit.change_id().clone(), commit.id().clone()));
|
||||
for (commit_id, change_id) in revset.commit_change_ids() {
|
||||
commit_id_vec.push((commit_id.clone(), ()));
|
||||
change_id_vec.push((change_id, commit_id));
|
||||
}
|
||||
Ok(Indexes {
|
||||
commit_index: IdIndex::from_vec(commit_id_vec),
|
||||
|
|
|
@ -2029,6 +2029,9 @@ pub trait Revset<'index>: fmt::Debug {
|
|||
/// Iterate in topological order with children before parents.
|
||||
fn iter(&self) -> Box<dyn Iterator<Item = CommitId> + '_>;
|
||||
|
||||
/// Iterates commit/change id pairs in topological order.
|
||||
fn commit_change_ids(&self) -> Box<dyn Iterator<Item = (CommitId, ChangeId)> + '_>;
|
||||
|
||||
fn iter_graph(&self) -> Box<dyn Iterator<Item = (CommitId, Vec<RevsetGraphEdge>)> + '_>;
|
||||
|
||||
fn change_id_index(&self) -> Box<dyn ChangeIdIndex + 'index>;
|
||||
|
|
Loading…
Reference in a new issue