mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 03:22:59 +00:00
index: make topo_order() return commit ids instead of index entries
`IndexEntry` is specific to the default index store; we don't want it in the interface.
This commit is contained in:
parent
772cb1a0e9
commit
a5b79f9b0e
3 changed files with 7 additions and 8 deletions
|
@ -724,7 +724,7 @@ impl Index for MutableIndexImpl {
|
||||||
CompositeIndex(self).heads(candidates)
|
CompositeIndex(self).heads(candidates)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<IndexEntry> {
|
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<CommitId> {
|
||||||
CompositeIndex(self).topo_order(input)
|
CompositeIndex(self).topo_order(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,10 +1109,10 @@ impl<'a> CompositeIndex<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parents before children
|
/// Parents before children
|
||||||
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<IndexEntry<'a>> {
|
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<CommitId> {
|
||||||
let mut entries_by_generation = input.map(|id| self.entry_by_id(id).unwrap()).collect_vec();
|
let mut ids = input.cloned().collect_vec();
|
||||||
entries_by_generation.sort_unstable_by_key(|e| e.pos);
|
ids.sort_by_cached_key(|id| self.commit_id_to_pos(id).unwrap());
|
||||||
entries_by_generation
|
ids
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1802,7 +1802,7 @@ impl Index for ReadonlyIndexImpl {
|
||||||
CompositeIndex(self).heads(candidates)
|
CompositeIndex(self).heads(candidates)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<IndexEntry> {
|
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<CommitId> {
|
||||||
CompositeIndex(self).topo_order(input)
|
CompositeIndex(self).topo_order(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub trait Index: Send + Sync {
|
||||||
fn heads(&self, candidates: &mut dyn Iterator<Item = &CommitId>) -> Vec<CommitId>;
|
fn heads(&self, candidates: &mut dyn Iterator<Item = &CommitId>) -> Vec<CommitId>;
|
||||||
|
|
||||||
/// Parents before children
|
/// Parents before children
|
||||||
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<IndexEntry>;
|
fn topo_order(&self, input: &mut dyn Iterator<Item = &CommitId>) -> Vec<CommitId>;
|
||||||
|
|
||||||
// TODO: It's weird that we pass in the repo here since the repo is a
|
// TODO: It's weird that we pass in the repo here since the repo is a
|
||||||
// higher-level concept. We should probably pass in the view and store
|
// higher-level concept. We should probably pass in the view and store
|
||||||
|
|
|
@ -1902,7 +1902,6 @@ fn cmd_duplicate(
|
||||||
.index()
|
.index()
|
||||||
.topo_order(&mut to_duplicate.iter().map(|c| c.id()))
|
.topo_order(&mut to_duplicate.iter().map(|c| c.id()))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|index_entry| index_entry.commit_id())
|
|
||||||
{
|
{
|
||||||
// Topological order ensures that any parents of `original_commit` are
|
// Topological order ensures that any parents of `original_commit` are
|
||||||
// either not in `to_duplicate` or were already duplicated.
|
// either not in `to_duplicate` or were already duplicated.
|
||||||
|
|
Loading…
Reference in a new issue