Skip to content

Commit

Permalink
move: deprecate the command
Browse files Browse the repository at this point in the history
Per discussion in
#2882. `jj squash` now has
all the functionality.
  • Loading branch information
martinvonz committed Mar 11, 2024
1 parent 10c1845 commit e97c7a4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions cli/src/commands/move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("@"))?;
Expand Down
4 changes: 4 additions & 0 deletions cli/tests/test_immutable_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
"###);
Expand Down
18 changes: 18 additions & 0 deletions cli/tests/test_move_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ 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.
"###);

// Can move from sibling, which results in the source being abandoned
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
Expand Down Expand Up @@ -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)
"###);
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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###"
Expand Down Expand Up @@ -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)
"###);
Expand Down
5 changes: 2 additions & 3 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
6 changes: 3 additions & 3 deletions docs/git-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ parent.
</tr>
<tr>
<td>Abandon the parent of the working copy, but keep its diff in the working copy</td>
<td><code>jj move --from @-</code></td>
<td><code>jj squash --from @-</code></td>
<td><code>git reset --soft HEAD~</code></td>
</tr>
<tr>
Expand Down Expand Up @@ -275,13 +275,13 @@ parent.
</tr>
<tr>
<td>Move the diff in the working copy into an ancestor</td>
<td><code>jj move --to X</code></td>
<td><code>jj squash --into X</code></td>
<td><code>git commit --fixup=X; git rebase -i --autosquash X^</code></td>
</tr>
<tr>
<td>Interactively move part of the diff in an arbitrary change to another
arbitrary change</td>
<td><code>jj move -i --from X --to Y</code></td>
<td><code>jj squash -i --from X --into Y</code></td>
<td>Not supported</td>
</tr>
<tr>
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit e97c7a4

Please sign in to comment.