mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-29 23:57:51 +00:00
lib: Add RevsetExpression::filtered()
.
This allows users to easily filter a commit range by conflicts, which will be needed for `next/prev` further down in the next commit. Users which benefit from it were also migrated.
This commit is contained in:
parent
c9b3d64ce5
commit
0d9000271e
3 changed files with 13 additions and 5 deletions
|
@ -1408,9 +1408,8 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin
|
||||||
// are millions of commits added to the repo, assuming the revset engine can
|
// are millions of commits added to the repo, assuming the revset engine can
|
||||||
// efficiently skip non-conflicting commits. Filter out empty commits mostly so
|
// efficiently skip non-conflicting commits. Filter out empty commits mostly so
|
||||||
// `jj new <conflicted commit>` doesn't result in a message about new conflicts.
|
// `jj new <conflicted commit>` doesn't result in a message about new conflicts.
|
||||||
let conflicts = RevsetExpression::filter(RevsetFilterPredicate::HasConflict).intersection(
|
let conflicts = RevsetExpression::filter(RevsetFilterPredicate::HasConflict)
|
||||||
&RevsetExpression::filter(RevsetFilterPredicate::File(FilesetExpression::all())),
|
.filtered(RevsetFilterPredicate::File(FilesetExpression::all()));
|
||||||
);
|
|
||||||
let removed_conflicts_expr = new_heads.range(&old_heads).intersection(&conflicts);
|
let removed_conflicts_expr = new_heads.range(&old_heads).intersection(&conflicts);
|
||||||
let added_conflicts_expr = old_heads.range(&new_heads).intersection(&conflicts);
|
let added_conflicts_expr = old_heads.range(&new_heads).intersection(&conflicts);
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,10 @@ pub(crate) fn cmd_status(
|
||||||
// Ancestors with conflicts, excluding the current working copy commit.
|
// Ancestors with conflicts, excluding the current working copy commit.
|
||||||
let ancestors_conflicts = workspace_command
|
let ancestors_conflicts = workspace_command
|
||||||
.attach_revset_evaluator(
|
.attach_revset_evaluator(
|
||||||
RevsetExpression::filter(RevsetFilterPredicate::HasConflict)
|
wc_revset
|
||||||
.intersection(&wc_revset.parents().ancestors())
|
.parents()
|
||||||
|
.ancestors()
|
||||||
|
.filtered(RevsetFilterPredicate::HasConflict)
|
||||||
.minus(&revset_util::parse_immutable_expression(
|
.minus(&revset_util::parse_immutable_expression(
|
||||||
&workspace_command.revset_parse_context(),
|
&workspace_command.revset_parse_context(),
|
||||||
)?),
|
)?),
|
||||||
|
|
|
@ -353,6 +353,13 @@ impl RevsetExpression {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Filter all commits by `predicate` in `self`.
|
||||||
|
pub fn filtered(
|
||||||
|
self: &Rc<RevsetExpression>,
|
||||||
|
predicate: RevsetFilterPredicate,
|
||||||
|
) -> Rc<RevsetExpression> {
|
||||||
|
self.intersection(&RevsetExpression::filter(predicate))
|
||||||
|
}
|
||||||
/// Commits that are descendants of `self` and ancestors of `heads`, both
|
/// Commits that are descendants of `self` and ancestors of `heads`, both
|
||||||
/// inclusive.
|
/// inclusive.
|
||||||
pub fn dag_range_to(
|
pub fn dag_range_to(
|
||||||
|
|
Loading…
Reference in a new issue