Safeguarding `pijul channel new`: it was too easy to create a new, independent root
Dependencies
- [2]
TDTCT6EGNew channel: confusion in subcommand names - [3]
A3RM526YIntegrating identity malleability - [4]
TFK7CYFQ`pijul channel new` to create new, empty channels - [5]
PGERZ3KJChannel renaming (also do not create a new channel when recording on a channel that doesn't exist) - [6]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [*]
GHO6DWPIRefactoring iterators - [*]
L4JXJHWXpijul/*: reorganize imports and remove extern crate
Change contents
- edit in pijul/src/commands/channel.rs at line 9[8.987][9.3080]
use log::debug; - replacement in pijul/src/commands/channel.rs at line 39
New { name: String },New {name: String,#[clap(long = "empty")]empty: bool,#[clap(long = "force", short = 'f')]force: bool,}, - replacement in pijul/src/commands/channel.rs at line 108
Some(SubCommand::New { name }) => {Some(SubCommand::New { name, empty, force }) => {if empty && !force {bail!("If creating an empty channel is really what you want, please use -f.")} - replacement in pijul/src/commands/channel.rs at line 117
txn.open_or_create_channel(&name)?;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)?;}}