mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 07:14:38 +00:00
cli: Include revset in hint for resolve_single_rev
The revset is already printed in the error message, but it's easy to miss since the error message is in different color.
This commit is contained in:
parent
5fb17925eb
commit
8c1a5539ad
2 changed files with 7 additions and 6 deletions
|
@ -738,14 +738,15 @@ impl WorkspaceCommandHelper {
|
|||
match (iter.next(), iter.next()) {
|
||||
(Some(commit), None) => Ok(commit?),
|
||||
(None, _) => Err(user_error(format!(
|
||||
"Revset \"{revision_str}\" didn't resolve to any revisions"
|
||||
r#"Revset "{revision_str}" didn't resolve to any revisions"#
|
||||
))),
|
||||
(Some(commit0), Some(commit1)) => {
|
||||
let mut iter = [commit0, commit1].into_iter().chain(iter);
|
||||
let commits: Vec<_> = iter.by_ref().take(5).try_collect()?;
|
||||
let elided = iter.next().is_some();
|
||||
let hint = format!(
|
||||
"The revset resolved to these revisions:\n{commits}{ellipsis}",
|
||||
r#"The revset "{revision_str}" resolved to these revisions:{eol}{commits}{ellipsis}"#,
|
||||
eol = "\n",
|
||||
commits = commits
|
||||
.iter()
|
||||
.map(|c| self.format_commit_summary(c))
|
||||
|
@ -753,7 +754,7 @@ impl WorkspaceCommandHelper {
|
|||
ellipsis = elided.then(|| "\n...").unwrap_or_default()
|
||||
);
|
||||
Err(user_error_with_hint(
|
||||
format!("Revset \"{revision_str}\" resolved to more than one revision"),
|
||||
format!(r#"Revset "{revision_str}" resolved to more than one revision"#),
|
||||
hint,
|
||||
))
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ fn test_checkout_not_single_rev() {
|
|||
let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "root..@"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: Revset "root..@" resolved to more than one revision
|
||||
Hint: The revset resolved to these revisions:
|
||||
Hint: The revset "root..@" resolved to these revisions:
|
||||
2f8593712db5 (no description set)
|
||||
5c1afd8b074f fifth
|
||||
009f88bf7141 fourth
|
||||
|
@ -77,7 +77,7 @@ fn test_checkout_not_single_rev() {
|
|||
let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "root..@-"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: Revset "root..@-" resolved to more than one revision
|
||||
Hint: The revset resolved to these revisions:
|
||||
Hint: The revset "root..@-" resolved to these revisions:
|
||||
5c1afd8b074f fifth
|
||||
009f88bf7141 fourth
|
||||
3fa8931e7b89 third
|
||||
|
@ -88,7 +88,7 @@ fn test_checkout_not_single_rev() {
|
|||
let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "@-|@--"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: Revset "@-|@--" resolved to more than one revision
|
||||
Hint: The revset resolved to these revisions:
|
||||
Hint: The revset "@-|@--" resolved to these revisions:
|
||||
5c1afd8b074f fifth
|
||||
009f88bf7141 fourth
|
||||
"###);
|
||||
|
|
Loading…
Reference in a new issue