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

revset: add none() function

This commit is contained in:
Martin von Zweigbergk 2021-10-13 09:07:18 -07:00
parent 8fef1c2068
commit 5874d5abfb
2 changed files with 20 additions and 0 deletions

View file

@ -552,6 +552,16 @@ fn parse_function_expression(
})
}
}
"none" => {
if arg_count == 0 {
Ok(RevsetExpression::none())
} else {
Err(RevsetParseError::InvalidFunctionArguments {
name,
message: "Expected 0 arguments".to_string(),
})
}
}
"heads" => {
if arg_count == 0 {
Ok(RevsetExpression::heads())

View file

@ -765,6 +765,16 @@ fn test_evaluate_expression_descendants(use_git: bool) {
tx.discard();
}
#[test_case(false ; "local backend")]
#[test_case(true ; "git backend")]
fn test_evaluate_expression_none(use_git: bool) {
let settings = testutils::user_settings();
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
// none() is empty (doesn't include the checkout, for example)
assert_eq!(resolve_commit_ids(repo.as_repo_ref(), "none()"), vec![]);
}
#[test_case(false ; "local backend")]
#[test_case(true ; "git backend")]
fn test_evaluate_expression_heads(use_git: bool) {