Skip to content

Commit

Permalink
revset: use common argument error instead of FsPathParseError
Browse files Browse the repository at this point in the history
It's not special compared to the other argument errors, and we can now track
the error source separately.
  • Loading branch information
yuja committed Mar 28, 2024
1 parent 074e6e1 commit 916dc30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cli/tests/test_revset_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
"###);
Expand Down
7 changes: 4 additions & 3 deletions lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"#)]
Expand Down Expand Up @@ -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)
.map_err(|e| {
RevsetParseError::with_span_and_source(
RevsetParseErrorKind::FsPathParseError,
RevsetParseErrorKind::InvalidFunctionArguments {
name: name.to_owned(),
message: "Invalid file pattern".to_owned(),
},
span,
e,
)
Expand Down

0 comments on commit 916dc30

Please sign in to comment.