Skip to content

Commit

Permalink
commands: move merge code to merge.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineCezar committed Oct 29, 2023
1 parent 92739eb commit 19a658e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
33 changes: 33 additions & 0 deletions cli/src/commands/merge.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2020 The Jujutsu Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use tracing::instrument;

use super::new;
use crate::cli_util::{CommandError, CommandHelper};
use crate::ui::Ui;

#[instrument(skip_all)]
pub(crate) fn cmd_merge(
ui: &mut Ui,
command: &CommandHelper,
args: &new::NewArgs,
) -> Result<(), CommandError> {
if args.revisions.len() < 2 {
return Err(CommandError::CliError(String::from(
"Merge requires at least two revisions",
)));
}
new::cmd_new(ui, command, args)
}
17 changes: 2 additions & 15 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mod git;
mod init;
mod interdiff;
mod log;
mod merge;
mod r#move;
mod new;
mod operation;
Expand Down Expand Up @@ -1898,20 +1899,6 @@ don't make any changes, then the operation will be aborted.
Ok(())
}

#[instrument(skip_all)]
fn cmd_merge(
ui: &mut Ui,
command: &CommandHelper,
args: &new::NewArgs,
) -> Result<(), CommandError> {
if args.revisions.len() < 2 {
return Err(CommandError::CliError(String::from(
"Merge requires at least two revisions",
)));
}
new::cmd_new(ui, command, args)
}

// TODO: Move to run.rs
fn cmd_run(_ui: &mut Ui, _command: &CommandHelper, _args: &RunArgs) -> Result<(), CommandError> {
Err(user_error("This is a stub, do not use"))
Expand Down Expand Up @@ -2517,7 +2504,7 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co
Commands::Run(sub_args) => cmd_run(ui, command_helper, sub_args),
Commands::Diffedit(sub_args) => diffedit::cmd_diffedit(ui, command_helper, sub_args),
Commands::Split(sub_args) => cmd_split(ui, command_helper, sub_args),
Commands::Merge(sub_args) => cmd_merge(ui, command_helper, sub_args),
Commands::Merge(sub_args) => merge::cmd_merge(ui, command_helper, sub_args),
Commands::Rebase(sub_args) => cmd_rebase(ui, command_helper, sub_args),
Commands::Backout(sub_args) => backout::cmd_backout(ui, command_helper, sub_args),
Commands::Resolve(sub_args) => cmd_resolve(ui, command_helper, sub_args),
Expand Down

0 comments on commit 19a658e

Please sign in to comment.