/// Add a simple file, to test submodules.
#[test]
fn add_file2_test() -> Result<(), anyhow::Error> {
env_logger::try_init().unwrap_or(());
let repo = working_copy::memory::Memory::new();
let changes = changestore::memory::Memory::new();
repo.add_file("a/b/c/file", b"a\nb\nc\nd\ne\nf\n".to_vec());
let env = pristine::sanakirja::Pristine::new_anon()?;
{
let txn = env.arc_txn_begin().unwrap();
txn.write().add_file("a/b/c/file", 0).unwrap();
let channel = txn.write().open_or_create_channel("main").unwrap();
record_all(&repo, &changes, &txn, &channel, "").unwrap();
txn.commit().unwrap()
}
let repo2 = working_copy::memory::Memory::new();
repo2.add_file("a/b/c/file", b"w\nx\ny\nz\n".to_vec());
let change = {
let txn = env.arc_txn_begin().unwrap();
txn.write().add_file("a/b/c/file", 0).unwrap();
let channel = txn.write().open_or_create_channel("other").unwrap();
let change = record_all(&repo, &changes, &txn, &channel, "").unwrap();
txn.commit().unwrap();
change
};
let txn = env.arc_txn_begin().unwrap();
let channel = txn.write().open_or_create_channel("main").unwrap();
apply::apply_change(&changes, &mut *txn.write(), &mut *channel.write(), &change)?;
output::output_repository_no_pending(&repo, &changes, &txn, &channel, "", true, None, 1, 0)?;
Ok(())
}