Unrecord: don't restore the same unrecorded file deletion twice in the inodes and tree tables
[?]
Nov 21, 2020, 6:13 PM
7UPL3Y2A5QOBU6VIUHNWEFGSGQ5CMWGDGOVLRZ53UARXG3TDGLMACDependencies
- [2]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting).
Change contents
- edit in libpijul/src/unrecord/working_copy.rs at line 0
// org id hPrt74aGC9MoSCkacm35YMV1UsqOTCIc9O8ApjoChHI= - replacement in libpijul/src/unrecord/working_copy.rs at line 4
// org id XWsbPEqsD3paeM/LxVDyIr2Q565JHhSez0T72hx9cHs= - replacement in libpijul/src/unrecord/working_copy.rs at line 23
// org id aM0a1a29Y251MOlVfR8GafvillHOtUZNFlHypSf5e0c= - replacement in libpijul/src/unrecord/working_copy.rs at line 41
// org id jpnOhTUKi2/wrb/uh1iJyGyO0F8zmYxoJlnFRItxZo0= - replacement in libpijul/src/unrecord/working_copy.rs at line 67
// org id tgKUYrZqx9aEX8jZs1AQbH/VCnJJAtXyCdfty6XGk3I= - replacement in libpijul/src/unrecord/working_copy.rs at line 80
// org id 6G9wZJSePFPM3jnKlWo/js7upKaYQwFWH9ep4l2BR8Y= - edit in libpijul/src/unrecord/working_copy.rs at line 88
let inode = crate::fs::create_new_inode(txn); - replacement in libpijul/src/unrecord/working_copy.rs at line 95
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)} - replacement in libpijul/src/unrecord/working_copy.rs at line 106
// org id RM0rj9DnLmh6LYZN5VK6ADMYoieH0mZJcaFzBEZzf9c= - replacement in libpijul/src/unrecord/working_copy.rs at line 142
// org id T313j+8glo3jbLVV755vMhVhm9EW2lx+7wowRud9Bfo= - edit in libpijul/src/unrecord/working_copy.rs at line 150
// org id HBoHMB0n95+Pap0r6KHw3Kj1HRX0MyKXyd0dYieT2cs= - edit in libpijul/src/tests/unrecord.rs at line 914
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)?; - edit in libpijul/src/tests/unrecord.rs at line 939
// 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());