let new = txn.open_or_create_channel(&name)?;
if !empty {
// Safeguard: apply the root patch if we're creating a new channel.
let current = txn.current_channel()?;
let channel = if let Some(channel) = txn.load_channel(current)? {
channel
} else {
bail!("No such channel: {:?}", current)
};
let ch = channel.read();
use libpijul::{GraphTxnT, MutTxnTExt};
let h = if let Some(Ok((k, v))) =
libpijul::pristine::changeid_log(&txn, &ch, 0u64.into())?.next()
{
debug!("initial patch on current channel: {:?} {:?}", k, v);
Some(txn.get_external(&v.a)?.unwrap().into())
} else {
None
};
if let Some(h) = h {
let mut new = new.write();
txn.apply_change(&repo.changes, &mut new, &h)?;
}
}