5DVRL6MFXQOCPOZMYSKBERMRRVUTYRL2SRGRTU2MH4IEOFCDKM3QC
I52XSRUH5RVHQBFWVMAQPTUSPAJ4KNVID2RMI3UGCVKFLYUO6WZAC
AEPEFS7O3YT7CRRFYQVJWUXUUSRGJ6K6XZQVK62B6N74UXOIFWYAC
7L32EXDWOT2BWHPC3ZPAE4W6BOGQTTJUYJWTNMLS6INFXZ7GLPNQC
L4JXJHWXYNCL4QGJXNKKTOKKTAXKKXBJUUY7HFZGEUZ5A2V5H34QC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
YAJAXIV5VL263Z6FYLKFPROB3MQPRPH22P44GRGRVGEP56HOMBOAC
return Err((crate::Error::CannotUnrecord {
change: c,
dep: txn.get_external(d).unwrap(),
})
.into());
let dep = txn.get_external(d).unwrap();
if Some(dep) == pending_hash {
bail!(
"Cannot unrecord change {} because unrecorded changes depend on it",
c
);
} else {
bail!(
"Cannot unrecord change {} because {} depend on it",
c,
dep.to_base32()
);
}
let recorded = txn.record_all(
libpijul::Algorithm::default(),
&mut channel,
&mut repo.working_copy,
&repo.changes,
"",
)?;
let hash = if recorded.actions.is_empty() {
None
} else {
let actions = recorded
.actions
.into_iter()
.map(|rec| rec.globalize(&txn))
.collect();
let mut pending_change = libpijul::change::Change::make_change(
&txn,
&channel,
actions,
recorded.contents,
libpijul::change::ChangeHeader::default(),
Vec::new(),
);
let (dependencies, extra_known) =
libpijul::change::dependencies(&txn, &channel, pending_change.changes.iter());
pending_change.dependencies = dependencies;
pending_change.extra_known = extra_known;
let hash = repo.changes.save_change(&pending_change).unwrap();
txn.apply_local_change(&mut channel, &pending_change, hash, &recorded.updatables)?;
Some(hash)
};
let hash = super::pending(&mut txn, &mut channel, &mut repo)?;
/// Record the pending change (i.e. any unrecorded modifications in
/// the working copy), returning its hash.
fn pending<T: libpijul::MutTxnTExt + libpijul::TxnT>(
txn: &mut T,
channel: &mut libpijul::ChannelRef<T>,
repo: &mut crate::repository::Repository,
) -> Result<Option<libpijul::Hash>, anyhow::Error> {
use libpijul::changestore::ChangeStore;
let recorded = txn.record_all(
libpijul::Algorithm::default(),
channel,
&mut repo.working_copy,
&repo.changes,
"",
)?;
if recorded.actions.is_empty() {
return Ok(None);
}
let actions = recorded
.actions
.into_iter()
.map(|rec| rec.globalize(txn))
.collect();
let mut pending_change = libpijul::change::Change::make_change(
txn,
channel,
actions,
recorded.contents,
libpijul::change::ChangeHeader::default(),
Vec::new(),
);
let (dependencies, extra_known) =
libpijul::change::dependencies(txn, channel, pending_change.changes.iter());
pending_change.dependencies = dependencies;
pending_change.extra_known = extra_known;
let hash = repo.changes.save_change(&pending_change).unwrap();
txn.apply_local_change(channel, &pending_change, hash, &recorded.updatables)?;
Ok(Some(hash))
}