From 916dc30828b76a7cc576a5acfc88dd6ee9a25feb Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 27 Mar 2024 21:36:40 +0900 Subject: [PATCH] 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. --- cli/tests/test_revset_output.rs | 4 ++-- lib/src/revset.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cli/tests/test_revset_output.rs b/cli/tests/test_revset_output.rs index 3d8260b95..03e4f3e3a 100644 --- a/cli/tests/test_revset_output.rs +++ b/cli/tests/test_revset_output.rs @@ -153,14 +153,14 @@ fn test_bad_function_call() { let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", r#"file(a, "../out")"#]); 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: 1: --> 1:9 | 1 | file(a, "../out") | ^------^ | - = Invalid file pattern + = Function "file": Invalid file pattern 2: Path "../out" is not in the repo "." 3: Invalid component ".." in repo-relative path "../out" "###); diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 040553663..792412f95 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -178,8 +178,6 @@ pub enum RevsetParseErrorKind { }, #[error(r#"Function "{name}": {message}"#)] InvalidFunctionArguments { name: String, message: String }, - #[error("Invalid file pattern")] - FsPathParseError, #[error("Cannot resolve file pattern without workspace")] FsPathWithoutWorkspace, #[error(r#"Cannot resolve "@" without workspace"#)] @@ -1272,7 +1270,10 @@ static BUILTIN_FUNCTION_MAP: Lazy> = Lazy: let path = RepoPathBuf::parse_fs_path(ctx.cwd, ctx.workspace_root, needle) .map_err(|e| { RevsetParseError::with_span_and_source( - RevsetParseErrorKind::FsPathParseError, + RevsetParseErrorKind::InvalidFunctionArguments { + name: name.to_owned(), + message: "Invalid file pattern".to_owned(), + }, span, e, )