From cf48d6b6c0f100870bdf9c0cf78822bad6df5ef1 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 16 Apr 2021 23:01:03 -0700 Subject: [PATCH] cli: use revsets for walking revisions for log output --- src/commands.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index c9e97da65..52434e0f4 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1094,17 +1094,16 @@ fn cmd_log( styler.add_label(String::from("log"))?; let store = repo.store(); - let mut head_ids = repo.view().heads().clone(); - if !sub_matches.is_present("all") { - head_ids = skip_uninteresting_heads(&repo, repo.view().heads()); + let revision_str = if sub_matches.is_present("all") { + "*:all_heads()" + } else { + "*:non_obsolete_heads()" }; - - let head_ids: Vec<_> = head_ids.into_iter().collect(); - let index = repo.index(); - let index_entries = index.walk_revs(&head_ids, &[]); + let revset_expression = revset::parse(revision_str)?; + let revset = revset::evaluate_expression(repo.as_repo_ref(), &revset_expression)?; if use_graph { let mut graph = AsciiGraphDrawer::new(&mut styler); - for index_entry in index_entries { + for index_entry in revset.iter() { let commit = store.get_commit(&index_entry.commit_id()).unwrap(); let mut edges = vec![]; for parent in commit.parents() { @@ -1123,7 +1122,7 @@ fn cmd_log( graph.add_node(commit.id(), &edges, b"o", &buffer)?; } } else { - for index_entry in index_entries { + for index_entry in revset.iter() { let commit = store.get_commit(&index_entry.commit_id()).unwrap(); template.format(&commit, styler)?; }