mirror of
https://github.com/martinvonz/jj.git
synced 2024-10-25 07:56:16 +00:00
commands: make skip_uninteresting_heads() work on CommitIds
This commit is contained in:
parent
998e23db3c
commit
c03be2e035
1 changed files with 20 additions and 22 deletions
|
@ -134,13 +134,11 @@ fn resolve_single_rev(
|
||||||
} else if revision_str.starts_with("desc(") && revision_str.ends_with(')') {
|
} else if revision_str.starts_with("desc(") && revision_str.ends_with(')') {
|
||||||
let needle = revision_str[5..revision_str.len() - 1].to_string();
|
let needle = revision_str[5..revision_str.len() - 1].to_string();
|
||||||
let mut matches = vec![];
|
let mut matches = vec![];
|
||||||
let heads: HashSet<Commit> = repo
|
let head_ids = skip_uninteresting_heads(repo, &repo.view().heads());
|
||||||
.view()
|
let heads: Vec<_> = head_ids
|
||||||
.heads()
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|commit_id| repo.store().get_commit(commit_id).unwrap())
|
.map(|id| repo.store().get_commit(&id).unwrap())
|
||||||
.collect();
|
.collect();
|
||||||
let heads = skip_uninteresting_heads(repo, heads);
|
|
||||||
for commit in walk_ancestors(heads) {
|
for commit in walk_ancestors(heads) {
|
||||||
if commit.description().contains(&needle) {
|
if commit.description().contains(&needle) {
|
||||||
matches.push(commit);
|
matches.push(commit);
|
||||||
|
@ -994,23 +992,28 @@ fn graph_log_template(settings: &UserSettings) -> String {
|
||||||
.unwrap_or_else(|_| String::from(default_template))
|
.unwrap_or_else(|_| String::from(default_template))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn skip_uninteresting_heads(repo: &ReadonlyRepo, heads: HashSet<Commit>) -> HashSet<Commit> {
|
fn skip_uninteresting_heads(repo: &ReadonlyRepo, heads: &HashSet<CommitId>) -> HashSet<CommitId> {
|
||||||
|
let index = repo.index();
|
||||||
let checkout_id = repo.view().checkout().clone();
|
let checkout_id = repo.view().checkout().clone();
|
||||||
let mut result = HashSet::new();
|
let mut result = HashSet::new();
|
||||||
let mut work: Vec<_> = heads.into_iter().collect();
|
let mut work: Vec<_> = heads
|
||||||
|
.iter()
|
||||||
|
.map(|id| index.entry_by_id(id).unwrap())
|
||||||
|
.collect();
|
||||||
let evolution = repo.evolution();
|
let evolution = repo.evolution();
|
||||||
while !work.is_empty() {
|
while !work.is_empty() {
|
||||||
let commit = work.pop().unwrap();
|
let index_entry = work.pop().unwrap();
|
||||||
if result.contains(&commit) {
|
let commit_id = index_entry.commit_id();
|
||||||
|
if result.contains(&commit_id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!commit.is_pruned() && !evolution.is_obsolete(commit.id()))
|
if (!index_entry.is_pruned() && !evolution.is_obsolete(&commit_id))
|
||||||
|| commit.id() == &checkout_id
|
|| commit_id == checkout_id
|
||||||
{
|
{
|
||||||
result.insert(commit);
|
result.insert(commit_id);
|
||||||
} else {
|
} else {
|
||||||
for parent in commit.parents() {
|
for parent_entry in index_entry.parents() {
|
||||||
work.push(parent);
|
work.push(parent_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1050,17 +1053,12 @@ 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 heads: HashSet<_> = repo
|
let mut head_ids = repo.view().heads().clone();
|
||||||
.view()
|
|
||||||
.heads()
|
|
||||||
.iter()
|
|
||||||
.map(|id| store.get_commit(id).unwrap())
|
|
||||||
.collect();
|
|
||||||
if !sub_matches.is_present("all") {
|
if !sub_matches.is_present("all") {
|
||||||
heads = skip_uninteresting_heads(&repo, heads);
|
head_ids = skip_uninteresting_heads(&repo, repo.view().heads());
|
||||||
};
|
};
|
||||||
|
|
||||||
let head_ids: Vec<_> = heads.iter().map(|commit| commit.id().clone()).collect();
|
let head_ids: Vec<_> = head_ids.into_iter().collect();
|
||||||
let index = repo.index();
|
let index = repo.index();
|
||||||
let index_entries = index.walk_revs(&head_ids, &[]);
|
let index_entries = index.walk_revs(&head_ids, &[]);
|
||||||
if use_graph {
|
if use_graph {
|
||||||
|
|
Loading…
Reference in a new issue