Skip to content

Commit

Permalink
restore: add --into flag, make --to an alias to it
Browse files Browse the repository at this point in the history
This is a part of jj-vcs#5394.
  • Loading branch information
v-gb committed Jan 19, 2025
1 parent c621a13 commit 7888363
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
can be customized using `format_detailed_cryptographic_signature(signature)` and
`format_short_cryptographic_signature(signature)`.

* Added `--into` flag to `jj restore`, similarly to `jj squash` and `jj absorb`. It is
equivalent to `--to`, but `--into` is the recommended name.

### Fixed bugs

* Fixed diff selection by external tools with `jj split`/`commit -i FILESETS`.
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub(crate) fn cmd_restore(
return Err(user_error(
"`jj restore` does not have a `--revision`/`-r` option. If you'd like to modify\nthe \
*current* revision, use `--from`. If you'd like to modify a *different* \
revision,\nuse `--to` or `--changes-in`.",
revision,\nuse `--into` or `--changes-in`.",
));
}
if args.from.is_some() || args.into.is_some() {
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/test_restore_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn test_restore() {
insta::assert_snapshot!(stderr, @r###"
Error: `jj restore` does not have a `--revision`/`-r` option. If you'd like to modify
the *current* revision, use `--from`. If you'd like to modify a *different* revision,
use `--to` or `--changes-in`.
use `--into` or `--changes-in`.
"###);

// Restores from parent by default
Expand Down Expand Up @@ -94,7 +94,7 @@ fn test_restore() {

// Can restore into other revision
test_env.jj_cmd_ok(&repo_path, &["undo"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["restore", "--to", "@-"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["restore", "--into", "@-"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Created rlvkpnrz ad805965 (no description set)
Expand All @@ -111,10 +111,10 @@ fn test_restore() {
A file3
"###);

// Can combine `--from` and `--to`
// Can combine `--from` and `--into`
test_env.jj_cmd_ok(&repo_path, &["undo"]);
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["restore", "--from", "@", "--to", "@-"]);
test_env.jj_cmd_ok(&repo_path, &["restore", "--from", "@", "--into", "@-"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Created rlvkpnrz f256040a (no description set)
Expand Down

0 comments on commit 7888363

Please sign in to comment.