From e9655dba13a8069635c3b83310fcb375b68e9ac2 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 10 Mar 2024 21:24:13 -0700 Subject: [PATCH] move: deprecate the command Per discussion in https://github.com/martinvonz/jj/discussions/2882. `jj squash` now has all the functionality. --- CHANGELOG.md | 2 ++ README.md | 2 +- cli/src/commands/move.rs | 8 ++++++++ cli/tests/test_immutable_commits.rs | 4 ++++ cli/tests/test_move_command.rs | 18 ++++++++++++++++++ docs/FAQ.md | 5 ++--- docs/git-comparison.md | 6 +++--- docs/tutorial.md | 6 +++--- 8 files changed, 41 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9b98d187..71b8f9348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecations +* `jj move` was deprecated in favor of `jj squash`. + ### Breaking changes ### New features diff --git a/README.md b/README.md index 4a7526a70..a8356eb7a 100644 --- a/README.md +++ b/README.md @@ -276,7 +276,7 @@ Besides the usual rebase command, there's `jj describe` for editing the description (commit message) of an arbitrary commit. There's also `jj diffedit`, which lets you edit the changes in a commit without checking it out. To split a commit into two, use `jj split`. You can even move part of the changes in a -commit to any other commit using `jj move`. +commit to any other commit using `jj squash -i --from X --into Y`. ## Status diff --git a/cli/src/commands/move.rs b/cli/src/commands/move.rs index ef9980950..8b2f892dc 100644 --- a/cli/src/commands/move.rs +++ b/cli/src/commands/move.rs @@ -62,6 +62,14 @@ pub(crate) fn cmd_move( command: &CommandHelper, args: &MoveArgs, ) -> Result<(), CommandError> { + writeln!( + ui.warning(), + "warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent" + )?; + writeln!( + ui.warning(), + "warning: `jj move` will be removed in a future version, and this will be a hard error" + )?; let mut workspace_command = command.workspace_helper(ui)?; let source = workspace_command.resolve_single_rev(args.from.as_deref().unwrap_or("@"))?; let destination = workspace_command.resolve_single_rev(args.to.as_deref().unwrap_or("@"))?; diff --git a/cli/tests/test_immutable_commits.rs b/cli/tests/test_immutable_commits.rs index e3193fb7f..610e65011 100644 --- a/cli/tests/test_immutable_commits.rs +++ b/cli/tests/test_immutable_commits.rs @@ -143,12 +143,16 @@ fn test_rewrite_immutable_commands() { // move --from let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--from=main"]); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Error: Commit 3d14df18607e is immutable Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`. "###); // move --to let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to=main"]); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Error: Commit 3d14df18607e is immutable Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`. "###); diff --git a/cli/tests/test_move_command.rs b/cli/tests/test_move_command.rs index 24a635658..d30212576 100644 --- a/cli/tests/test_move_command.rs +++ b/cli/tests/test_move_command.rs @@ -78,6 +78,8 @@ fn test_move() { // Errors out if source and destination are the same let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to", "@"]); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Error: Source and destination cannot be the same. "###); @@ -85,6 +87,8 @@ fn test_move() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "--from", "c"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Working copy now at: kmkuslsw 1c03e3d3 f | (no description set) Parent commit : znkkpsqq e9515f21 e | (no description set) Added 0 files, modified 1 files, removed 0 files @@ -114,6 +118,8 @@ fn test_move() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "--from", "@--"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Working copy now at: kmkuslsw c8d83075 f | (no description set) Parent commit : znkkpsqq 2c50bfc5 e | (no description set) "###); @@ -140,6 +146,8 @@ fn test_move() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "--from", "e", "--to", "d"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Rebased 1 descendant commits Working copy now at: kmkuslsw 2b723b1d f | (no description set) Parent commit : vruxwmqv 4293930d d e | (no description set) @@ -205,6 +213,8 @@ fn test_move_partial() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "-i", "--from", "c"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Working copy now at: vruxwmqv 71b69e43 d | (no description set) Parent commit : qpvuntsm 3db0a2f5 a | (no description set) Added 0 files, modified 2 files, removed 0 files @@ -237,6 +247,8 @@ fn test_move_partial() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "-i", "--from", "c"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Working copy now at: vruxwmqv 63f1a6e9 d | (no description set) Parent commit : qpvuntsm 3db0a2f5 a | (no description set) Added 0 files, modified 1 files, removed 0 files @@ -272,6 +284,8 @@ fn test_move_partial() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "--from", "c", "file1"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Working copy now at: vruxwmqv 17c2e663 d | (no description set) Parent commit : qpvuntsm 3db0a2f5 a | (no description set) Added 0 files, modified 1 files, removed 0 files @@ -308,6 +322,8 @@ fn test_move_partial() { test_env.jj_cmd_ok(&repo_path, &["move", "--from", "c", "--to", "b", "file1"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Rebased 1 descendant commits "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @@ -335,6 +351,8 @@ fn test_move_partial() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["move", "--from", "c", "nonexistent"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + warning: `jj move` is deprecated; use `jj squash` instead, which is equivalent + warning: `jj move` will be removed in a future version, and this will be a hard error Working copy now at: vruxwmqv b670567d d | (no description set) Parent commit : qpvuntsm 3db0a2f5 a | (no description set) "###); diff --git a/docs/FAQ.md b/docs/FAQ.md index 0315c701b..2b5ee1a01 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -122,9 +122,8 @@ try `jj rebase -s all:commit_with_local_changes+ -d main` An alternative workflow would be to rebase the commit with local changes on top of the PR you're working on and then do `jj new commit_with_local_changes`. -You'll then need to use `jj new --before` to create new commits -and `jj move --to` -to move new changes into the correct commits. +You'll then need to use `jj new --before` to create new commits and +`jj squash --into` to move new changes into the correct commits. ### I accidentally changed files in the wrong commit, how do I move the recent changes into another commit? diff --git a/docs/git-comparison.md b/docs/git-comparison.md index 9e5b53516..09e6f9beb 100644 --- a/docs/git-comparison.md +++ b/docs/git-comparison.md @@ -212,7 +212,7 @@ parent. Abandon the parent of the working copy, but keep its diff in the working copy - jj move --from @- + jj squash --from @- git reset --soft HEAD~ @@ -275,13 +275,13 @@ parent. Move the diff in the working copy into an ancestor - jj move --to X + jj squash --into X git commit --fixup=X; git rebase -i --autosquash X^ Interactively move part of the diff in an arbitrary change to another arbitrary change - jj move -i --from X --to Y + jj squash -i --from X --into Y Not supported diff --git a/docs/tutorial.md b/docs/tutorial.md index 87daec06e..2833f21ca 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -486,6 +486,6 @@ unchanged, `jj diffedit` (typically) results in a different state, which means that descendant commits may have conflicts. Other commands for rewriting contents of existing commits are `jj split`, `jj -unsquash -i` and `jj move -i`. Now that you've seen how `jj squash -i` and `jj -diffedit` work, you can hopefully figure out how those work (with the help of -the instructions in the diff). +unsquash -i`. Now that you've seen how `jj squash -i` and `jj diffedit` work, +you can hopefully figure out how those work (with the help of the instructions +in the diff).