ok/jj
1
0
Fork 0
forked from mirrors/jj

revset: remove redundant candidates argument from merges()

Since 'merges()' just filters the candidates set per item, it doesn't need
a candidates argument. Perhaps, 'merges(x)' could be a predicate to select
merge commits within a subgraph 'x', but I don't know if that would be
useful.
This commit is contained in:
Yuya Nishihara 2022-10-25 22:20:59 +09:00
parent 373c63b414
commit 59717aa187
4 changed files with 11 additions and 15 deletions

View file

@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking changes
* Dropped candidates set argument from `description(needle)`, `author(needle)`,
`committer(needle)` revsets. Use `x & description(needle)` instead.
`committer(needle)`, `merges()` revsets. Use `x & description(needle)`
instead.
### New features

View file

@ -101,8 +101,7 @@ revsets (expressions) as arguments.
If `x` was not specified, it selects all visible heads (as if you had said
`heads(all())`).
* `roots(x)`: Commits in `x` that are not descendants of other commits in `x`.
* `merges([x])`: Merge commits within `x`. If `x` was not specified, it selects
all visible merge commits (as if you had said `merges(all())`).
* `merges()`: Merge commits.
* `description(needle)`: Commits with the given string in their
description.
* `author(needle)`: Commits with the given string in the author's name or

View file

@ -745,18 +745,14 @@ fn parse_function_expression(
}
}
"merges" => {
if arg_count > 1 {
return Err(RevsetParseError::InvalidFunctionArguments {
name,
message: "Expected 0 or 1 arguments".to_string(),
});
}
let candidates = if arg_count == 0 {
RevsetExpression::all()
if arg_count == 0 {
Ok(RevsetExpression::all().with_parent_count(2..u32::MAX))
} else {
parse_expression_rule(argument_pairs.next().unwrap().into_inner())?
};
Ok(candidates.with_parent_count(2..u32::MAX))
Err(RevsetParseError::InvalidFunctionArguments {
name,
message: "Expected 0 arguments".to_string(),
})
}
}
"description" | "author" | "committer" | "file" => {
if arg_count != 1 {

View file

@ -1388,7 +1388,7 @@ fn test_evaluate_expression_merges(use_git: bool) {
assert_eq!(
resolve_commit_ids(
mut_repo.as_repo_ref(),
&format!("merges(:{})", commit5.id().hex())
&format!(":{} & merges()", commit5.id().hex())
),
vec![commit5.id().clone()]
);