This is by analogy with rebase_descendants_with_options, except
we don't need the options.
+19
-4
lib/src/repo.rs
+19
-4
lib/src/repo.rs
···
1406
1406
/// The content of those descendants will remain untouched.
1407
1407
/// Returns the number of reparented descendants.
1408
1408
pub fn reparent_descendants(&mut self) -> BackendResult<usize> {
1409
-
let roots = self.parent_mapping.keys().cloned().collect_vec();
1410
1409
let mut num_reparented = 0;
1410
+
self.reparent_descendants_with_progress(|_, _| {
1411
+
num_reparented += 1;
1412
+
})?;
1413
+
Ok(num_reparented)
1414
+
}
1415
+
1416
+
/// Reparent descendants, and call the provided function for each moved
1417
+
/// commit
1418
+
///
1419
+
/// The function takes the old commit and the reparented commit.
1420
+
pub fn reparent_descendants_with_progress(
1421
+
&mut self,
1422
+
mut progress: impl FnMut(Commit, Commit),
1423
+
) -> BackendResult<()> {
1424
+
let roots = self.parent_mapping.keys().cloned().collect_vec();
1411
1425
self.transform_descendants(roots, |rewriter| {
1412
1426
if rewriter.parents_changed() {
1427
+
let old_commit = rewriter.old_commit().clone();
1413
1428
let builder = rewriter.reparent();
1414
-
builder.write()?;
1415
-
num_reparented += 1;
1429
+
let reparented_commit = builder.write()?;
1430
+
progress(old_commit, reparented_commit);
1416
1431
}
1417
1432
Ok(())
1418
1433
})?;
1419
1434
self.parent_mapping.clear();
1420
-
Ok(num_reparented)
1435
+
Ok(())
1421
1436
}
1422
1437
1423
1438
pub fn set_wc_commit(
History
1 round
0 comments
ilyagr.bsky.social
submitted
#0
1 commit
expand
collapse
repo: create a reparent_descendants_with_progress helper (no-op)
This is by analogy with `rebase_descendants_with_options`, except
we don't need the options.
no conflicts, ready to merge