diff --git a/src/cli_util.rs b/src/cli_util.rs index 38853bc80..a86f9bd72 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -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, )) } diff --git a/tests/test_checkout.rs b/tests/test_checkout.rs index 2a21c4973..e4f545516 100644 --- a/tests/test_checkout.rs +++ b/tests/test_checkout.rs @@ -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 "###);