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

revset: flatten match arms of description|author|committer predicates

Since most of the code duplicates has been extracted to helper functions,
nested match statement looks more verbose.
This commit is contained in:
Yuya Nishihara 2022-11-15 19:45:53 +09:00
parent 18feef3775
commit 19a3fb7d6c

View file

@ -735,18 +735,20 @@ fn parse_function_expression(
expect_no_arguments(name, arguments_pair)?; expect_no_arguments(name, arguments_pair)?;
Ok(RevsetExpression::all().with_parent_count(2..u32::MAX)) Ok(RevsetExpression::all().with_parent_count(2..u32::MAX))
} }
"description" | "author" | "committer" => { "description" => {
let arg = expect_one_argument(name, arguments_pair)?; let arg = expect_one_argument(name, arguments_pair)?;
let needle = parse_function_argument_to_string(name, arg)?; let needle = parse_function_argument_to_string(name, arg)?;
let candidates = RevsetExpression::all(); Ok(RevsetExpression::all().with_description(needle))
match name { }
"description" => Ok(candidates.with_description(needle)), "author" => {
"author" => Ok(candidates.with_author(needle)), let arg = expect_one_argument(name, arguments_pair)?;
"committer" => Ok(candidates.with_committer(needle)), let needle = parse_function_argument_to_string(name, arg)?;
_ => { Ok(RevsetExpression::all().with_author(needle))
panic!("unexpected function name: {}", name) }
} "committer" => {
} let arg = expect_one_argument(name, arguments_pair)?;
let needle = parse_function_argument_to_string(name, arg)?;
Ok(RevsetExpression::all().with_committer(needle))
} }
"file" => { "file" => {
if let Some(ctx) = workspace_ctx { if let Some(ctx) = workspace_ctx {