FGIVSUFHH7DN65DYQHDGGDDCHHIB5Z7KKQWI4I3WMERE3BY6IMRQC
RMDMAYRXYBU5OQXV5HSF6LFD4NBMKRNH5EPIVW3K5HAV6D56IG6QC
UN2M77YUIQZMPH5CQARPUUK2Q66RHN5J6BIIQQFEJ35DSFSKFFPQC
YTQS4ES362EJ27OE45CE5HLY7ZU57YLVKRMDRJ2OXT623VM5WOBQC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
CCFJ7VO3I73FE3MZRS5RSDRYNZVW7AXC345P4BXS7JIL2TU3LQJQC
CCLLB7OIFNFYJZTG3UCI7536TOCWSCSXR67VELSB466R24WLJSDAC
5FI6SBEZ6RERERUAIWQJVAY66BEZ7YQOYOUNK2DPOLRGS2X326RAC
VO5OQW4W2656DIYYRNZ3PO7TQ4JOKQ3GVWE5ALUTYVMX3WMXJOYQC
3S6LU2U5TIU43WRE5RQS3IOLVJLVNCDL4W44FVK2HR3NAXZ7IDUAC
RUBSM5DRA4O7SGD7NO7QYFGDQ2CQL6K7SZTIQVGRWAQHGSFUBGCQC
RRCSHAYZ6RLWVPNYHF2F5FSRL2KKJNPQUQRIJYLJGB23BZQQ7JLQC
ZSF3YFZTDOXMCOC3HOT5C6MQLYLWOR7QJAOUDS2M2Z4SC2YW3GRAC
BaseHunk::AddRoot { change } => BaseHunk::AddRoot { change: f(change)? },
BaseHunk::DelRoot { change } => BaseHunk::DelRoot { change: f(change)? },
BaseHunk::AddRoot { name, inode } => BaseHunk::AddRoot { name: f(name)?, inode: f(inode)? },
BaseHunk::DelRoot { name, inode } => BaseHunk::DelRoot { name: f(name)?, inode: f(inode)? },
}
writeln!(w, "Root",)?;
}
writeln!(w, "Unroot",)?;
Hunk::AddRoot { name, .. } => {
if let Atom::NewVertex(ref n) = name {
PrintableHunk::AddRoot {
start: n.start.0 .0,
}
} else {
unreachable!()
}
}
Hunk::DelRoot { inode, name } => PrintableHunk::DelRoot {
name: to_printable_edge_map(name, hashes),
inode: to_printable_edge_map(inode, hashes),
},
x.up_context = from_printable_pos_vec_offsets(changes, offsets, &new_vertex.up_context)?;
x.down_context = from_printable_pos_vec_offsets(changes, offsets, &new_vertex.down_context)?;
x.up_context = from_printable_pos_vec_offsets(
changes,
offsets,
&new_vertex.up_context,
)?;
x.down_context = from_printable_pos_vec_offsets(
changes,
offsets,
&new_vertex.down_context,
)?;
x.up_context = from_printable_pos_vec_offsets(changes, offsets, &replacement.up_context)?;
x.down_context = from_printable_pos_vec_offsets(changes, offsets, &replacement.down_context)?;
x.up_context =
from_printable_pos_vec_offsets(changes, offsets, &replacement.up_context)?;
x.down_context = from_printable_pos_vec_offsets(
changes,
offsets,
&replacement.down_context,
)?;
c.up_context = from_printable_pos_vec_offsets(changes, offsets, &change.up_context)?;
c.down_context = from_printable_pos_vec_offsets(changes, offsets, &change.down_context)?;
c.up_context =
from_printable_pos_vec_offsets(changes, offsets, &change.up_context)?;
c.down_context =
from_printable_pos_vec_offsets(changes, offsets, &change.down_context)?;
PrintableHunk::AddRoot { start } => {
contents_.push(0);
let root_inode = Position {
change: Some(Hash::None),
pos: ChangePosition(contents_.len().into()),
};
contents_.push(0);
let inode = contents_.len();
contents_.push(0);
if let Entry::Occupied(mut e) = updatables.entry(hunk_id as usize) {
if let crate::InodeUpdate::Add { ref mut pos, .. } = e.get_mut() {
offsets.insert(pos.0.into(), ChangePosition((start + 1).into()));
*pos = ChangePosition((start + 1).into())
}
}
Ok(Hunk::AddRoot {
name: Atom::NewVertex(NewVertex {
up_context: vec![root_inode],
down_context: Vec::new(),
start: ChangePosition(start.into()),
end: ChangePosition(start.into()),
flag: EdgeFlags::FOLDER | EdgeFlags::BLOCK,
inode: root_inode,
}),
inode: Atom::NewVertex(NewVertex {
up_context: vec![Position {
change: None,
pos: ChangePosition(start.into()),
}],
down_context: Vec::new(),
start: ChangePosition(inode.into()),
end: ChangePosition(inode.into()),
flag: EdgeFlags::FOLDER | EdgeFlags::BLOCK,
inode: root_inode,
})
})
}
PrintableHunk::DelRoot { name, inode } => {
let root_inode = PrintablePos(1, 0);
Ok(Hunk::DelRoot {
name: Atom::EdgeMap(EdgeMap {
edges: from_printable_edge_map(&name, changes)?,
inode: from_printable_pos(changes, root_inode)?,
}),
inode: Atom::EdgeMap(EdgeMap {
edges: from_printable_edge_map(&inode, changes)?,
inode: from_printable_pos(changes, root_inode)?,
}),
})
}
let (name, perms) = if n.start == n.end {
("", InodeMetadata::DIR)
} else {
let FileMetadata {
basename: name,
metadata: perms,
..
} = FileMetadata::read(&change_contents[n.start.0.into()..n.end.0.into()]);
(name, perms)
};
AddRoot {
start
} => {
writeln!(
w,
"Root add\n up {}, new {}:{}",
PrintablePos(1, 0),
start, start,
)?;
}
DelRoot {
name, inode
} => {
writeln!(
w,
"Root del",
)?;
writeln!(w, "{}", PrintableAtom::Edges(name.to_vec()))?;
writeln!(w, "{}", PrintableAtom::Edges(inode.to_vec()))?;
}
fn parse_root_addition_hunk(i: &str) -> IResult<&str, PrintableHunk> {
debug!("root add {:?}", i);
let (i, _) = delimited(space0, tag("Root add"), space0)(i)?;
let (i, _) = tuple((space0, newline, multispace0))(i)?;
debug!("root add {:?}", i);
let (i, up_context) = preceded(tag("up"), parse_context)(i)?;
debug!("root add {:?}", i);
let (i, (start, end)) = delimited(space0, parse_start_end, pair(space0, newline))(i)?;
debug!("root add {:?}", i);
assert_eq!(&up_context[..], &[PrintablePos(1, 0)]);
assert_eq!(start, end);
Ok((
i,
PrintableHunk::AddRoot {
start
},
))
}
fn parse_root_deletion_hunk(i: &str) -> IResult<&str, PrintableHunk> {
let (i, _) = delimited(space0, tag("Root del"), space0)(i)?;
let (i, _) = tuple((space0, newline))(i)?;
let (i, name) = parse_edges(i)?;
let (i, inode) = parse_edges(i)?;
Ok((
i,
PrintableHunk::DelRoot {
inode, name
},
))
}