revset: allow empty string literal ""

This commit is contained in:
Yuya Nishihara 2022-11-20 12:06:09 +09:00
parent 57ff990fe8
commit 84efed420f
3 changed files with 13 additions and 1 deletions

View file

@ -21,7 +21,7 @@ symbol = {
identifier
| literal_string
}
literal_string = { "\"" ~ (!"\"" ~ ANY)+ ~ "\"" }
literal_string = { "\"" ~ (!"\"" ~ ANY)* ~ "\"" }
whitespace = _{ " " }
parents_op = { "-" }

View file

@ -1890,6 +1890,12 @@ mod tests {
message: "Expected 1 argument".to_string()
})
);
assert_eq!(
parse(r#"description("")"#),
Ok(RevsetExpression::filter(
RevsetFilterPredicate::Description("".to_string())
))
);
assert_eq!(
parse("description(foo)"),
Ok(RevsetExpression::filter(

View file

@ -102,6 +102,12 @@ fn test_resolve_symbol_commit_id() {
Ok(vec![commits[2].id().clone()])
);
// Test empty commit id
assert_eq!(
resolve_symbol(repo_ref, "", None),
Err(RevsetError::AmbiguousCommitIdPrefix("".to_string()))
);
// Test commit id prefix
assert_eq!(
resolve_symbol(repo_ref, "046", None),