mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-27 06:23:18 +00:00
Mention --allow-large-revsets in hint when one revset resolves to multiple revisions
This commit is contained in:
parent
db148af019
commit
9cc536e9e0
2 changed files with 22 additions and 1 deletions
|
@ -1419,7 +1419,9 @@ pub fn resolve_mutliple_nonempty_revsets_flag_guarded(
|
|||
} else {
|
||||
let mut commits = IndexSet::new();
|
||||
for revision_str in revisions {
|
||||
let commit = workspace_command.resolve_single_rev(revision_str)?;
|
||||
let commit = workspace_command
|
||||
.resolve_single_rev(revision_str)
|
||||
.map_err(append_large_revsets_hint_if_multiple_revisions)?;
|
||||
let commit_hash = short_commit_hash(commit.id());
|
||||
if !commits.insert(commit) {
|
||||
return Err(user_error(format!(
|
||||
|
@ -1431,6 +1433,24 @@ pub fn resolve_mutliple_nonempty_revsets_flag_guarded(
|
|||
}
|
||||
}
|
||||
|
||||
fn append_large_revsets_hint_if_multiple_revisions(err: CommandError) -> CommandError {
|
||||
match err {
|
||||
CommandError::UserError { message, hint } if message.contains("more than one revision") => {
|
||||
CommandError::UserError {
|
||||
message,
|
||||
hint: {
|
||||
Some(format!(
|
||||
"{old_hint}If this was intentional, specify the `--allow-large-revsets` \
|
||||
argument",
|
||||
old_hint = hint.map(|h| format!("{h}\n")).unwrap_or_default()
|
||||
))
|
||||
},
|
||||
}
|
||||
}
|
||||
_ => err,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_working_copy(
|
||||
ui: &mut Ui,
|
||||
repo: &Arc<ReadonlyRepo>,
|
||||
|
|
|
@ -320,6 +320,7 @@ fn test_rebase_multiple_destinations() {
|
|||
Hint: The revset "b|c" resolved to these revisions:
|
||||
fe2e8e8b50b3 c
|
||||
d370aee184ba b
|
||||
If this was intentional, specify the `--allow-large-revsets` argument
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
|
|
Loading…
Reference in a new issue