forked from mirrors/jj
Move resolve_destination_revs into mod.rs
It's not very general.
This commit is contained in:
parent
4183c69238
commit
db148af019
2 changed files with 24 additions and 24 deletions
|
@ -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<IndexSet<Commit>, 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<ReadonlyRepo>,
|
||||
|
|
|
@ -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<IndexSet<Commit>, 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!(
|
||||
|
|
Loading…
Reference in a new issue