mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 23:32:41 +00:00
revset: remove pre-calculation of arguments count
This commit is contained in:
parent
1d4b5fd8a7
commit
f4cb91c7dd
1 changed files with 8 additions and 8 deletions
|
@ -594,7 +594,6 @@ fn parse_function_expression(
|
|||
argument_pairs: Pairs<Rule>,
|
||||
workspace_ctx: Option<&RevsetWorkspaceContext>,
|
||||
) -> Result<Rc<RevsetExpression>, RevsetParseError> {
|
||||
let arg_count = argument_pairs.clone().count();
|
||||
match name.as_str() {
|
||||
"parents" => {
|
||||
let arg = expect_one_argument(&name, argument_pairs)?;
|
||||
|
@ -684,12 +683,6 @@ fn parse_function_expression(
|
|||
}
|
||||
}
|
||||
"file" => {
|
||||
if arg_count < 1 {
|
||||
return Err(RevsetParseError::InvalidFunctionArguments {
|
||||
name,
|
||||
message: "Expected at least 1 argument".to_string(),
|
||||
});
|
||||
}
|
||||
if let Some(ctx) = workspace_ctx {
|
||||
let paths = argument_pairs
|
||||
.map(|arg| {
|
||||
|
@ -698,7 +691,14 @@ fn parse_function_expression(
|
|||
Ok(path)
|
||||
})
|
||||
.collect::<Result<Vec<_>, RevsetParseError>>()?;
|
||||
Ok(RevsetExpression::all().with_file(paths))
|
||||
if paths.is_empty() {
|
||||
Err(RevsetParseError::InvalidFunctionArguments {
|
||||
name,
|
||||
message: "Expected at least 1 argument".to_string(),
|
||||
})
|
||||
} else {
|
||||
Ok(RevsetExpression::all().with_file(paths))
|
||||
}
|
||||
} else {
|
||||
Err(RevsetParseError::FsPathWithoutWorkspace)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue