in tools/publisher/src/package.rs [299:334]
fn batch_packages(packages: Vec<Package>) -> Result<Vec<PackageBatch>> {
// Sort packages in order of local dependencies
let mut packages = dependency_order(packages)?;
// Discover batches
let mut batches = Vec::new();
'outer: while packages.len() > 1 {
for run in 0..packages.len() {
let next = &packages[run];
// If the next package depends on any prior package, then we've discovered the end of the batch
for index in 0..run {
let previous = &packages[index];
if next.locally_depends_on(&previous.handle) {
let remaining = packages.split_off(run);
let batch = packages;
packages = remaining;
batches.push(batch);
continue 'outer;
}
}
}
// If the current run is the length of the package vec, then we have exactly one batch left
break;
}
// Push the final batch
if !packages.is_empty() {
batches.push(packages);
}
// Sort packages within batches so that `--continue-from` work consistently
for batch in batches.iter_mut() {
batch.sort();
}
Ok(batches)
}