diff --git a/cli/src/commands/evolog.rs b/cli/src/commands/evolog.rs index bd2747733..290945896 100644 --- a/cli/src/commands/evolog.rs +++ b/cli/src/commands/evolog.rs @@ -32,6 +32,7 @@ use crate::diff_util::DiffRenderer; use crate::formatter::Formatter; use crate::graphlog::get_graphlog; use crate::graphlog::Edge; +use crate::graphlog::GraphStyle; use crate::ui::Ui; /// Show how a change has evolved over time @@ -143,7 +144,8 @@ pub(crate) fn cmd_evolog( commits.truncate(n); } if !args.no_graph { - let mut graph = get_graphlog(command.settings(), formatter.raw()); + let graph_style = GraphStyle::from_settings(command.settings()); + let mut graph = get_graphlog(graph_style, formatter.raw()); for commit in commits { let mut edges = vec![]; for predecessor in commit.predecessors() { diff --git a/cli/src/commands/log.rs b/cli/src/commands/log.rs index 26cf497d2..7969537bc 100644 --- a/cli/src/commands/log.rs +++ b/cli/src/commands/log.rs @@ -33,6 +33,7 @@ use crate::diff_util::DiffFormatArgs; use crate::graphlog::get_graphlog; use crate::graphlog::node_template_for_key; use crate::graphlog::Edge; +use crate::graphlog::GraphStyle; use crate::ui::Ui; /// Show revision history @@ -164,7 +165,8 @@ pub(crate) fn cmd_log( let limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX); if !args.no_graph { - let mut graph = get_graphlog(command.settings(), formatter.raw()); + let graph_style = GraphStyle::from_settings(command.settings()); + let mut graph = get_graphlog(graph_style, formatter.raw()); let forward_iter = TopoGroupedGraphIterator::new(revset.iter_graph()); let iter: Box> = if args.reversed { Box::new(ReverseGraphIterator::new(forward_iter)) diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index 8ddf556ab..6985aa9a1 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -47,6 +47,7 @@ use crate::diff_util::DiffRenderer; use crate::formatter::Formatter; use crate::graphlog::get_graphlog; use crate::graphlog::Edge; +use crate::graphlog::GraphStyle; use crate::templater::TemplateRenderer; use crate::ui::Ui; @@ -216,7 +217,8 @@ pub fn show_op_diff( writeln!(formatter)?; writeln!(formatter, "Changed commits:")?; if show_graph { - let mut graph = get_graphlog(command.settings(), formatter.raw()); + let graph_style = GraphStyle::from_settings(command.settings()); + let mut graph = get_graphlog(graph_style, formatter.raw()); let graph_iter = TopoGroupedGraphIterator::new(ordered_change_ids.iter().map(|change_id| { diff --git a/cli/src/commands/operation/log.rs b/cli/src/commands/operation/log.rs index 6520aa3be..8fe01255a 100644 --- a/cli/src/commands/operation/log.rs +++ b/cli/src/commands/operation/log.rs @@ -24,6 +24,7 @@ use crate::command_error::CommandError; use crate::graphlog::get_graphlog; use crate::graphlog::node_template_for_key; use crate::graphlog::Edge; +use crate::graphlog::GraphStyle; use crate::operation_templater::OperationTemplateLanguage; use crate::ui::Ui; @@ -116,7 +117,8 @@ pub fn cmd_op_log( let limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX); let iter = op_walk::walk_ancestors(slice::from_ref(¤t_op)).take(limit); if !args.no_graph { - let mut graph = get_graphlog(command.settings(), formatter.raw()); + let graph_style = GraphStyle::from_settings(command.settings()); + let mut graph = get_graphlog(graph_style, formatter.raw()); for op in iter { let op = op?; let mut edges = vec![]; diff --git a/cli/src/graphlog.rs b/cli/src/graphlog.rs index 6a422fea1..95f8e257d 100644 --- a/cli/src/graphlog.rs +++ b/cli/src/graphlog.rs @@ -142,11 +142,11 @@ pub fn node_template_for_key( } pub fn get_graphlog<'a, K: Clone + Eq + Hash + 'a>( - settings: &UserSettings, + style: GraphStyle, formatter: &'a mut dyn Write, ) -> Box + 'a> { let builder = GraphRowRenderer::new().output().with_min_row_height(0); - match GraphStyle::from_settings(settings) { + match style { GraphStyle::Ascii => SaplingGraphLog::create(builder.build_ascii(), formatter), GraphStyle::AsciiLarge => SaplingGraphLog::create(builder.build_ascii_large(), formatter), GraphStyle::Curved => SaplingGraphLog::create(builder.build_box_drawing(), formatter),