mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-29 23:57:51 +00:00
cli: use revsets for walking revisions for log output
This commit is contained in:
parent
05e9149157
commit
cf48d6b6c0
1 changed files with 8 additions and 9 deletions
|
@ -1094,17 +1094,16 @@ fn cmd_log(
|
||||||
styler.add_label(String::from("log"))?;
|
styler.add_label(String::from("log"))?;
|
||||||
|
|
||||||
let store = repo.store();
|
let store = repo.store();
|
||||||
let mut head_ids = repo.view().heads().clone();
|
let revision_str = if sub_matches.is_present("all") {
|
||||||
if !sub_matches.is_present("all") {
|
"*:all_heads()"
|
||||||
head_ids = skip_uninteresting_heads(&repo, repo.view().heads());
|
} else {
|
||||||
|
"*:non_obsolete_heads()"
|
||||||
};
|
};
|
||||||
|
let revset_expression = revset::parse(revision_str)?;
|
||||||
let head_ids: Vec<_> = head_ids.into_iter().collect();
|
let revset = revset::evaluate_expression(repo.as_repo_ref(), &revset_expression)?;
|
||||||
let index = repo.index();
|
|
||||||
let index_entries = index.walk_revs(&head_ids, &[]);
|
|
||||||
if use_graph {
|
if use_graph {
|
||||||
let mut graph = AsciiGraphDrawer::new(&mut styler);
|
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 commit = store.get_commit(&index_entry.commit_id()).unwrap();
|
||||||
let mut edges = vec![];
|
let mut edges = vec![];
|
||||||
for parent in commit.parents() {
|
for parent in commit.parents() {
|
||||||
|
@ -1123,7 +1122,7 @@ fn cmd_log(
|
||||||
graph.add_node(commit.id(), &edges, b"o", &buffer)?;
|
graph.add_node(commit.id(), &edges, b"o", &buffer)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for index_entry in index_entries {
|
for index_entry in revset.iter() {
|
||||||
let commit = store.get_commit(&index_entry.commit_id()).unwrap();
|
let commit = store.get_commit(&index_entry.commit_id()).unwrap();
|
||||||
template.format(&commit, styler)?;
|
template.format(&commit, styler)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue