diff --git a/src/cli_util.rs b/src/cli_util.rs index a86f9bd72..38a824dc4 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -26,6 +26,7 @@ use std::sync::Arc; use clap::builder::{NonEmptyStringValueParser, TypedValueParser, ValueParserFactory}; use clap::{Arg, ArgAction, ArgMatches, Command, FromArgMatches}; use git2::{Oid, Repository}; +use indexmap::IndexSet; use itertools::Itertools; use jujutsu_lib::backend::{BackendError, ChangeId, CommitId, ObjectId, TreeId}; use jujutsu_lib::commit::Commit; @@ -1395,6 +1396,22 @@ fn load_revset_aliases( Ok(aliases_map) } +pub fn resolve_multiple_rewritable_revsets( + revision_args: &[RevisionArg], + workspace_command: &WorkspaceCommandHelper, +) -> Result, CommandError> { + let mut acc = IndexSet::new(); + for revset in revision_args { + let revisions = workspace_command.resolve_revset(revset)?; + workspace_command.check_non_empty(&revisions)?; + for commit in &revisions { + workspace_command.check_rewritable(commit)?; + } + acc.extend(revisions); + } + Ok(acc) +} + pub fn resolve_base_revs( workspace_command: &WorkspaceCommandHelper, revisions: &[RevisionArg], diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 5e029c286..8d75c50ee 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_base_revs, 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_base_revs, + resolve_multiple_rewritable_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, }; use crate::config::{config_path, AnnotatedValue, ConfigSource}; use crate::diff_util::{self, DiffFormat, DiffFormatArgs}; @@ -1863,22 +1863,6 @@ fn cmd_commit(ui: &mut Ui, command: &CommandHelper, args: &CommitArgs) -> Result Ok(()) } -fn resolve_multiple_rewritable_revsets( - revision_args: &[RevisionArg], - workspace_command: &WorkspaceCommandHelper, -) -> Result, CommandError> { - let mut acc = IndexSet::new(); - for revset in revision_args { - let revisions = workspace_command.resolve_revset(revset)?; - workspace_command.check_non_empty(&revisions)?; - for commit in &revisions { - workspace_command.check_rewritable(commit)?; - } - acc.extend(revisions); - } - Ok(acc) -} - fn cmd_duplicate( ui: &mut Ui, command: &CommandHelper,