Skip to content

Commit

Permalink
cli: mention revsets doc on syntax error
Browse files Browse the repository at this point in the history
Maybe we can show more specific hints on certain cases, but this should be good
as a fallback. The message is copied from the FilesetParseError hint.
  • Loading branch information
yuja committed Feb 20, 2025
1 parent b1eca37 commit 6308897
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/src/command_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ fn revset_parse_error_hint(err: &RevsetParseError) -> Option<String> {
// Only for the bottom error, which is usually the root cause
let bottom_err = iter::successors(Some(err), |e| e.origin()).last().unwrap();
match bottom_err.kind() {
RevsetParseErrorKind::SyntaxError => Some(
"See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to \
quote symbols."
.into(),
),
RevsetParseErrorKind::NotPrefixOperator {
op: _,
similar_op,
Expand Down
3 changes: 3 additions & 0 deletions cli/tests/test_bookmark_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fn test_bookmark_bad_name() {
= expected <identifier>, <string_literal>, or <raw_string_literal>
For more information, try '--help'.
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");

Expand All @@ -181,6 +182,7 @@ fn test_bookmark_bad_name() {
= expected <identifier>, <string_literal>, or <raw_string_literal>
For more information, try '--help'.
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");

Expand All @@ -195,6 +197,7 @@ fn test_bookmark_bad_name() {
= expected <identifier>, <string_literal>, or <raw_string_literal>
For more information, try '--help'.
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");

Expand Down
4 changes: 4 additions & 0 deletions cli/tests/test_revset_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn test_syntax_error() {
| ^---
|
= expected `::`, `..`, `~`, or <primary>
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");

Expand Down Expand Up @@ -292,6 +293,7 @@ fn test_bad_function_call() {
| ^---
|
= expected <strict_identifier> or <expression>
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");

Expand All @@ -304,6 +306,7 @@ fn test_bad_function_call() {
| ^---
|
= expected <expression>
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");
}
Expand Down Expand Up @@ -481,6 +484,7 @@ fn test_alias() {
| ^---
|
= expected `::`, `..`, `~`, or <primary>
Hint: See https://jj-vcs.github.io/jj/latest/revsets/ for revsets syntax, or for how to quote symbols.
[EOF]
");

Expand Down

0 comments on commit 6308897

Please sign in to comment.