diff --git a/cli/src/commands/operation.rs b/cli/src/commands/operation.rs index 1cf951dd6..bc1915482 100644 --- a/cli/src/commands/operation.rs +++ b/cli/src/commands/operation.rs @@ -125,7 +125,7 @@ fn cmd_op_log( ui.request_pager(); let mut formatter = ui.stdout_formatter(); let formatter = formatter.as_mut(); - let iter = op_walk::walk_ancestors(&head_op).take(args.limit.unwrap_or(usize::MAX)); + let iter = op_walk::walk_ancestors(&[head_op]).take(args.limit.unwrap_or(usize::MAX)); if !args.no_graph { let mut graph = get_graphlog(command.settings(), formatter.raw()); let default_node_symbol = graph.default_node_symbol().to_owned(); diff --git a/lib/src/op_walk.rs b/lib/src/op_walk.rs index 4b02a1737..7fc47061f 100644 --- a/lib/src/op_walk.rs +++ b/lib/src/op_walk.rs @@ -195,12 +195,15 @@ impl PartialOrd for OperationByEndTime { } } -/// Walks `head_op` and its ancestors in reverse topological order. -pub fn walk_ancestors(head_op: &Operation) -> impl Iterator> { +/// Walks `head_ops` and their ancestors in reverse topological order. +pub fn walk_ancestors(head_ops: &[Operation]) -> impl Iterator> { // Lazily load operations based on timestamp-based heuristic. This works so long // as the operation history is mostly linear. dag_walk::topo_order_reverse_lazy_ok( - [Ok(OperationByEndTime(head_op.clone()))], + head_ops + .iter() + .map(|op| Ok(OperationByEndTime(op.clone()))) + .collect_vec(), |OperationByEndTime(op)| op.id().clone(), |OperationByEndTime(op)| op.parents().map_ok(OperationByEndTime).collect_vec(), )