diff --git a/CHANGELOG.md b/CHANGELOG.md index 65577f2457..1246887fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 **Deadline**: `jj checkout` will be deleted and become a **hard error in version 0.18.0**. +* `jj merge` is now deprecated; use `jj new` instead. + + **Rationale**: `jj merge` is functionally equivalent to `jj new`, except it + requires *at least* two arguments. `jj new` can create a new commit with any + number of parents; whether that is 1 parent — a single commit — or + 2, or 3 parents, which would represent various merges. `jj merge` is a + specialization of existing functionality; it only creates "merge commits", but + only because "merge commit" is defined as "has at least two parents." + + This makes `jj merge` functionally redundant, and also obscures the relative + generality of the `jj new` command, which can create a commit from any number + of parents. We encourage all users to adopt `jj new` for performing merges + instead; it is shorter, more general, and easier to remember. + + `jj merge` will no longer be shown as part of `jj help`, but will still + function for now, emitting a warning about its deprecation. + + **Deadline**: `jj merge` will be deleted and become a **hard error in + version 0.18.0**. + ### Breaking changes ### New features diff --git a/cli/src/commands/merge.rs b/cli/src/commands/merge.rs index fea077e2f8..66805aff67 100644 --- a/cli/src/commands/merge.rs +++ b/cli/src/commands/merge.rs @@ -24,6 +24,14 @@ pub(crate) fn cmd_merge( command: &CommandHelper, args: &new::NewArgs, ) -> Result<(), CommandError> { + writeln!( + ui.warning(), + "warning: `jj merge` is deprecated; use `jj new` instead, which is equivalent" + )?; + writeln!( + ui.warning(), + "warning: `jj merge` will be removed in jj 0.18, and this will be a hard error" + )?; if args.revisions.len() < 2 { return Err(CommandError::CliError(String::from( "Merge requires at least two revisions", diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 60b9a99d3d..2cd255ca36 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -102,6 +102,7 @@ enum Command { /// /// This is the same as `jj new`, except that it requires at least two /// arguments. + #[command(hide = true)] Merge(new::NewArgs), Move(r#move::MoveArgs), New(new::NewArgs), diff --git a/cli/tests/test_new_command.rs b/cli/tests/test_new_command.rs index 5a8f6b3344..9edd10ec12 100644 --- a/cli/tests/test_new_command.rs +++ b/cli/tests/test_new_command.rs @@ -123,10 +123,14 @@ fn test_new_merge() { // `jj merge` with less than two arguments is an error let stderr = test_env.jj_cmd_cli_error(&repo_path, &["merge"]); insta::assert_snapshot!(stderr, @r###" + warning: `jj merge` is deprecated; use `jj new` instead, which is equivalent + warning: `jj merge` will be removed in jj 0.18, and this will be a hard error Error: Merge requires at least two revisions "###); let stderr = test_env.jj_cmd_cli_error(&repo_path, &["merge", "main"]); insta::assert_snapshot!(stderr, @r###" + warning: `jj merge` is deprecated; use `jj new` instead, which is equivalent + warning: `jj merge` will be removed in jj 0.18, and this will be a hard error Error: Merge requires at least two revisions "###);