diff --git a/cli/src/commands/log.rs b/cli/src/commands/log.rs index 864b9b3c13..641323a8e6 100644 --- a/cli/src/commands/log.rs +++ b/cli/src/commands/log.rs @@ -140,23 +140,14 @@ pub(crate) fn cmd_log( has_missing = true; } RevsetGraphEdgeType::Direct => { - graphlog_edges.push(Edge::Present { - direct: true, - target: (edge.target, false), - }); + graphlog_edges.push(Edge::Direct((edge.target, false))); } RevsetGraphEdgeType::Indirect => { if use_elided_nodes { elided_targets.push(edge.target.clone()); - graphlog_edges.push(Edge::Present { - direct: true, - target: (edge.target, true), - }); + graphlog_edges.push(Edge::Direct((edge.target, true))); } else { - graphlog_edges.push(Edge::Present { - direct: false, - target: (edge.target, false), - }); + graphlog_edges.push(Edge::Indirect((edge.target, false))); } } } @@ -201,10 +192,7 @@ pub(crate) fn cmd_log( for elided_target in elided_targets { let elided_key = (elided_target, true); let real_key = (elided_key.0.clone(), false); - let edges = [Edge::Present { - direct: true, - target: real_key, - }]; + let edges = [Edge::Direct(real_key)]; let mut buffer = vec![]; with_content_format.write_graph_text( ui.new_formatter(&mut buffer).as_mut(), diff --git a/cli/src/commands/obslog.rs b/cli/src/commands/obslog.rs index fccd1131f6..5994b8fe28 100644 --- a/cli/src/commands/obslog.rs +++ b/cli/src/commands/obslog.rs @@ -95,7 +95,7 @@ pub(crate) fn cmd_obslog( for commit in commits { let mut edges = vec![]; for predecessor in &commit.predecessors() { - edges.push(Edge::direct(predecessor.id().clone())); + edges.push(Edge::Direct(predecessor.id().clone())); } let mut buffer = vec![]; with_content_format.write_graph_text( diff --git a/cli/src/commands/operation.rs b/cli/src/commands/operation.rs index 829e14d514..f5cf527814 100644 --- a/cli/src/commands/operation.rs +++ b/cli/src/commands/operation.rs @@ -184,7 +184,7 @@ fn cmd_op_log( let op = op?; let mut edges = vec![]; for id in op.parent_ids() { - edges.push(Edge::direct(id.clone())); + edges.push(Edge::Direct(id.clone())); } let is_current_op = Some(op.id()) == current_op_id; let mut buffer = vec![]; diff --git a/cli/src/graphlog.rs b/cli/src/graphlog.rs index 74daa1c298..9e9c598397 100644 --- a/cli/src/graphlog.rs +++ b/cli/src/graphlog.rs @@ -23,30 +23,11 @@ use renderdag::{Ancestor, GraphRowRenderer, Renderer}; #[derive(Debug, Clone, PartialEq, Eq)] // An edge to another node in the graph pub enum Edge { - Present { target: T, direct: bool }, + Direct(T), + Indirect(T), Missing, } -impl Edge { - pub fn missing() -> Self { - Edge::Missing - } - - pub fn direct(id: T) -> Self { - Edge::Present { - target: id, - direct: true, - } - } - - pub fn indirect(id: T) -> Self { - Edge::Present { - target: id, - direct: false, - } - } -} - pub trait GraphLog { fn add_node( &mut self, @@ -73,11 +54,8 @@ pub struct SaplingGraphLog<'writer, R> { impl From<&Edge> for Ancestor { fn from(e: &Edge) -> Self { match e { - Edge::Present { - target, - direct: true, - } => Ancestor::Parent(target.clone()), - Edge::Present { target, .. } => Ancestor::Ancestor(target.clone()), + Edge::Direct(target) => Ancestor::Parent(target.clone()), + Edge::Indirect(target) => Ancestor::Ancestor(target.clone()), Edge::Missing => Ancestor::Anonymous, } }