Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl Revision {
}

fn hash(&self, context: &Context) -> FieldResult<String> {
rs_tracing::trace_scoped!("hash");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to keep those here?

let transaction = context.transaction.lock()?;
let commit = transaction.repo().find_commit(self.commit_id)?;
let filter_commit = filter::apply_to_commit(self.filter, &commit, &transaction)?;
Expand Down Expand Up @@ -169,6 +170,7 @@ impl Revision {
offset: Option<i32>,
context: &Context,
) -> FieldResult<Vec<Revision>> {
rs_tracing::trace_scoped!("history");
let limit = limit.unwrap_or(1) as usize;
let offset = offset.unwrap_or(0) as usize;
let transaction = context.transaction.lock()?;
Expand All @@ -184,18 +186,33 @@ impl Revision {
walk.set_sorting(git2::Sort::TOPOLOGICAL)?;
walk.push(filter_commit.id())?;

Ok(walk
.skip(offset)
.take(limit)
let mut contained_in = self.commit_id;
let mut ids = {
rs_tracing::trace_scoped!("walk");
walk.skip(offset)
.take(limit)
.map(|id| id.unwrap_or(git2::Oid::zero()))
.collect::<Vec<git2::Oid>>()
};

{
rs_tracing::trace_scoped!("walk");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this scope can have a different name, like find_original

for i in 0..ids.len() {
ids[i] = history::find_original(&transaction, self.filter, contained_in, ids[i])?;
contained_in = transaction
.repo()
.find_commit(ids[i])?
.parent_ids()
.next()
.unwrap_or(ids[i]);
}
}

Ok(ids
.into_iter()
.map(|id| Revision {
filter: self.filter,
commit_id: history::find_original(
&transaction,
self.filter,
self.commit_id,
id.unwrap_or(git2::Oid::zero()),
)
.unwrap_or(git2::Oid::zero()),
commit_id: id,
})
.collect())
}
Expand Down