mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-24 06:19:42 +00:00
cli: delete deprecated jj checkout
command
This has been deprecated for almost a year now. Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
parent
ec30979e0e
commit
037134147d
8 changed files with 10 additions and 198 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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<String>,
|
||||
}
|
||||
|
||||
#[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(())
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
[aliases]
|
||||
amend = ["squash"]
|
||||
b = ["bookmark"]
|
||||
co = ["checkout"]
|
||||
unamend = ["unsquash"]
|
||||
|
||||
[diff.color-words]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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])
|
||||
}
|
|
@ -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(
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue