Unrecord: don't restore the same unrecorded file deletion twice in the inodes and tree tables

[?]
Nov 21, 2020, 6:13 PM
7UPL3Y2A5QOBU6VIUHNWEFGSGQ5CMWGDGOVLRZ53UARXG3TDGLMAC

Dependencies

  • [2] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).

Change contents

  • edit in libpijul/src/unrecord/working_copy.rs at line 0
    [2.225940][2.225941:225996]()
    // org id hPrt74aGC9MoSCkacm35YMV1UsqOTCIc9O8ApjoChHI=
  • replacement in libpijul/src/unrecord/working_copy.rs at line 4
    [2.226097][2.226097:226152]()
    // org id XWsbPEqsD3paeM/LxVDyIr2Q565JHhSez0T72hx9cHs=
    [2.226097]
    [2.226152]
  • replacement in libpijul/src/unrecord/working_copy.rs at line 23
    [2.226674][2.226674:226729]()
    // org id aM0a1a29Y251MOlVfR8GafvillHOtUZNFlHypSf5e0c=
    [2.226674]
    [2.226729]
  • replacement in libpijul/src/unrecord/working_copy.rs at line 41
    [2.227373][2.227373:227428]()
    // org id jpnOhTUKi2/wrb/uh1iJyGyO0F8zmYxoJlnFRItxZo0=
    [2.227373]
    [2.227428]
  • replacement in libpijul/src/unrecord/working_copy.rs at line 67
    [2.228275][2.228275:228338]()
    // org id tgKUYrZqx9aEX8jZs1AQbH/VCnJJAtXyCdfty6XGk3I=
    [2.228275]
    [2.228338]
  • replacement in libpijul/src/unrecord/working_copy.rs at line 80
    [2.228868][2.228868:228923]()
    // org id 6G9wZJSePFPM3jnKlWo/js7upKaYQwFWH9ep4l2BR8Y=
    [2.228868]
    [2.228923]
  • edit in libpijul/src/unrecord/working_copy.rs at line 88
    [2.229124][2.229124:229174]()
    let inode = crate::fs::create_new_inode(txn);
  • replacement in libpijul/src/unrecord/working_copy.rs at line 95
    [2.229428][2.229428:229620]()
    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)
    [2.229428]
    [2.229620]
    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
    [2.229622][2.229622:229677]()
    // org id RM0rj9DnLmh6LYZN5VK6ADMYoieH0mZJcaFzBEZzf9c=
    [2.229622]
    [2.229677]
  • replacement in libpijul/src/unrecord/working_copy.rs at line 142
    [2.230739][2.230739:230794]()
    // org id T313j+8glo3jbLVV755vMhVhm9EW2lx+7wowRud9Bfo=
    [2.230739]
    [2.230794]
  • edit in libpijul/src/unrecord/working_copy.rs at line 150
    [2.231040][2.231040:231103]()
    // org id HBoHMB0n95+Pap0r6KHw3Kj1HRX0MyKXyd0dYieT2cs=
  • edit in libpijul/src/tests/unrecord.rs at line 914
    [2.276023]
    [2.276023]
    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
    [2.276024]
    [2.276024]
    // First deletion
    repo.remove_path("file")?;
    let h1 = record_all(&mut repo, &changes, &mut txn, &mut channel, "")?;
    debug!("h1 = {:?}", h1);
    // Second deletion
    let 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());