Skip to content

Commit

Permalink
adapt to changes in gix-traverse
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Apr 7, 2024
1 parent e0969c3 commit 6154bf3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/create.rs
Expand Up @@ -130,7 +130,7 @@ where
.collect::<Result<Vec<_>, _>>()?;
let handle = repo.objects.into_shared_arc().to_cache_arc();
let iter = Box::new(
traverse::commit::Ancestors::new(tips, traverse::commit::ancestors::State::default(), handle.clone())
traverse::commit::Ancestors::new(tips, handle.clone())
.map(|res| res.map_err(|err| Box::new(err) as Box<_>).map(|c| c.id))
.inspect(move |_| progress.inc()),
);
Expand Down
2 changes: 1 addition & 1 deletion gix-diff/tests/tree/mod.rs
Expand Up @@ -133,7 +133,7 @@ mod changes {
let mut buf = Vec::new();

let head = head_of(db);
commit::Ancestors::new(Some(head), commit::ancestors::State::default(), &db)
commit::Ancestors::new(Some(head), &db)
.collect::<Result<Vec<_>, _>>()
.expect("valid iteration")
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion gix-pack/tests/pack/data/output/count_and_entries.rs
Expand Up @@ -241,7 +241,7 @@ fn traversals() -> crate::Result {
.copied()
{
let head = hex_to_id("dfcb5e39ac6eb30179808bbab721e8a28ce1b52e");
let mut commits = commit::Ancestors::new(Some(head), commit::ancestors::State::default(), db.clone())
let mut commits = commit::Ancestors::new(Some(head), db.clone())
.map(Result::unwrap)
.map(|c| c.id)
.collect::<Vec<_>>();
Expand Down
6 changes: 3 additions & 3 deletions gix/src/ext/object_id.rs
@@ -1,9 +1,9 @@
use gix_hash::ObjectId;
use gix_traverse::commit::{ancestors, Ancestors};
use gix_traverse::commit::Ancestors;

pub trait Sealed {}

pub type AncestorsIter<Find> = Ancestors<Find, fn(&gix_hash::oid) -> bool, ancestors::State>;
pub type AncestorsIter<Find> = Ancestors<Find, fn(&gix_hash::oid) -> bool>;

/// An extension trait to add functionality to [`ObjectId`]s.
pub trait ObjectIdExt: Sealed {
Expand All @@ -23,7 +23,7 @@ impl ObjectIdExt for ObjectId {
where
Find: gix_object::Find,
{
Ancestors::new(Some(self), ancestors::State::default(), find)
Ancestors::new(Some(self), find)
}

fn attach(self, repo: &crate::Repository) -> crate::Id<'_> {
Expand Down
59 changes: 27 additions & 32 deletions gix/src/revision/walk.rs
Expand Up @@ -166,40 +166,35 @@ impl<'repo> Platform<'repo> {
Ok(revision::Walk {
repo,
inner: Box::new(
gix_traverse::commit::Ancestors::filtered(
tips,
gix_traverse::commit::ancestors::State::default(),
&repo.objects,
{
// Note that specific shallow handling for commit-graphs isn't needed as these contain
// all information there is, and exclude shallow parents to be structurally consistent.
let shallow_commits = repo.shallow_commits()?;
let mut grafted_parents_to_skip = Vec::new();
let mut buf = Vec::new();
move |id| {
if !filter(id) {
return false;
}
match shallow_commits.as_ref() {
Some(commits) => {
let id = id.to_owned();
if let Ok(idx) = grafted_parents_to_skip.binary_search(&id) {
grafted_parents_to_skip.remove(idx);
return false;
};
if commits.binary_search(&id).is_ok() {
if let Ok(commit) = repo.objects.find_commit_iter(&id, &mut buf) {
grafted_parents_to_skip.extend(commit.parent_ids());
grafted_parents_to_skip.sort();
}
};
true
}
None => true,
gix_traverse::commit::Ancestors::filtered(tips, &repo.objects, {
// Note that specific shallow handling for commit-graphs isn't needed as these contain
// all information there is, and exclude shallow parents to be structurally consistent.
let shallow_commits = repo.shallow_commits()?;
let mut grafted_parents_to_skip = Vec::new();
let mut buf = Vec::new();
move |id| {
if !filter(id) {
return false;
}
match shallow_commits.as_ref() {
Some(commits) => {
let id = id.to_owned();
if let Ok(idx) = grafted_parents_to_skip.binary_search(&id) {
grafted_parents_to_skip.remove(idx);
return false;
};
if commits.binary_search(&id).is_ok() {
if let Ok(commit) = repo.objects.find_commit_iter(&id, &mut buf) {
grafted_parents_to_skip.extend(commit.parent_ids());
grafted_parents_to_skip.sort();
}
};
true
}
None => true,
}
},
)
}
})
.sorting(sorting)?
.parents(parents)
.commit_graph(
Expand Down

0 comments on commit 6154bf3

Please sign in to comment.