1
1
use std:: { collections:: BTreeSet , io, path:: Path , time:: Instant } ;
2
2
3
- use anyhow:: { anyhow , bail} ;
3
+ use anyhow:: bail;
4
4
use gix:: {
5
5
actor,
6
6
bstr:: { BStr , ByteSlice } ,
7
- interrupt,
8
7
prelude:: * ,
9
8
progress, Progress ,
10
9
} ;
@@ -144,24 +143,31 @@ where
144
143
let mut skipped_merge_commits = 0 ;
145
144
const CHUNK_SIZE : usize = 50 ;
146
145
let mut chunk = Vec :: with_capacity ( CHUNK_SIZE ) ;
147
- let commit_iter = interrupt:: Iter :: new (
148
- commit_id. ancestors ( |oid, buf| {
149
- progress. inc ( ) ;
150
- repo. objects . find ( oid, buf) . map ( |obj| {
151
- tx. send ( ( commit_idx, obj. data . to_owned ( ) ) ) . ok ( ) ;
152
- if let Some ( ( tx_tree, first_parent, commit) ) = tx_tree_id. as_ref ( ) . and_then ( |tx| {
153
- let mut parents = gix:: objs:: CommitRefIter :: from_bytes ( obj. data ) . parent_ids ( ) ;
154
- let res = parents
146
+ let mut commit_iter = commit_id. ancestors ( |oid, buf| repo. objects . find_commit_iter ( oid, buf) ) ;
147
+ let mut is_shallow = false ;
148
+ while let Some ( c) = commit_iter. next ( ) {
149
+ progress. inc ( ) ;
150
+ if gix:: interrupt:: is_triggered ( ) {
151
+ bail ! ( "Cancelled by user" ) ;
152
+ }
153
+ match c {
154
+ Ok ( c) => {
155
+ tx. send ( ( commit_idx, commit_iter. commit_data ( ) . to_owned ( ) ) ) . ok ( ) ;
156
+ let tree_delta_info = tx_tree_id. as_ref ( ) . and_then ( |tx| {
157
+ let mut parents = c. parent_ids . into_iter ( ) ;
158
+ parents
155
159
. next ( )
156
- . map ( |first_parent| ( tx, Some ( first_parent) , oid. to_owned ( ) ) ) ;
157
- match parents. next ( ) {
158
- Some ( _) => {
159
- skipped_merge_commits += 1 ;
160
- None
161
- }
162
- None => res,
163
- }
164
- } ) {
160
+ . map ( |first_parent| ( tx, Some ( first_parent) , c. id . to_owned ( ) ) )
161
+ . filter ( |_| {
162
+ if parents. next ( ) . is_some ( ) {
163
+ skipped_merge_commits += 1 ;
164
+ false
165
+ } else {
166
+ true
167
+ }
168
+ } )
169
+ } ) ;
170
+ if let Some ( ( tx_tree, first_parent, commit) ) = tree_delta_info {
165
171
if chunk. len ( ) == CHUNK_SIZE {
166
172
tx_tree
167
173
. send ( std:: mem:: replace ( & mut chunk, Vec :: with_capacity ( CHUNK_SIZE ) ) )
@@ -170,16 +176,8 @@ where
170
176
chunk. push ( ( commit_idx, first_parent, commit) )
171
177
}
172
178
}
173
- commit_idx = commit_idx. checked_add ( 1 ) . expect ( "less then 4 billion commits" ) ;
174
- gix:: objs:: CommitRefIter :: from_bytes ( obj. data )
175
- } )
176
- } ) ,
177
- || anyhow ! ( "Cancelled by user" ) ,
178
- ) ;
179
- let mut is_shallow = false ;
180
- for c in commit_iter {
181
- match c? {
182
- Ok ( c) => c,
179
+ commit_idx += 1 ;
180
+ }
183
181
Err ( gix:: traverse:: commit:: ancestors:: Error :: FindExisting { .. } ) => {
184
182
is_shallow = true ;
185
183
break ;
0 commit comments