diff --git a/src/cli_util.rs b/src/cli_util.rs index f1be1ba92..801394dc2 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1431,26 +1431,6 @@ pub fn resolve_mutliple_nonempty_revsets_flag_guarded( } } -/// Resolves revsets into revisions to rebase onto. These revisions don't have -/// to be rewriteable. -pub fn resolve_destination_revs( - workspace_command: &WorkspaceCommandHelper, - revisions: &[RevisionArg], - allow_plural_revsets: bool, -) -> Result, CommandError> { - let commits = resolve_mutliple_nonempty_revsets_flag_guarded( - workspace_command, - revisions, - allow_plural_revsets, - )?; - let root_commit_id = workspace_command.repo().store().root_commit_id(); - if commits.len() >= 2 && commits.iter().any(|c| c.id() == root_commit_id) { - Err(user_error("Cannot merge with root revision")) - } else { - Ok(commits) - } -} - pub fn update_working_copy( ui: &mut Ui, repo: &Arc, diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 908fab7d6..17610e490 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -45,10 +45,10 @@ use maplit::{hashmap, hashset}; use pest::Parser; use crate::cli_util::{ - self, check_stale_working_copy, print_checkout_stats, resolve_destination_revs, - resolve_multiple_nonempty_revsets, run_ui_editor, serialize_config_value, short_commit_hash, - user_error, user_error_with_hint, Args, CommandError, CommandHelper, DescriptionArg, - RevisionArg, WorkspaceCommandHelper, DESCRIPTION_PLACEHOLDER_TEMPLATE, + self, check_stale_working_copy, print_checkout_stats, resolve_multiple_nonempty_revsets, + resolve_mutliple_nonempty_revsets_flag_guarded, run_ui_editor, serialize_config_value, + short_commit_hash, user_error, user_error_with_hint, Args, CommandError, CommandHelper, + DescriptionArg, RevisionArg, WorkspaceCommandHelper, DESCRIPTION_PLACEHOLDER_TEMPLATE, }; use crate::config::{config_path, AnnotatedValue, ConfigSource}; use crate::diff_util::{self, DiffFormat, DiffFormatArgs}; @@ -1997,6 +1997,26 @@ fn cmd_edit(ui: &mut Ui, command: &CommandHelper, args: &EditArgs) -> Result<(), Ok(()) } +/// Resolves revsets into revisions to rebase onto. These revisions don't have +/// to be rewriteable. +fn resolve_destination_revs( + workspace_command: &WorkspaceCommandHelper, + revisions: &[RevisionArg], + allow_plural_revsets: bool, +) -> Result, CommandError> { + let commits = resolve_mutliple_nonempty_revsets_flag_guarded( + workspace_command, + revisions, + allow_plural_revsets, + )?; + let root_commit_id = workspace_command.repo().store().root_commit_id(); + if commits.len() >= 2 && commits.iter().any(|c| c.id() == root_commit_id) { + Err(user_error("Cannot merge with root revision")) + } else { + Ok(commits) + } +} + fn cmd_new(ui: &mut Ui, command: &CommandHelper, args: &NewArgs) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; assert!(