mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-29 07:59:00 +00:00
Move resolve_multiple_rewriteable_revsets to cli_utils.rs
This commit is contained in:
parent
8c4fa90e2e
commit
159c474e2c
2 changed files with 21 additions and 20 deletions
|
@ -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<IndexSet<Commit>, 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],
|
||||
|
|
|
@ -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<IndexSet<Commit>, 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,
|
||||
|
|
Loading…
Reference in a new issue