From 037134147dc04ac5db56ef7d25b0261a5ec1e303 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Tue, 19 Nov 2024 17:16:52 -0600 Subject: [PATCH] cli: delete deprecated `jj checkout` command This has been deprecated for almost a year now. Signed-off-by: Austin Seipp --- CHANGELOG.md | 3 + cli/src/commands/checkout.rs | 70 ----------------- cli/src/commands/mod.rs | 4 - cli/src/config/misc.toml | 1 - cli/tests/runner.rs | 1 - cli/tests/test_checkout.rs | 115 ---------------------------- cli/tests/test_git_push.rs | 6 +- cli/tests/test_interdiff_command.rs | 8 +- 8 files changed, 10 insertions(+), 198 deletions(-) delete mode 100644 cli/src/commands/checkout.rs delete mode 100644 cli/tests/test_checkout.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 35b6234a8..08a6352ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * `jj move` has been removed. It was deprecated in 0.16.0. +* `jj checkout` and the built-in alias `jj co` have been removed. + It was deprecated in 0.14.0. + * `jj git push` no longer pushes new bookmarks by default. Use `--allow-new` to bypass this restriction. diff --git a/cli/src/commands/checkout.rs b/cli/src/commands/checkout.rs deleted file mode 100644 index 2918f20ea..000000000 --- a/cli/src/commands/checkout.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2020 The Jujutsu Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use jj_lib::object_id::ObjectId; -use tracing::instrument; - -use crate::cli_util::CommandHelper; -use crate::cli_util::RevisionArg; -use crate::command_error::CommandError; -use crate::description_util::join_message_paragraphs; -use crate::ui::Ui; - -/// Create a new, empty change and edit it in the working copy (DEPRECATED, use -/// `jj new`) -/// -/// For more information, see -/// https://martinvonz.github.io/jj/latest/working-copy/. -#[derive(clap::Args, Clone, Debug)] -pub(crate) struct CheckoutArgs { - /// The revision to update to - revision: RevisionArg, - /// Ignored (but lets you pass `-r` for consistency with other commands) - #[arg(short = 'r', hide = true)] - unused_revision: bool, - /// The change description to use - #[arg(long = "message", short, value_name = "MESSAGE")] - message_paragraphs: Vec, -} - -#[instrument(skip_all)] -pub(crate) fn cmd_checkout( - ui: &mut Ui, - command: &CommandHelper, - args: &CheckoutArgs, -) -> Result<(), CommandError> { - writeln!( - ui.warning_default(), - "`jj checkout` is deprecated; use `jj new` instead, which is equivalent" - )?; - writeln!( - ui.warning_default(), - "`jj checkout` will be removed in a future version, and this will be a hard error" - )?; - let mut workspace_command = command.workspace_helper(ui)?; - let target = workspace_command.resolve_single_rev(ui, &args.revision)?; - let mut tx = workspace_command.start_transaction(); - let commit_builder = tx - .repo_mut() - .new_commit( - command.settings(), - vec![target.id().clone()], - target.tree_id().clone(), - ) - .set_description(join_message_paragraphs(&args.message_paragraphs)); - let new_commit = commit_builder.write()?; - tx.edit(&new_commit).unwrap(); - tx.finish(ui, format!("check out commit {}", target.id().hex()))?; - Ok(()) -} diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 064ddb4ae..65a01483a 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -18,7 +18,6 @@ mod backout; #[cfg(feature = "bench")] mod bench; mod bookmark; -mod checkout; mod commit; mod config; mod debug; @@ -91,8 +90,6 @@ enum Command { Branch(bookmark::BookmarkCommand), #[command(alias = "print", hide = true)] Cat(file::show::FileShowArgs), - #[command(hide = true)] - Checkout(checkout::CheckoutArgs), // TODO: Delete `chmod` in jj 0.25+ #[command(hide = true)] Chmod(file::chmod::FileChmodArgs), @@ -204,7 +201,6 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co let cmd = renamed_cmd("cat", "file show", file::show::cmd_file_show); cmd(ui, command_helper, args) } - Command::Checkout(args) => checkout::cmd_checkout(ui, command_helper, args), Command::Chmod(args) => { let cmd = renamed_cmd("chmod", "file chmod", file::chmod::cmd_file_chmod); cmd(ui, command_helper, args) diff --git a/cli/src/config/misc.toml b/cli/src/config/misc.toml index d4f08353c..228d2ffaa 100644 --- a/cli/src/config/misc.toml +++ b/cli/src/config/misc.toml @@ -3,7 +3,6 @@ [aliases] amend = ["squash"] b = ["bookmark"] -co = ["checkout"] unamend = ["unsquash"] [diff.color-words] diff --git a/cli/tests/runner.rs b/cli/tests/runner.rs index e95b89fac..a8312038a 100644 --- a/cli/tests/runner.rs +++ b/cli/tests/runner.rs @@ -16,7 +16,6 @@ mod test_alias; mod test_backout_command; mod test_bookmark_command; mod test_builtin_aliases; -mod test_checkout; mod test_commit_command; mod test_commit_template; mod test_completion; diff --git a/cli/tests/test_checkout.rs b/cli/tests/test_checkout.rs deleted file mode 100644 index 9c64ec12f..000000000 --- a/cli/tests/test_checkout.rs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 The Jujutsu Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::path::Path; - -use crate::common::TestEnvironment; - -#[test] -fn test_checkout() { - let test_env = TestEnvironment::default(); - test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); - let repo_path = test_env.env_root().join("repo"); - - test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]); - test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "second"]); - - // Check out current commit - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["checkout", "@"]); - insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" - Warning: `jj checkout` is deprecated; use `jj new` instead, which is equivalent - Warning: `jj checkout` will be removed in a future version, and this will be a hard error - Working copy now at: zsuskuln c97da310 (empty) (no description set) - Parent commit : rlvkpnrz 9ed53a4a (empty) second - "###); - insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" - @ c97da310c66008034013412d321397242e1e43ef - ○ 9ed53a4a1becd028f9a2fe0d5275973acea7e8da second - ○ fa15625b4a986997697639dfc2844138900c79f2 first - ◆ 0000000000000000000000000000000000000000 - "###); - - // Can provide a description - test_env.jj_cmd_ok(&repo_path, &["checkout", "@--", "-m", "my message"]); - insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" - @ 6f9c4a002224fde4ebc48ce6ec03d5ffcfa64ad2 my message - │ ○ 9ed53a4a1becd028f9a2fe0d5275973acea7e8da second - ├─╯ - ○ fa15625b4a986997697639dfc2844138900c79f2 first - ◆ 0000000000000000000000000000000000000000 - "###); -} - -#[test] -fn test_checkout_not_single_rev() { - let test_env = TestEnvironment::default(); - test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); - let repo_path = test_env.env_root().join("repo"); - - test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]); - test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]); - test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]); - test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]); - test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fifth"]); - - let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "root()..@"]); - insta::assert_snapshot!(stderr, @r###" - Warning: `jj checkout` is deprecated; use `jj new` instead, which is equivalent - Warning: `jj checkout` will be removed in a future version, and this will be a hard error - Error: Revset "root()..@" resolved to more than one revision - Hint: The revset "root()..@" resolved to these revisions: - royxmykx 554d2245 (empty) (no description set) - mzvwutvl a497e2bf (empty) fifth - zsuskuln 9d7e5e99 (empty) fourth - kkmpptxz 30056b0c (empty) third - rlvkpnrz 9ed53a4a (empty) second - ... - "###); - - let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "root()..@-"]); - insta::assert_snapshot!(stderr, @r###" - Warning: `jj checkout` is deprecated; use `jj new` instead, which is equivalent - Warning: `jj checkout` will be removed in a future version, and this will be a hard error - Error: Revset "root()..@-" resolved to more than one revision - Hint: The revset "root()..@-" resolved to these revisions: - mzvwutvl a497e2bf (empty) fifth - zsuskuln 9d7e5e99 (empty) fourth - kkmpptxz 30056b0c (empty) third - rlvkpnrz 9ed53a4a (empty) second - qpvuntsm fa15625b (empty) first - "###); - - let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "@-|@--"]); - insta::assert_snapshot!(stderr, @r###" - Warning: `jj checkout` is deprecated; use `jj new` instead, which is equivalent - Warning: `jj checkout` will be removed in a future version, and this will be a hard error - Error: Revset "@-|@--" resolved to more than one revision - Hint: The revset "@-|@--" resolved to these revisions: - mzvwutvl a497e2bf (empty) fifth - zsuskuln 9d7e5e99 (empty) fourth - "###); - - let stderr = test_env.jj_cmd_failure(&repo_path, &["checkout", "none()"]); - insta::assert_snapshot!(stderr, @r###" - Warning: `jj checkout` is deprecated; use `jj new` instead, which is equivalent - Warning: `jj checkout` will be removed in a future version, and this will be a hard error - Error: Revset "none()" didn't resolve to any revisions - "###); -} - -fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { - let template = r#"commit_id ++ " " ++ description"#; - test_env.jj_cmd_success(cwd, &["log", "-T", template]) -} diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 9e83cdd12..467bdf4a8 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -976,7 +976,7 @@ fn test_git_push_missing_author() { .assert() .success(); }; - run_without_var("JJ_USER", &["checkout", "root()", "-m=initial"]); + run_without_var("JJ_USER", &["new", "root()", "-m=initial"]); run_without_var("JJ_USER", &["bookmark", "create", "missing-name"]); let stderr = test_env.jj_cmd_failure( &workspace_root, @@ -985,7 +985,7 @@ fn test_git_push_missing_author() { insta::assert_snapshot!(stderr, @r###" Error: Won't push commit 944313939bbd since it has no author and/or committer set "###); - run_without_var("JJ_EMAIL", &["checkout", "root()", "-m=initial"]); + run_without_var("JJ_EMAIL", &["new", "root()", "-m=initial"]); run_without_var("JJ_EMAIL", &["bookmark", "create", "missing-email"]); let stderr = test_env.jj_cmd_failure( &workspace_root, @@ -1065,7 +1065,7 @@ fn test_git_push_missing_committer() { insta::assert_snapshot!(stderr, @r###" Error: Won't push commit 4fd190283d1a since it has no author and/or committer set "###); - test_env.jj_cmd_ok(&workspace_root, &["checkout", "root()"]); + test_env.jj_cmd_ok(&workspace_root, &["new", "root()"]); test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "missing-email"]); run_without_var("JJ_EMAIL", &["describe", "-m=no committer email"]); let stderr = test_env.jj_cmd_failure( diff --git a/cli/tests/test_interdiff_command.rs b/cli/tests/test_interdiff_command.rs index ec0601465..5943753af 100644 --- a/cli/tests/test_interdiff_command.rs +++ b/cli/tests/test_interdiff_command.rs @@ -25,7 +25,7 @@ fn test_interdiff_basic() { std::fs::write(repo_path.join("file2"), "foo\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]); - test_env.jj_cmd_ok(&repo_path, &["checkout", "root()"]); + test_env.jj_cmd_ok(&repo_path, &["new", "root()"]); std::fs::write(repo_path.join("file3"), "foo\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["new"]); std::fs::write(repo_path.join("file2"), "foo\nbar\n").unwrap(); @@ -40,7 +40,7 @@ fn test_interdiff_basic() { "###); // explicit --to - test_env.jj_cmd_ok(&repo_path, &["checkout", "@-"]); + test_env.jj_cmd_ok(&repo_path, &["new", "@-"]); let stdout = test_env.jj_cmd_success( &repo_path, &["interdiff", "--from", "left", "--to", "right"], @@ -89,7 +89,7 @@ fn test_interdiff_paths() { std::fs::write(repo_path.join("file2"), "bar\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]); - test_env.jj_cmd_ok(&repo_path, &["checkout", "root()"]); + test_env.jj_cmd_ok(&repo_path, &["new", "root()"]); std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); std::fs::write(repo_path.join("file2"), "foo\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["new"]); @@ -137,7 +137,7 @@ fn test_interdiff_conflicting() { std::fs::write(repo_path.join("file"), "bar\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]); - test_env.jj_cmd_ok(&repo_path, &["checkout", "root()"]); + test_env.jj_cmd_ok(&repo_path, &["new", "root()"]); std::fs::write(repo_path.join("file"), "abc\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["new"]); std::fs::write(repo_path.join("file"), "def\n").unwrap();