From 9c55d9884272cfa6d77a2ec329e33645fe1ed6dc Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 18 Jun 2022 20:22:54 -0700 Subject: [PATCH] cli: rename `jj edit` to `jj touchup` --- CHANGELOG.md | 2 ++ README.md | 2 +- docs/git-comparison.md | 2 +- docs/tutorial.md | 8 ++++---- src/commands.rs | 16 ++++++++++------ tests/test_global_opts.rs | 10 +++++----- ...t_edit_command.rs => test_touchup_command.rs} | 10 +++++----- 7 files changed, 28 insertions(+), 22 deletions(-) rename tests/{test_edit_command.rs => test_touchup_command.rs} (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7c384b3d..e178f752d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * The [`$NO_COLOR` environment variable](https://no-color.org/) no longer overrides the `ui.color` configuration if explicitly set. +* `jj edit` has been renamed to `jj touchup`. + * `jj git push` no longer aborts if you attempt to push an open commit (but it now aborts if a commit does not have a description). diff --git a/README.md b/README.md index bb959b363..1d4edff94 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ updated. So will the working copy if it points to a rebased commit. ### Comprehensive support for rewriting history Besides the usual rebase command, there's `jj describe` for editing the -description (commit message) of an arbitrary commit. There's also `jj edit`, +description (commit message) of an arbitrary commit. There's also `jj touchup`, 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`. diff --git a/docs/git-comparison.md b/docs/git-comparison.md index b0ef9f2f7..f04483e0b 100644 --- a/docs/git-comparison.md +++ b/docs/git-comparison.md @@ -240,7 +240,7 @@ parent. Interactively edit the diff in a given change - jj edit -r <revision> + jj touchup -r <revision> Not supported (can be emulated with the "edit" action in git rebase -i) diff --git a/docs/tutorial.md b/docs/tutorial.md index 4ab72cbc3..dadd8d151 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -386,10 +386,10 @@ the parent change, even if they touch the same word, and it won't cause any conflicts. Let's try one final command for changing the contents of an exiting commit. That -command is `jj edit`, which lets you edit the contents of a commit without +command is `jj touchup`, which lets you edit the contents of a commit without checking it out. ```shell script -$ jj edit -r @-- +$ jj touchup -r @-- Created 2423c134ea70 ABC Rebased 2 descendant commits Working copy now at: d31c52e8ca41 (no description set) @@ -399,10 +399,10 @@ When Meld starts, edit the right side by e.g. adding something to the first line. Then close Meld. You can now inspect the rewritten commit with `jj diff -r @--` again and you should see your addition to the first line. Unlike `jj squash -i`, which left the content state of the commit unchanged, -`jj edit` (typically) results in a different state, which means that descendant +`jj touchup` (typically) results in a different state, which means that descendant commits may have conflicts. Other commands for rewriting contents of existing commits are `jj restore -i`, `jj split`, `jj unsquash -i`. Now that you've seen how `jj squash -i` and -`jj edit` work, you can hopefully figure out how those work (with the help of +`jj touchup` work, you can hopefully figure out how those work (with the help of the instructions in the diff). diff --git a/src/commands.rs b/src/commands.rs index 0ffd2e1c3..cfe06afc0 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1132,7 +1132,7 @@ enum Commands { Squash(SquashArgs), Unsquash(UnsquashArgs), Restore(RestoreArgs), - Edit(EditArgs), + Touchup(TouchupArgs), Split(SplitArgs), Merge(MergeArgs), Rebase(RebaseArgs), @@ -1513,7 +1513,7 @@ struct RestoreArgs { paths: Vec, } -/// Edit the content changes in a revision +/// Touch up the content changes in a revision /// /// Starts a diff editor (`meld` by default) on the changes in the revision. /// Edit the right side of the diff until it looks the way you want. Once you @@ -1522,8 +1522,8 @@ struct RestoreArgs { /// unsquash -i` if you instead want to move changes into or out of the parent /// revision. #[derive(clap::Args, Clone, Debug)] -struct EditArgs { - /// The revision to edit +struct TouchupArgs { + /// The revision to touch up #[clap(long, short, default_value = "@")] revision: String, } @@ -3731,7 +3731,11 @@ side. If you don't make any changes, then the operation will be aborted. Ok(()) } -fn cmd_edit(ui: &mut Ui, command: &CommandHelper, args: &EditArgs) -> Result<(), CommandError> { +fn cmd_touchup( + ui: &mut Ui, + command: &CommandHelper, + args: &TouchupArgs, +) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; workspace_command.check_rewriteable(&commit)?; @@ -5278,7 +5282,7 @@ where Commands::Squash(sub_args) => cmd_squash(ui, &command_helper, sub_args), Commands::Unsquash(sub_args) => cmd_unsquash(ui, &command_helper, sub_args), Commands::Restore(sub_args) => cmd_restore(ui, &command_helper, sub_args), - Commands::Edit(sub_args) => cmd_edit(ui, &command_helper, sub_args), + Commands::Touchup(sub_args) => cmd_touchup(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::Rebase(sub_args) => cmd_rebase(ui, &command_helper, sub_args), diff --git a/tests/test_global_opts.rs b/tests/test_global_opts.rs index 215b06ab1..43ab05371 100644 --- a/tests/test_global_opts.rs +++ b/tests/test_global_opts.rs @@ -149,16 +149,16 @@ fn test_help() { // Test that global options are separated out in the help output let test_env = TestEnvironment::default(); - let stdout = test_env.jj_cmd_success(test_env.env_root(), &["edit", "-h"]); + let stdout = test_env.jj_cmd_success(test_env.env_root(), &["touchup", "-h"]); insta::assert_snapshot!(stdout.replace(".exe", ""), @r###" - jj-edit - Edit the content changes in a revision + jj-touchup + Touch up the content changes in a revision USAGE: - jj edit [OPTIONS] + jj touchup [OPTIONS] OPTIONS: - -r, --revision The revision to edit [default: @] + -r, --revision The revision to touch up [default: @] GLOBAL OPTIONS: --at-operation Operation to load the repo at [default: @] [aliases: at-op] diff --git a/tests/test_edit_command.rs b/tests/test_touchup_command.rs similarity index 93% rename from tests/test_edit_command.rs rename to tests/test_touchup_command.rs index d5a57df41..68762eb13 100644 --- a/tests/test_edit_command.rs +++ b/tests/test_touchup_command.rs @@ -37,7 +37,7 @@ fn test_edit() { "files-before file1 file2\0files-after JJ-INSTRUCTIONS file2", ) .unwrap(); - let stdout = test_env.jj_cmd_success(&repo_path, &["edit"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["touchup"]); insta::assert_snapshot!(stdout, @r###" Nothing changed. "###); @@ -49,7 +49,7 @@ fn test_edit() { // Nothing happens if the diff-editor exits with an error std::fs::write(&edit_script, "rm file2\0fail").unwrap(); - let stderr = test_env.jj_cmd_failure(&repo_path, &["edit"]); + let stderr = test_env.jj_cmd_failure(&repo_path, &["touchup"]); insta::assert_snapshot!(stderr, @r###" Error: Failed to edit diff: The diff tool exited with a non-zero code "###); @@ -61,7 +61,7 @@ fn test_edit() { // Can edit changes to individual files std::fs::write(&edit_script, "reset file2").unwrap(); - let stdout = test_env.jj_cmd_success(&repo_path, &["edit"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["touchup"]); insta::assert_snapshot!(stdout, @r###" Created 8c79910b5033 (no description set) Working copy now at: 8c79910b5033 (no description set) @@ -75,7 +75,7 @@ fn test_edit() { // Changes to a commit are propagated to descendants test_env.jj_cmd_success(&repo_path, &["undo"]); std::fs::write(&edit_script, "write file3\nmodified\n").unwrap(); - let stdout = test_env.jj_cmd_success(&repo_path, &["edit", "-r", "@-"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["touchup", "-r", "@-"]); insta::assert_snapshot!(stdout, @r###" Created 472de2debaff (no description set) Rebased 1 descendant commits @@ -126,7 +126,7 @@ fn test_edit_merge() { "files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1", ) .unwrap(); - let stdout = test_env.jj_cmd_success(&repo_path, &["edit", "-r", "@-"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["touchup", "-r", "@-"]); insta::assert_snapshot!(stdout, @r###" Created 608f32ad9e19 merge Rebased 1 descendant commits