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 2a9c178 commit 1cfeb11
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion examples/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::Parser;
use gix::{
bstr::{BString, ByteSlice},
date::time::format,
traverse::commit::Sorting,
traverse::commit::simple::Sorting,
};

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/commitgraph/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub(crate) mod function {
use std::{borrow::Cow, ffi::OsString};

use anyhow::{bail, Context};
use gix::{prelude::ObjectIdExt, traverse::commit::Sorting};
use gix::{prelude::ObjectIdExt, traverse::commit::simple::Sorting};

use crate::OutputFormat;

Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/revision/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 0..=2;

pub(crate) mod function {
use anyhow::{bail, Context};
use gix::{hashtable::HashMap, traverse::commit::Sorting, Progress};
use gix::{hashtable::HashMap, traverse::commit::simple::Sorting, Progress};
use layout::{
backends::svg::SVGWriter,
core::{base::Orientation, geometry::Point, style::StyleAttr},
Expand Down
3 changes: 1 addition & 2 deletions gix-diff/tests/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,10 @@ mod changes {
}

fn all_commits(db: &gix_odb::Handle) -> HashMap<String, ObjectId> {
use gix_traverse::commit;
let mut buf = Vec::new();

let head = head_of(db);
commit::Simple::new(Some(head), &db)
gix_traverse::commit::Simple::new(Some(head), &db)
.collect::<Result<Vec<_>, _>>()
.expect("valid iteration")
.into_iter()
Expand Down
3 changes: 1 addition & 2 deletions gix-pack/tests/pack/data/output/count_and_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use gix_pack::data::{
output,
output::{count, entry},
};
use gix_traverse::commit;

use crate::pack::{
data::output::{db, DbKind},
Expand Down Expand Up @@ -241,7 +240,7 @@ fn traversals() -> crate::Result {
.copied()
{
let head = hex_to_id("dfcb5e39ac6eb30179808bbab721e8a28ce1b52e");
let mut commits = commit::Simple::new(Some(head), db.clone())
let mut commits = gix_traverse::commit::Simple::new(Some(head), db.clone())
.map(Result::unwrap)
.map(|c| c.id)
.collect::<Vec<_>>();
Expand Down
5 changes: 2 additions & 3 deletions gix/src/ext/object_id.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use gix_hash::ObjectId;
use gix_traverse::commit::Simple;

pub trait Sealed {}

pub type AncestorsIter<Find> = Simple<Find, fn(&gix_hash::oid) -> bool>;
pub type AncestorsIter<Find> = gix_traverse::commit::Simple<Find, fn(&gix_hash::oid) -> bool>;

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

fn attach(self, repo: &crate::Repository) -> crate::Id<'_> {
Expand Down
2 changes: 1 addition & 1 deletion gix/src/remote/connection/fetch/update_refs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub(crate) fn update(
.to_owned()
.ancestors(&repo.objects)
.sorting(
gix_traverse::commit::Sorting::ByCommitTimeNewestFirstCutoffOlderThan {
gix_traverse::commit::simple::Sorting::ByCommitTimeNewestFirstCutoffOlderThan {
seconds: local_commit_time
},
)
Expand Down
12 changes: 3 additions & 9 deletions gix/src/revision/spec/parse/delegate/navigate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use gix_revision::spec::parse::{
delegate,
delegate::{PeelTo, Traversal},
};
use gix_traverse::commit::Sorting;

use crate::{
bstr::{BStr, ByteSlice},
Expand Down Expand Up @@ -193,7 +192,7 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
match oid
.attach(repo)
.ancestors()
.sorting(Sorting::ByCommitTimeNewestFirst)
.sorting(gix_traverse::commit::simple::Sorting::ByCommitTimeNewestFirst)
.all()
{
Ok(iter) => {
Expand Down Expand Up @@ -242,15 +241,10 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
references
.peeled()
.filter_map(Result::ok)
.filter(|r| {
r.id()
.object()
.ok()
.map_or(false, |obj| obj.kind == gix_object::Kind::Commit)
})
.filter(|r| r.id().header().ok().map_or(false, |obj| obj.kind().is_commit()))
.filter_map(|r| r.detach().peeled),
)
.sorting(Sorting::ByCommitTimeNewestFirst)
.sorting(gix_traverse::commit::simple::Sorting::ByCommitTimeNewestFirst)
.all()
{
Ok(iter) => {
Expand Down
10 changes: 5 additions & 5 deletions gix/src/revision/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ext::ObjectIdExt, revision, Repository};
#[allow(missing_docs)]
pub enum Error {
#[error(transparent)]
AncestorIter(#[from] gix_traverse::commit::simple::Error),
SimpleTraversal(#[from] gix_traverse::commit::simple::Error),
#[error(transparent)]
ShallowCommits(#[from] crate::shallow::open::Error),
#[error(transparent)]
Expand All @@ -22,8 +22,8 @@ pub struct Info<'repo> {
pub id: gix_hash::ObjectId,
/// All parent ids we have encountered. Note that these will be at most one if [`Parents::First`][gix_traverse::commit::Parents::First] is enabled.
pub parent_ids: gix_traverse::commit::ParentIds,
/// The time at which the commit was created. It's only `Some(_)` if sorting is not [`Sorting::BreadthFirst`][gix_traverse::commit::Sorting::BreadthFirst],
/// as the walk needs to require the commit-date.
/// The time at which the commit was created. It will only be `Some(_)` if the chosen traversal was
/// taking dates into consideration.
pub commit_time: Option<gix_date::SecondsSinceUnixEpoch>,

repo: &'repo Repository,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<'repo> Info<'repo> {
pub struct Platform<'repo> {
pub(crate) repo: &'repo Repository,
pub(crate) tips: Vec<ObjectId>,
pub(crate) sorting: gix_traverse::commit::Sorting,
pub(crate) sorting: gix_traverse::commit::simple::Sorting,
pub(crate) parents: gix_traverse::commit::Parents,
pub(crate) use_commit_graph: Option<bool>,
pub(crate) commit_graph: Option<gix_commitgraph::Graph>,
Expand All @@ -113,7 +113,7 @@ impl<'repo> Platform<'repo> {
/// Create-time builder methods
impl<'repo> Platform<'repo> {
/// Set the sort mode for commits to the given value. The default is to order topologically breadth-first.
pub fn sorting(mut self, sorting: gix_traverse::commit::Sorting) -> Self {
pub fn sorting(mut self, sorting: gix_traverse::commit::simple::Sorting) -> Self {
self.sorting = sorting;
self
}
Expand Down
10 changes: 5 additions & 5 deletions gix/tests/id/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mod ancestors {
let commits_by_commit_date = head
.ancestors()
.use_commit_graph(!use_commit_graph)
.sorting(commit::Sorting::ByCommitTimeNewestFirst)
.sorting(commit::simple::Sorting::ByCommitTimeNewestFirst)
.all()?
.map(|c| c.map(gix::revision::walk::Info::detach))
.collect::<Result<Vec<_>, _>>()?;
Expand Down Expand Up @@ -121,7 +121,7 @@ mod ancestors {
let head = repo.head()?.into_peeled_id()?;
let commits = head
.ancestors()
.sorting(commit::Sorting::ByCommitTimeNewestFirst) // assure we have time set
.sorting(commit::simple::Sorting::ByCommitTimeNewestFirst) // assure we have time set
.use_commit_graph(use_commit_graph)
.all()?
.collect::<Result<Vec<_>, _>>()?;
Expand All @@ -141,9 +141,9 @@ mod ancestors {

for use_commit_graph in [false, true] {
for sorting in [
commit::Sorting::BreadthFirst,
commit::Sorting::ByCommitTimeNewestFirst,
commit::Sorting::ByCommitTimeNewestFirstCutoffOlderThan { seconds: 0 },
commit::simple::Sorting::BreadthFirst,
commit::simple::Sorting::ByCommitTimeNewestFirst,
commit::simple::Sorting::ByCommitTimeNewestFirstCutoffOlderThan { seconds: 0 },
] {
let commits_graph_order = head
.ancestors()
Expand Down
2 changes: 1 addition & 1 deletion gix/tests/repository/shallow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn yes() -> crate::Result {
}

mod traverse {
use gix_traverse::commit::Sorting;
use gix_traverse::commit::simple::Sorting;
use serial_test::parallel;

use crate::util::{hex_to_id, named_subrepo_opts};
Expand Down

0 comments on commit 1cfeb11

Please sign in to comment.