M5FK3ABTKBDG6HHW32G7UKRJEJQKD2U7BPXNZ3HVHBKULWVV6CTQC
let o = make_changelist(&repo.changes, &to_upload)?;
let u = parse_changelist(&edit::edit_bytes(&o[..])?);
check_deps(&repo.changes, &to_upload, &u)?;
u
let mut o = make_changelist(&repo.changes, &to_upload)?;
loop {
let d = parse_changelist(&edit::edit_bytes(&o[..])?);
let comp = complete_deps(&repo.changes, &to_upload, &d)?;
if comp.len() == d.len() {
break comp
}
o = make_changelist(&repo.changes, &comp)?
}
let o = make_changelist(&repo.changes, &to_download)?;
let d = parse_changelist(&edit::edit_bytes(&o[..])?);
check_deps(&repo.changes, &to_download, &d)?;
let mut o = make_changelist(&repo.changes, &to_download)?;
let d = loop {
let d = parse_changelist(&edit::edit_bytes(&o[..])?);
let comp = complete_deps(&repo.changes, &to_download, &d)?;
if comp.len() == d.len() {
break comp
}
o = make_changelist(&repo.changes, &comp)?
};
fn complete_deps<C: ChangeStore>(
c: &C,
original: &[libpijul::pristine::Hash],
now: &[libpijul::pristine::Hash],
) -> Result<Vec<libpijul::pristine::Hash>, anyhow::Error> {
let original_: HashSet<_> = original.iter().collect();
let mut now_ = HashSet::new();
let mut result = Vec::new();
for n in now {
// check that all of `now`'s deps are in now or not in original
for d in c.get_dependencies(n)? {
if original_.get(&d).is_some() && now_.get(&d).is_none() {
result.push(d);
now_.insert(d);
}
}
now_.insert(*n);
result.push(*n)
}
Ok(result)
}