mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 12:48:55 +00:00
revset: for roots:heads, terminate ancestor lookup at min(roots)
This commit is contained in:
parent
ddff089286
commit
85fb1f74c3
3 changed files with 32 additions and 2 deletions
|
@ -825,9 +825,14 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> {
|
|||
S: InternalRevset<'a> + ?Sized,
|
||||
T: InternalRevset<'b> + ?Sized,
|
||||
{
|
||||
let mut reachable: HashSet<_> = root_set.iter().map(|entry| entry.position()).collect();
|
||||
let root_positions = root_set.iter().map(|entry| entry.position()).collect_vec();
|
||||
let bottom_position = *root_positions.last().unwrap_or(&IndexPosition::MAX);
|
||||
let mut reachable: HashSet<_> = root_positions.into_iter().collect();
|
||||
let mut index_entries = vec![];
|
||||
let candidates = self.walk_ancestors(head_set).collect_vec();
|
||||
let candidates = self
|
||||
.walk_ancestors(head_set)
|
||||
.take_while(|entry| entry.position() >= bottom_position)
|
||||
.collect_vec();
|
||||
for candidate in candidates.into_iter().rev() {
|
||||
if reachable.contains(&candidate.position())
|
||||
|| candidate
|
||||
|
|
|
@ -976,6 +976,30 @@ fn test_evaluate_expression_dag_range(use_git: bool) {
|
|||
vec![]
|
||||
);
|
||||
|
||||
// Empty root
|
||||
assert_eq!(
|
||||
resolve_commit_ids(mut_repo, &format!("none():{}", commit5.id().hex())),
|
||||
vec![],
|
||||
);
|
||||
|
||||
// Multiple root, commit1 shouldn't be hidden by commit2
|
||||
assert_eq!(
|
||||
resolve_commit_ids(
|
||||
mut_repo,
|
||||
&format!(
|
||||
"({}|{}):{}",
|
||||
commit1.id().hex(),
|
||||
commit2.id().hex(),
|
||||
commit3.id().hex()
|
||||
)
|
||||
),
|
||||
vec![
|
||||
commit3.id().clone(),
|
||||
commit2.id().clone(),
|
||||
commit1.id().clone()
|
||||
]
|
||||
);
|
||||
|
||||
// Including a merge
|
||||
assert_eq!(
|
||||
resolve_commit_ids(
|
||||
|
|
|
@ -13,6 +13,7 @@ v2.40.0
|
|||
v2.39.0..v2.40.0
|
||||
:v2.40.0 ~ :v2.39.0
|
||||
v2.39.0:v2.40.0
|
||||
v2.40.0+
|
||||
# Tags and branches
|
||||
tags()
|
||||
branches()
|
||||
|
|
Loading…
Reference in a new issue