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

revset: use common argument error instead of FsPathParseError

It's not special compared to the other argument errors, and we can now track
the error source separately.
This commit is contained in:
Yuya Nishihara 2024-03-27 21:36:40 +09:00
parent 074e6e12bc
commit 916dc30828
2 changed files with 6 additions and 5 deletions

View file

@ -153,14 +153,14 @@ fn test_bad_function_call() {
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", r#"file(a, "../out")"#]); let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", r#"file(a, "../out")"#]);
insta::assert_snapshot!(stderr.replace('\\', "/"), @r###" insta::assert_snapshot!(stderr.replace('\\', "/"), @r###"
Error: Failed to parse revset: Invalid file pattern Error: Failed to parse revset: Function "file": Invalid file pattern
Caused by: Caused by:
1: --> 1:9 1: --> 1:9
| |
1 | file(a, "../out") 1 | file(a, "../out")
| ^------^ | ^------^
| |
= Invalid file pattern = Function "file": Invalid file pattern
2: Path "../out" is not in the repo "." 2: Path "../out" is not in the repo "."
3: Invalid component ".." in repo-relative path "../out" 3: Invalid component ".." in repo-relative path "../out"
"###); "###);

View file

@ -178,8 +178,6 @@ pub enum RevsetParseErrorKind {
}, },
#[error(r#"Function "{name}": {message}"#)] #[error(r#"Function "{name}": {message}"#)]
InvalidFunctionArguments { name: String, message: String }, InvalidFunctionArguments { name: String, message: String },
#[error("Invalid file pattern")]
FsPathParseError,
#[error("Cannot resolve file pattern without workspace")] #[error("Cannot resolve file pattern without workspace")]
FsPathWithoutWorkspace, FsPathWithoutWorkspace,
#[error(r#"Cannot resolve "@" without workspace"#)] #[error(r#"Cannot resolve "@" without workspace"#)]
@ -1272,7 +1270,10 @@ static BUILTIN_FUNCTION_MAP: Lazy<HashMap<&'static str, RevsetFunction>> = Lazy:
let path = RepoPathBuf::parse_fs_path(ctx.cwd, ctx.workspace_root, needle) let path = RepoPathBuf::parse_fs_path(ctx.cwd, ctx.workspace_root, needle)
.map_err(|e| { .map_err(|e| {
RevsetParseError::with_span_and_source( RevsetParseError::with_span_and_source(
RevsetParseErrorKind::FsPathParseError, RevsetParseErrorKind::InvalidFunctionArguments {
name: name.to_owned(),
message: "Invalid file pattern".to_owned(),
},
span, span,
e, e,
) )