forked from mirrors/jj
graphlog: load settings by caller
I'll make it error out if the style name is invalid.
This commit is contained in:
parent
bd7cbaaffb
commit
406ead241b
5 changed files with 14 additions and 6 deletions
|
@ -32,6 +32,7 @@ use crate::diff_util::DiffRenderer;
|
||||||
use crate::formatter::Formatter;
|
use crate::formatter::Formatter;
|
||||||
use crate::graphlog::get_graphlog;
|
use crate::graphlog::get_graphlog;
|
||||||
use crate::graphlog::Edge;
|
use crate::graphlog::Edge;
|
||||||
|
use crate::graphlog::GraphStyle;
|
||||||
use crate::ui::Ui;
|
use crate::ui::Ui;
|
||||||
|
|
||||||
/// Show how a change has evolved over time
|
/// Show how a change has evolved over time
|
||||||
|
@ -143,7 +144,8 @@ pub(crate) fn cmd_evolog(
|
||||||
commits.truncate(n);
|
commits.truncate(n);
|
||||||
}
|
}
|
||||||
if !args.no_graph {
|
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 {
|
for commit in commits {
|
||||||
let mut edges = vec![];
|
let mut edges = vec![];
|
||||||
for predecessor in commit.predecessors() {
|
for predecessor in commit.predecessors() {
|
||||||
|
|
|
@ -33,6 +33,7 @@ use crate::diff_util::DiffFormatArgs;
|
||||||
use crate::graphlog::get_graphlog;
|
use crate::graphlog::get_graphlog;
|
||||||
use crate::graphlog::node_template_for_key;
|
use crate::graphlog::node_template_for_key;
|
||||||
use crate::graphlog::Edge;
|
use crate::graphlog::Edge;
|
||||||
|
use crate::graphlog::GraphStyle;
|
||||||
use crate::ui::Ui;
|
use crate::ui::Ui;
|
||||||
|
|
||||||
/// Show revision history
|
/// Show revision history
|
||||||
|
@ -164,7 +165,8 @@ pub(crate) fn cmd_log(
|
||||||
let limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX);
|
let limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX);
|
||||||
|
|
||||||
if !args.no_graph {
|
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 forward_iter = TopoGroupedGraphIterator::new(revset.iter_graph());
|
||||||
let iter: Box<dyn Iterator<Item = _>> = if args.reversed {
|
let iter: Box<dyn Iterator<Item = _>> = if args.reversed {
|
||||||
Box::new(ReverseGraphIterator::new(forward_iter))
|
Box::new(ReverseGraphIterator::new(forward_iter))
|
||||||
|
|
|
@ -47,6 +47,7 @@ use crate::diff_util::DiffRenderer;
|
||||||
use crate::formatter::Formatter;
|
use crate::formatter::Formatter;
|
||||||
use crate::graphlog::get_graphlog;
|
use crate::graphlog::get_graphlog;
|
||||||
use crate::graphlog::Edge;
|
use crate::graphlog::Edge;
|
||||||
|
use crate::graphlog::GraphStyle;
|
||||||
use crate::templater::TemplateRenderer;
|
use crate::templater::TemplateRenderer;
|
||||||
use crate::ui::Ui;
|
use crate::ui::Ui;
|
||||||
|
|
||||||
|
@ -216,7 +217,8 @@ pub fn show_op_diff(
|
||||||
writeln!(formatter)?;
|
writeln!(formatter)?;
|
||||||
writeln!(formatter, "Changed commits:")?;
|
writeln!(formatter, "Changed commits:")?;
|
||||||
if show_graph {
|
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 =
|
let graph_iter =
|
||||||
TopoGroupedGraphIterator::new(ordered_change_ids.iter().map(|change_id| {
|
TopoGroupedGraphIterator::new(ordered_change_ids.iter().map(|change_id| {
|
||||||
|
|
|
@ -24,6 +24,7 @@ use crate::command_error::CommandError;
|
||||||
use crate::graphlog::get_graphlog;
|
use crate::graphlog::get_graphlog;
|
||||||
use crate::graphlog::node_template_for_key;
|
use crate::graphlog::node_template_for_key;
|
||||||
use crate::graphlog::Edge;
|
use crate::graphlog::Edge;
|
||||||
|
use crate::graphlog::GraphStyle;
|
||||||
use crate::operation_templater::OperationTemplateLanguage;
|
use crate::operation_templater::OperationTemplateLanguage;
|
||||||
use crate::ui::Ui;
|
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 limit = args.limit.or(args.deprecated_limit).unwrap_or(usize::MAX);
|
||||||
let iter = op_walk::walk_ancestors(slice::from_ref(¤t_op)).take(limit);
|
let iter = op_walk::walk_ancestors(slice::from_ref(¤t_op)).take(limit);
|
||||||
if !args.no_graph {
|
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 {
|
for op in iter {
|
||||||
let op = op?;
|
let op = op?;
|
||||||
let mut edges = vec![];
|
let mut edges = vec![];
|
||||||
|
|
|
@ -142,11 +142,11 @@ pub fn node_template_for_key(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_graphlog<'a, K: Clone + Eq + Hash + 'a>(
|
pub fn get_graphlog<'a, K: Clone + Eq + Hash + 'a>(
|
||||||
settings: &UserSettings,
|
style: GraphStyle,
|
||||||
formatter: &'a mut dyn Write,
|
formatter: &'a mut dyn Write,
|
||||||
) -> Box<dyn GraphLog<K> + 'a> {
|
) -> Box<dyn GraphLog<K> + 'a> {
|
||||||
let builder = GraphRowRenderer::new().output().with_min_row_height(0);
|
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::Ascii => SaplingGraphLog::create(builder.build_ascii(), formatter),
|
||||||
GraphStyle::AsciiLarge => SaplingGraphLog::create(builder.build_ascii_large(), formatter),
|
GraphStyle::AsciiLarge => SaplingGraphLog::create(builder.build_ascii_large(), formatter),
|
||||||
GraphStyle::Curved => SaplingGraphLog::create(builder.build_box_drawing(), formatter),
|
GraphStyle::Curved => SaplingGraphLog::create(builder.build_box_drawing(), formatter),
|
||||||
|
|
Loading…
Reference in a new issue