7UPL3Y2A5QOBU6VIUHNWEFGSGQ5CMWGDGOVLRZ53UARXG3TDGLMAC txn.put_tree(file_id.as_file_id(), inode)?;txn.put_revtree(inode, file_id.as_file_id())?;txn.replace_inodes(inode, dest)?;txn.replace_revinodes(dest, inode)?;Ok(inode)
if let Some(inode) = txn.get_revinodes(dest, None) {Ok(inode)} else {let inode = crate::fs::create_new_inode(txn);txn.put_tree(file_id.as_file_id(), inode)?;txn.put_revtree(inode, file_id.as_file_id())?;txn.put_inodes(inode, dest)?;txn.put_revinodes(dest, inode)?;Ok(inode)}
Ok(())}/// Delete the same file on two different channels, merge, unrecord each patch on the same channel. What happens to tree/revtree?#[test]fn double_file() -> Result<(), anyhow::Error> {env_logger::try_init().unwrap_or(());let mut repo = working_copy::memory::Memory::new();let changes = changestore::memory::Memory::new();let env = pristine::sanakirja::Pristine::new_anon()?;let mut txn = env.mut_txn_begin();let mut channel = txn.open_or_create_channel("main")?;let mut channel2 = txn.open_or_create_channel("main2")?;repo.add_file("file", b"blabla\nblibli\nblublu\n".to_vec());txn.add_file("file")?;let h0 = record_all(&mut repo, &changes, &mut txn, &mut channel, "")?;debug!("h0 = {:?}", h0);apply::apply_change(&changes, &mut txn, &mut channel2, h0)?;
// First deletionrepo.remove_path("file")?;let h1 = record_all(&mut repo, &changes, &mut txn, &mut channel, "")?;debug!("h1 = {:?}", h1);// Second deletionlet h2 = record_all(&mut repo, &changes, &mut txn, &mut channel2, "")?;debug!("h2 = {:?}", h2);// Both deletions together.debug!("applying");apply::apply_change(&changes, &mut txn, &mut channel, h2)?;crate::unrecord::unrecord(&mut txn, &mut channel, &changes, &h1)?;crate::unrecord::unrecord(&mut txn, &mut channel, &changes, &h2)?;let mut inodes = txn.iter_inodes();assert!(inodes.next().is_some());assert!(inodes.next().is_none());