From 362ee2f641ee5578dc492df752151df3077d324f Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 7 May 2020 13:51:24 +0200 Subject: Annotate types in the graph --- src/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index d6e9013..b891595 100644 --- a/src/main.rs +++ b/src/main.rs @@ -148,11 +148,11 @@ fn write_dot bool>(stream: &mut W, history: &mut match history.node_for(key).unwrap() { HistoryNode::Genesis(oid) => { - writeln!(stream, "\t\"{}\" [label=\"G\"];", oid)?; + writeln!(stream, "\t\"{}\" [label=\"G= {}\"];", oid, oid)?; next_keys = Vec::new(); }, HistoryNode::Reference(oid, parents) => { - writeln!(stream, "\t\"{}\" [label=\"{}\"];", oid, refmap.get(oid).unwrap().reference.shorthand().expect("Reference name not valid utf8"))?; + writeln!(stream, "\t\"{}\" [label=\"R= {}\"];", oid, refmap.get(oid).unwrap().reference.shorthand().expect("Reference name not valid utf8"))?; // writeln!(stream, "\t\"{}\" [label=\"R\"];", oid)?; for &parent in parents { let node = history.node_for(parent).unwrap(); @@ -161,7 +161,7 @@ fn write_dot bool>(stream: &mut W, history: &mut next_keys = parents.clone(); }, HistoryNode::Merge(oid, parents) => { - writeln!(stream, "\t\"{}\" [label=\"\"];", oid)?; + writeln!(stream, "\t\"{}\" [label=\"M= {}\"];", oid, if (history.is_reference)(oid) { refmap.get(oid).unwrap().reference.shorthand().expect("Reference name not valid utf8") } else { "" })?; for &parent in parents { let node = history.node_for(parent).unwrap(); writeln!(stream, "\t\"{}\" -> \"{}\";", node.oid(), oid)?; @@ -190,15 +190,17 @@ fn main() -> Result<()> { for reference in repo.references().to_io_result()? { let reference = reference.to_io_result()?; + eprintln!("reference: {:?}", reference.name()); if reference.is_tag() || reference.is_remote() { let reference = reference.resolve().to_io_result()?; match reference.peel_to_commit() { Ok(commit) => { - let oid = reference.target().expect("Resolved reference is not a direct reference?"); + // let oid = reference.target().expect("Resolved reference is not a direct reference?"); + eprintln!(" -> taken commit id \x1B[41m{}\x1B[0m", commit.id()); + // eprintln!("{} {}", + // reference.name().expect("Invalid utf8 in reference name"), + // commit.id()); refmap.insert(commit.id(), RefInfo { reference, commit }); - // println!("{} {}", - // reference.name().expect("Invalid utf8 in reference name"), - // commit.id()); } Err(_) => {}, } -- cgit v1.2.3-70-g09d2