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6LFD4NBMKRNH5EPIVW3K5HAV6D56IG6QC
}
fn text_test<C: ChangeStore>(c: &C, change0: &Change, h: Hash) {
let mut v = Vec::new();
let mut v_old = Vec::new();
// let channel = channel.borrow();
change0.write_old(c, Some(h), true, &mut v_old).unwrap();
change0.write(c, Some(h), true, &mut v).unwrap();
println!("{}", String::from_utf8_lossy(&v_old));
for i in std::str::from_utf8(&v).unwrap().lines() {
debug!("{}", i);
}
let change0 =
Change::read_old(std::io::Cursor::new(&v_old[..]), &mut HashMap::default()).unwrap();
let change1 = Change::read(std::io::Cursor::new(&v[..]), &mut HashMap::default()).unwrap();
if change0.header != change1.header {
error!("header: {:#?} != {:#?}", change0.header, change1.header);
}
if change0.dependencies != change1.dependencies {
error!(
"deps: {:#?} != {:#?}",
change0.dependencies, change1.dependencies
);
}
if change0.extra_known != change1.extra_known {
error!(
"extra: {:#?} != {:#?}",
change0.extra_known, change1.extra_known
);
}
if change0.metadata != change1.metadata {
error!("meta: {:#?} != {:#?}", change0.metadata, change1.metadata);
}
if change0.changes != change1.changes {
if change0.changes.len() != change1.changes.len() {
trace!("change0.changes = {:#?}", change0.changes);
trace!("change1.changes = {:#?}", change1.changes);
} else {
for (a, b) in change0.changes.iter().zip(change1.changes.iter()) {
trace!("change0: {:#?}", a);
trace!("change1: {:#?}", b);
for (a, b) in a.iter().zip(b.iter()) {
if a != b {
error!("change0 -> {:#?}", a);
error!("change1 -> {:#?}", b);
}
}
}
}
}
if change0.contents != change1.contents {
error!("change0.contents = {:?}", change0.contents);
error!("change1.contents = {:?}", change1.contents);
}
assert_eq!(change0, change1);
let mut cursor = txn.read().graph_cursor(graph, None).unwrap();
while let Some(Ok(_)) = txn.read().next_graph(graph, &mut cursor) {
let mut cursor = txn.read().graph_cursor(&*graph, None).unwrap();
while let Some(Ok(_)) = txn.read().next_graph(&*graph, &mut cursor) {
repo.write_file("a/b/c/d").unwrap().write_all(b"edits\n")?;
repo.write_file("e/f/g/h").unwrap().write_all(b"edits\n")?;
repo.write_file("a/b/c/d", Inode::ROOT)
.unwrap()
.write_all(b"edits\n")?;
repo.write_file("e/f/g/h", Inode::ROOT)
.unwrap()
.write_all(b"edits\n")?;
}
Ok(())
}
#[test]
fn move_back_noundel_test() -> Result<(), anyhow::Error> {
env_logger::try_init().unwrap_or(());
let repo_alice = working_copy::memory::Memory::new();
let changes = changestore::memory::Memory::new();
let env_alice = pristine::sanakirja::Pristine::new_anon()?;
let txn_alice = env_alice.arc_txn_begin().unwrap();
let channel_alice = txn_alice.write().open_or_create_channel("main")?;
repo_alice.add_file("a", b"a\n".to_vec());
txn_alice.write().add_file("a", 0)?;
let _init = record_all(&repo_alice, &changes, &txn_alice, &channel_alice, "")?;
repo_alice.rename("a", "b").unwrap_or(());
txn_alice.write().move_file("a", "b", 0)?;
let _mv = record_all(&repo_alice, &changes, &txn_alice, &channel_alice, "")?;
repo_alice.rename("b", "a").unwrap_or(());
txn_alice.write().move_file("b", "a", 0)?;
info!("MOVE BACK");
{
let txn_ = txn_alice.write();
let mut f = std::fs::File::create("/tmp/moveback")?;
crate::pristine::debug(&*txn_, &txn_.graph(&*channel_alice.read()), &mut f)?;
repo.write_file("a/b/c/d").unwrap().write_all(b"edits\n")?;
repo.write_file("e/f/g/h").unwrap().write_all(b"edits\n")?;
repo.write_file("a/b/c/d", Inode::ROOT)
.unwrap()
.write_all(b"edits\n")?;
repo.write_file("e/f/g/h", Inode::ROOT)
.unwrap()
.write_all(b"edits\n")?;