diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a9021ced3..6ba57676e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `jj split --siblings` is deprecated in favor of `jj split --parallel` (to match `jj parallelize`). +* `jj file print` (aka `jj file cat`) replaces `jj cat`. + +* `jj file chmod` replaces `jj chmod`. + ### New features * Support background filesystem monitoring via watchman triggers enabled with @@ -44,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Conflicted files are individually simplified before being materialized. +* `jj file` now groups commands for working with files. + ### Fixed bugs ## [0.18.0] - 2024-06-05 diff --git a/cli/src/commands/chmod.rs b/cli/src/commands/file/chmod.rs similarity index 90% rename from cli/src/commands/chmod.rs rename to cli/src/commands/file/chmod.rs index 1bc29aa05c..77c97d9bc8 100644 --- a/cli/src/commands/chmod.rs +++ b/cli/src/commands/file/chmod.rs @@ -47,6 +47,23 @@ pub(crate) struct ChmodArgs { paths: Vec, } +#[instrument(skip_all)] +pub(crate) fn deprecated_cmd_chmod( + ui: &mut Ui, + command: &CommandHelper, + args: &ChmodArgs, +) -> Result<(), CommandError> { + writeln!( + ui.warning_default(), + "`jj chmod` is deprecated; use `jj file chmod` instead, which is equivalent" + )?; + writeln!( + ui.warning_default(), + "`jj chmod` will be removed in a future version, and this will be a hard error" + )?; + cmd_chmod(ui, command, args) +} + #[instrument(skip_all)] pub(crate) fn cmd_chmod( ui: &mut Ui, diff --git a/cli/src/commands/file/mod.rs b/cli/src/commands/file/mod.rs new file mode 100644 index 0000000000..db55145afd --- /dev/null +++ b/cli/src/commands/file/mod.rs @@ -0,0 +1,38 @@ +// Copyright 2020-2023 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. + +pub mod chmod; +pub mod print; + +use crate::cli_util::CommandHelper; +use crate::command_error::CommandError; +use crate::ui::Ui; + +/// File operations. +#[derive(clap::Subcommand, Clone, Debug)] +pub enum FileCommand { + Print(print::PrintArgs), + Chmod(chmod::ChmodArgs), +} + +pub fn cmd_file( + ui: &mut Ui, + command: &CommandHelper, + subcommand: &FileCommand, +) -> Result<(), CommandError> { + match subcommand { + FileCommand::Print(sub_args) => print::cmd_print(ui, command, sub_args), + FileCommand::Chmod(sub_args) => chmod::cmd_chmod(ui, command, sub_args), + } +} diff --git a/cli/src/commands/cat.rs b/cli/src/commands/file/print.rs similarity index 90% rename from cli/src/commands/cat.rs rename to cli/src/commands/file/print.rs index 8e5d8a4acd..eccf4e3c09 100644 --- a/cli/src/commands/cat.rs +++ b/cli/src/commands/file/print.rs @@ -34,7 +34,7 @@ use crate::ui::Ui; /// If the given path is a directory, files in the directory will be visited /// recursively. #[derive(clap::Args, Clone, Debug)] -pub(crate) struct CatArgs { +pub(crate) struct PrintArgs { /// The revision to get the file contents from #[arg(long, short, default_value = "@")] revision: RevisionArg, @@ -44,10 +44,27 @@ pub(crate) struct CatArgs { } #[instrument(skip_all)] -pub(crate) fn cmd_cat( +pub(crate) fn deprecated_cmd_cat( ui: &mut Ui, command: &CommandHelper, - args: &CatArgs, + args: &PrintArgs, +) -> Result<(), CommandError> { + writeln!( + ui.warning_default(), + "`jj cat` is deprecated; use `jj file print` instead, which is equivalent" + )?; + writeln!( + ui.warning_default(), + "`jj cat` will be removed in a future version, and this will be a hard error" + )?; + cmd_print(ui, command, args) +} + +#[instrument(skip_all)] +pub(crate) fn cmd_print( + ui: &mut Ui, + command: &CommandHelper, + args: &PrintArgs, ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let commit = workspace_command.resolve_single_rev(&args.revision)?; diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 188147ad59..470a240c0a 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -17,9 +17,7 @@ mod backout; #[cfg(feature = "bench")] mod bench; mod branch; -mod cat; mod checkout; -mod chmod; mod commit; mod config; mod debug; @@ -28,6 +26,7 @@ mod diff; mod diffedit; mod duplicate; mod edit; +mod file; mod files; mod fix; mod git; @@ -77,11 +76,12 @@ enum Command { Bench(bench::BenchCommand), #[command(subcommand)] Branch(branch::BranchCommand), - #[command(alias = "print")] - Cat(cat::CatArgs), + #[command(alias = "print", hide = true)] + Cat(file::print::PrintArgs), #[command(hide = true)] Checkout(checkout::CheckoutArgs), - Chmod(chmod::ChmodArgs), + #[command(hide = true)] + Chmod(file::chmod::ChmodArgs), Commit(commit::CommitArgs), #[command(subcommand)] Config(config::ConfigCommand), @@ -92,6 +92,8 @@ enum Command { Diffedit(diffedit::DiffeditArgs), Duplicate(duplicate::DuplicateArgs), Edit(edit::EditArgs), + #[command(subcommand)] + File(file::FileCommand), Files(files::FilesArgs), Fix(fix::FixArgs), #[command(subcommand)] @@ -171,8 +173,9 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co Command::Config(sub_args) => config::cmd_config(ui, command_helper, sub_args), Command::Checkout(sub_args) => checkout::cmd_checkout(ui, command_helper, sub_args), Command::Untrack(sub_args) => untrack::cmd_untrack(ui, command_helper, sub_args), + Command::File(sub_args) => file::cmd_file(ui, command_helper, sub_args), Command::Files(sub_args) => files::cmd_files(ui, command_helper, sub_args), - Command::Cat(sub_args) => cat::cmd_cat(ui, command_helper, sub_args), + Command::Cat(sub_args) => file::print::deprecated_cmd_cat(ui, command_helper, sub_args), Command::Diff(sub_args) => diff::cmd_diff(ui, command_helper, sub_args), Command::Show(sub_args) => show::cmd_show(ui, command_helper, sub_args), Command::Status(sub_args) => status::cmd_status(ui, command_helper, sub_args), @@ -210,7 +213,7 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co Command::Workspace(sub_args) => workspace::cmd_workspace(ui, command_helper, sub_args), Command::Sparse(sub_args) => sparse::cmd_sparse(ui, command_helper, sub_args), Command::Tag(sub_args) => tag::cmd_tag(ui, command_helper, sub_args), - Command::Chmod(sub_args) => chmod::cmd_chmod(ui, command_helper, sub_args), + Command::Chmod(sub_args) => file::chmod::deprecated_cmd_chmod(ui, command_helper, sub_args), Command::Git(sub_args) => git::cmd_git(ui, command_helper, sub_args), Command::Util(sub_args) => util::cmd_util(ui, command_helper, sub_args), #[cfg(feature = "bench")] diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index cc2f926482..9e3ac8faca 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -22,8 +22,6 @@ This document contains the help content for the `jj` command-line program. * [`jj branch set`↴](#jj-branch-set) * [`jj branch track`↴](#jj-branch-track) * [`jj branch untrack`↴](#jj-branch-untrack) -* [`jj cat`↴](#jj-cat) -* [`jj chmod`↴](#jj-chmod) * [`jj commit`↴](#jj-commit) * [`jj config`↴](#jj-config) * [`jj config list`↴](#jj-config-list) @@ -36,6 +34,9 @@ This document contains the help content for the `jj` command-line program. * [`jj diffedit`↴](#jj-diffedit) * [`jj duplicate`↴](#jj-duplicate) * [`jj edit`↴](#jj-edit) +* [`jj file`↴](#jj-file) +* [`jj file print`↴](#jj-file-print) +* [`jj file chmod`↴](#jj-file-chmod) * [`jj files`↴](#jj-files) * [`jj fix`↴](#jj-fix) * [`jj git`↴](#jj-git) @@ -108,8 +109,6 @@ To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/d * `abandon` — Abandon a revision * `backout` — Apply the reverse of a revision on top of another revision * `branch` — Manage branches -* `cat` — Print contents of files in a revision -* `chmod` — Sets or removes the executable bit for paths in the repo * `commit` — Update the description and create a new change on top * `config` — Manage config options * `describe` — Update the change description or other metadata @@ -117,6 +116,7 @@ To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/d * `diffedit` — Touch up the content changes in a revision with a diff editor * `duplicate` — Create a new change with the same content as an existing one * `edit` — Sets the specified revision as the working-copy revision +* `file` — File operations * `files` — List files in a revision * `fix` — Update files with formatting fixes or other changes * `git` — Commands for working with Git remotes and the underlying Git repo @@ -390,54 +390,6 @@ A non-tracking remote branch is just a pointer to the last-fetched remote branch -## `jj cat` - -Print contents of files in a revision - -If the given path is a directory, files in the directory will be visited recursively. - -**Usage:** `jj cat [OPTIONS] ...` - -###### **Arguments:** - -* `` — Paths to print - -###### **Options:** - -* `-r`, `--revision ` — The revision to get the file contents from - - Default value: `@` - - - -## `jj chmod` - -Sets or removes the executable bit for paths in the repo - -Unlike the POSIX `chmod`, `jj chmod` also works on Windows, on conflicted files, and on arbitrary revisions. - -**Usage:** `jj chmod [OPTIONS] ...` - -###### **Arguments:** - -* `` - - Possible values: - - `n`: - Make a path non-executable (alias: normal) - - `x`: - Make a path executable (alias: executable) - -* `` — Paths to change the executable bit for - -###### **Options:** - -* `-r`, `--revision ` — The revision to update - - Default value: `@` - - - ## `jj commit` Update the description and create a new change on top @@ -693,6 +645,67 @@ For more information, see https://martinvonz.github.io/jj/latest/FAQ#how-do-i-re +## `jj file` + +File operations + +**Usage:** `jj file ` + +###### **Subcommands:** + +* `print` — Print contents of files in a revision +* `chmod` — Sets or removes the executable bit for paths in the repo + + + +## `jj file print` + +Print contents of files in a revision + +If the given path is a directory, files in the directory will be visited recursively. + +**Usage:** `jj file print [OPTIONS] ...` + +###### **Arguments:** + +* `` — Paths to print + +###### **Options:** + +* `-r`, `--revision ` — The revision to get the file contents from + + Default value: `@` + + + +## `jj file chmod` + +Sets or removes the executable bit for paths in the repo + +Unlike the POSIX `chmod`, `jj chmod` also works on Windows, on conflicted files, and on arbitrary revisions. + +**Usage:** `jj file chmod [OPTIONS] ...` + +###### **Arguments:** + +* `` + + Possible values: + - `n`: + Make a path non-executable (alias: normal) + - `x`: + Make a path executable (alias: executable) + +* `` — Paths to change the executable bit for + +###### **Options:** + +* `-r`, `--revision ` — The revision to update + + Default value: `@` + + + ## `jj files` List files in a revision diff --git a/cli/tests/runner.rs b/cli/tests/runner.rs index afa39c3773..c143db0975 100644 --- a/cli/tests/runner.rs +++ b/cli/tests/runner.rs @@ -14,9 +14,7 @@ mod test_advance_branches; mod test_alias; mod test_branch_command; mod test_builtin_aliases; -mod test_cat_command; mod test_checkout; -mod test_chmod_command; mod test_commit_command; mod test_commit_template; mod test_concurrent_operations; @@ -27,6 +25,8 @@ mod test_diff_command; mod test_diffedit_command; mod test_duplicate_command; mod test_edit_command; +mod test_file_chmod_command; +mod test_file_print_command; mod test_fix_command; mod test_generate_md_cli_help; mod test_git_clone; diff --git a/cli/tests/test_acls.rs b/cli/tests/test_acls.rs index 8db8967bc9..58bc3370e4 100644 --- a/cli/tests/test_acls.rs +++ b/cli/tests/test_acls.rs @@ -110,7 +110,7 @@ fn test_cat() { SecretBackend::adopt_git_repo(&repo_path); - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["cat", "."]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["file", "print", "."]); insta::assert_snapshot!(stdout.replace('\\', "/"), @r###" foo baz diff --git a/cli/tests/test_diffedit_command.rs b/cli/tests/test_diffedit_command.rs index a5786cb40d..afa301a04d 100644 --- a/cli/tests/test_diffedit_command.rs +++ b/cli/tests/test_diffedit_command.rs @@ -394,7 +394,7 @@ fn test_diffedit_merge() { A file3 "###); assert!(!repo_path.join("file1").exists()); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 diff --git a/cli/tests/test_chmod_command.rs b/cli/tests/test_file_chmod_command.rs similarity index 88% rename from cli/tests/test_chmod_command.rs rename to cli/tests/test_file_chmod_command.rs index 97af1ed789..c6f2d0e9f7 100644 --- a/cli/tests/test_chmod_command.rs +++ b/cli/tests/test_file_chmod_command.rs @@ -50,7 +50,7 @@ fn test_chmod_regular_conflict() { create_commit(&test_env, &repo_path, "n", &["base"], &[("file", "n\n")]); create_commit(&test_env, &repo_path, "x", &["base"], &[("file", "x\n")]); // Test chmodding a file. The effect will be visible in the conflict below. - test_env.jj_cmd_ok(&repo_path, &["chmod", "x", "file", "-r=x"]); + test_env.jj_cmd_ok(&repo_path, &["file", "chmod", "x", "file", "-r=x"]); create_commit(&test_env, &repo_path, "conflict", &["x", "n"], &[]); // Test the setup @@ -68,7 +68,7 @@ fn test_chmod_regular_conflict() { @r###" file: Ok(Conflicted([Some(File { id: FileId("587be6b4c3f93f93c489c0111bba5596147a26cb"), executable: true }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("8ba3a16384aacc37d01564b28401755ce8053f51"), executable: false })])) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "file"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 @@ -81,13 +81,13 @@ fn test_chmod_regular_conflict() { "###); // Test chmodding a conflict - test_env.jj_cmd_ok(&repo_path, &["chmod", "x", "file"]); + test_env.jj_cmd_ok(&repo_path, &["file", "chmod", "x", "file"]); let stdout = test_env.jj_cmd_success(&repo_path, &["debug", "tree"]); insta::assert_snapshot!(stdout, @r###" file: Ok(Conflicted([Some(File { id: FileId("587be6b4c3f93f93c489c0111bba5596147a26cb"), executable: true }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: true }), Some(File { id: FileId("8ba3a16384aacc37d01564b28401755ce8053f51"), executable: true })])) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "file"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 @@ -98,13 +98,13 @@ fn test_chmod_regular_conflict() { n >>>>>>> Conflict 1 of 1 ends "###); - test_env.jj_cmd_ok(&repo_path, &["chmod", "n", "file"]); + test_env.jj_cmd_ok(&repo_path, &["file", "chmod", "n", "file"]); let stdout = test_env.jj_cmd_success(&repo_path, &["debug", "tree"]); insta::assert_snapshot!(stdout, @r###" file: Ok(Conflicted([Some(File { id: FileId("587be6b4c3f93f93c489c0111bba5596147a26cb"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(File { id: FileId("8ba3a16384aacc37d01564b28401755ce8053f51"), executable: false })])) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "file"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 @@ -117,7 +117,8 @@ fn test_chmod_regular_conflict() { "###); // Unmatched paths should generate warnings - let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["chmod", "x", "nonexistent", "file"]); + let (_stdout, stderr) = + test_env.jj_cmd_ok(&repo_path, &["file", "chmod", "x", "nonexistent", "file"]); insta::assert_snapshot!(stderr, @r###" Warning: No matching entries for paths: nonexistent Working copy now at: yostqsxw e5912d62 conflict | (conflict) conflict @@ -179,7 +180,7 @@ fn test_chmod_file_dir_deletion_conflicts() { @r###" file: Ok(Conflicted([Some(File { id: FileId("78981922613b2afb6025042ff6bd878ac1994e85"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), Some(Tree(TreeId("133bb38fc4e4bf6b551f1f04db7e48f04cac2877")))])) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "-r=file_dir", "file"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=file_dir", "file"]); insta::assert_snapshot!(stdout, @r###" Conflict: @@ -187,7 +188,8 @@ fn test_chmod_file_dir_deletion_conflicts() { Adding file with id 78981922613b2afb6025042ff6bd878ac1994e85 Adding tree with id 133bb38fc4e4bf6b551f1f04db7e48f04cac2877 "###); - let stderr = test_env.jj_cmd_failure(&repo_path, &["chmod", "x", "file", "-r=file_dir"]); + let stderr = + test_env.jj_cmd_failure(&repo_path, &["file", "chmod", "x", "file", "-r=file_dir"]); insta::assert_snapshot!(stderr, @r###" Error: Some of the sides of the conflict are not files at 'file'. "###); @@ -198,7 +200,8 @@ fn test_chmod_file_dir_deletion_conflicts() { @r###" file: Ok(Conflicted([Some(File { id: FileId("78981922613b2afb6025042ff6bd878ac1994e85"), executable: false }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: false }), None])) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "-r=file_deletion", "file"]); + let stdout = + test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=file_deletion", "file"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 @@ -208,8 +211,10 @@ fn test_chmod_file_dir_deletion_conflicts() { -base >>>>>>> Conflict 1 of 1 ends "###); - let (stdout, stderr) = - test_env.jj_cmd_ok(&repo_path, &["chmod", "x", "file", "-r=file_deletion"]); + let (stdout, stderr) = test_env.jj_cmd_ok( + &repo_path, + &["file", "chmod", "x", "file", "-r=file_deletion"], + ); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" New conflicts appeared in these commits: @@ -231,7 +236,8 @@ fn test_chmod_file_dir_deletion_conflicts() { @r###" file: Ok(Conflicted([Some(File { id: FileId("78981922613b2afb6025042ff6bd878ac1994e85"), executable: true }), Some(File { id: FileId("df967b96a579e45a18b8251732d16804b2e56a55"), executable: true }), None])) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "-r=file_deletion", "file"]); + let stdout = + test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=file_deletion", "file"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 diff --git a/cli/tests/test_cat_command.rs b/cli/tests/test_file_print_command.rs similarity index 77% rename from cli/tests/test_cat_command.rs rename to cli/tests/test_file_print_command.rs index 98fd088365..da3184541b 100644 --- a/cli/tests/test_cat_command.rs +++ b/cli/tests/test_file_print_command.rs @@ -15,7 +15,7 @@ use crate::common::TestEnvironment; #[test] -fn test_cat() { +fn test_print() { 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"); @@ -27,19 +27,13 @@ fn test_cat() { std::fs::write(repo_path.join("dir").join("file2"), "c\n").unwrap(); // Can print the contents of a file in a commit - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "file1", "-r", "@-"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "@-"]); insta::assert_snapshot!(stdout, @r###" a "###); // Defaults to printing the working-copy version - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "file1"]); - insta::assert_snapshot!(stdout, @r###" - b - "###); - - // `print` is an alias for `cat` - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" b "###); @@ -50,32 +44,33 @@ fn test_cat() { } else { "dir\\file2" }; - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", subdir_file]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", subdir_file]); insta::assert_snapshot!(stdout, @r###" c "###); // Error if the path doesn't exist - let stderr = test_env.jj_cmd_failure(&repo_path, &["cat", "nonexistent"]); + let stderr = test_env.jj_cmd_failure(&repo_path, &["file", "print", "nonexistent"]); insta::assert_snapshot!(stderr, @r###" Error: No such path: nonexistent "###); // Can print files under the specified directory - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "dir"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "dir"]); insta::assert_snapshot!(stdout, @r###" c "###); // Can print multiple files - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "."]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "."]); insta::assert_snapshot!(stdout, @r###" c b "###); // Unmatched paths should generate warnings - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["cat", "file1", "non-existent"]); + let (stdout, stderr) = + test_env.jj_cmd_ok(&repo_path, &["file", "print", "file1", "non-existent"]); insta::assert_snapshot!(stdout, @r###" b "###); @@ -87,7 +82,7 @@ fn test_cat() { test_env.jj_cmd_ok(&repo_path, &["new"]); std::fs::write(repo_path.join("file1"), "c\n").unwrap(); test_env.jj_cmd_ok(&repo_path, &["rebase", "-r", "@", "-d", "@--"]); - let stdout = test_env.jj_cmd_success(&repo_path, &["cat", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 @@ -101,7 +96,7 @@ fn test_cat() { #[cfg(unix)] #[test] -fn test_cat_symlink() { +fn test_print_symlink() { 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"); @@ -112,7 +107,7 @@ fn test_cat_symlink() { std::os::unix::fs::symlink("symlink1_target", repo_path.join("symlink1")).unwrap(); // Can print multiple files - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["cat", "."]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["file", "print", "."]); insta::assert_snapshot!(stdout, @r###" c a diff --git a/cli/tests/test_fix_command.rs b/cli/tests/test_fix_command.rs index 695d7b2b1b..23ab21ed7b 100644 --- a/cli/tests/test_fix_command.rs +++ b/cli/tests/test_fix_command.rs @@ -79,9 +79,9 @@ fn test_fix_leaf_commit() { Parent commit : qpvuntsm fda57e40 (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@-"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@-"]); insta::assert_snapshot!(content, @"unaffected"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"AFFECTED"); } @@ -106,11 +106,11 @@ fn test_fix_parent_commit() { Parent commit : qpvuntsm 4f4d2103 parent | (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "parent"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "parent"]); insta::assert_snapshot!(content, @"PARENT"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "child1"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "child1"]); insta::assert_snapshot!(content, @"CHILD1"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "child2"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "child2"]); insta::assert_snapshot!(content, @"CHILD2"); } @@ -131,11 +131,11 @@ fn test_fix_sibling_commit() { insta::assert_snapshot!(stderr, @r###" Fixed 1 commits of 1 checked. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "parent"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "parent"]); insta::assert_snapshot!(content, @"parent"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "child1"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "child1"]); insta::assert_snapshot!(content, @"CHILD1"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "child2"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "child2"]); insta::assert_snapshot!(content, @"child2"); } @@ -173,17 +173,17 @@ fn test_default_revset() { Parent commit : yqosqzyt 4747dd17 bar1 | (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "trunk1"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "trunk1"]); insta::assert_snapshot!(content, @"trunk1"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "trunk2"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "trunk2"]); insta::assert_snapshot!(content, @"trunk2"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "foo"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "foo"]); insta::assert_snapshot!(content, @"foo"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar1"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "bar1"]); insta::assert_snapshot!(content, @"BAR1"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar2"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "bar2"]); insta::assert_snapshot!(content, @"BAR2"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar3"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "bar3"]); insta::assert_snapshot!(content, @"BAR3"); } @@ -207,9 +207,9 @@ fn test_custom_default_revset() { insta::assert_snapshot!(stderr, @r###" Fixed 1 commits of 1 checked. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "foo"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "foo"]); insta::assert_snapshot!(content, @"foo"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "bar"]); insta::assert_snapshot!(content, @"BAR"); } @@ -228,9 +228,10 @@ fn test_fix_immutable_commit() { Error: Commit 83eee3c8dce2 is immutable Hint: Pass `--ignore-immutable` or configure the set of immutable commits via `revset-aliases.immutable_heads()`. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "immutable"]); + let content = + test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "immutable"]); insta::assert_snapshot!(content, @"immutable"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "mutable"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "mutable"]); insta::assert_snapshot!(content, @"mutable"); } @@ -245,7 +246,7 @@ fn test_fix_empty_file() { Fixed 0 commits of 1 checked. Nothing changed. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @""); } @@ -263,11 +264,11 @@ fn test_fix_some_paths() { Parent commit : zzzzzzzz 00000000 (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(content, @r###" FOO "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(content, @"bar"); } @@ -284,7 +285,7 @@ fn test_fix_cyclic() { Parent commit : zzzzzzzz 00000000 (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"tnetnoc\n"); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix"]); @@ -295,7 +296,7 @@ fn test_fix_cyclic() { Parent commit : zzzzzzzz 00000000 (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"content\n"); } @@ -328,13 +329,13 @@ fn test_deduplication() { Parent commit : mzvwutvl 90d9a032 c | (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "a"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "a"]); insta::assert_snapshot!(content, @"FOO\n"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "b"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "b"]); insta::assert_snapshot!(content, @"BAR\n"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "c"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "c"]); insta::assert_snapshot!(content, @"BAR\n"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "d"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "d"]); insta::assert_snapshot!(content, @"FOO\n"); // Each new content string only appears once in the log, because all the other @@ -366,7 +367,7 @@ fn test_executed_but_nothing_changed() { Fixed 0 commits of 1 checked. Nothing changed. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"content\n"); let copy_content = std::fs::read_to_string(repo_path.join("file-copy").as_os_str()).unwrap(); insta::assert_snapshot!(copy_content, @"content\n"); @@ -383,7 +384,7 @@ fn test_failure() { Fixed 0 commits of 1 checked. Nothing changed. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"content"); } @@ -403,7 +404,7 @@ fn test_stderr_success() { Parent commit : zzzzzzzz 00000000 (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"new content"); } @@ -419,7 +420,7 @@ fn test_stderr_failure() { errorFixed 0 commits of 1 checked. Nothing changed. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"old content"); } @@ -455,7 +456,7 @@ fn test_fix_file_types() { Parent commit : zzzzzzzz 00000000 (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"CONTENT"); } @@ -477,7 +478,7 @@ fn test_fix_executable() { Parent commit : zzzzzzzz 00000000 (empty) (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @"CONTENT"); let executable = std::fs::metadata(&path).unwrap().permissions().mode() & 0o111; assert_eq!(executable, 0o111); @@ -503,11 +504,11 @@ fn test_fix_trivial_merge_commit() { Fixed 0 commits of 1 checked. Nothing changed. "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_a", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_a", "-r", "@"]); insta::assert_snapshot!(content, @"content a"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_b", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_b", "-r", "@"]); insta::assert_snapshot!(content, @"content b"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_c", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_c", "-r", "@"]); insta::assert_snapshot!(content, @"content c"); } @@ -538,13 +539,13 @@ fn test_fix_adding_merge_commit() { Parent commit : kkmpptxz 82e9bc6a b | (no description set) Added 0 files, modified 4 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_a", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_a", "-r", "@"]); insta::assert_snapshot!(content, @"CHANGE A"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_b", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_b", "-r", "@"]); insta::assert_snapshot!(content, @"CHANGE B"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_c", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_c", "-r", "@"]); insta::assert_snapshot!(content, @"CHANGE C"); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file_d", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file_d", "-r", "@"]); insta::assert_snapshot!(content, @"CHANGE D"); } @@ -571,15 +572,15 @@ fn test_fix_both_sides_of_conflict() { There are unresolved conflicts at these paths: file 2-sided conflict "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "a"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "a"]); insta::assert_snapshot!(content, @r###" CONTENT A "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "b"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "b"]); insta::assert_snapshot!(content, @r###" CONTENT B "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @r###" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base to side #1 @@ -613,7 +614,7 @@ fn test_fix_resolve_conflict() { Parent commit : kkmpptxz 82703f5e b | (no description set) Added 0 files, modified 1 files, removed 0 files "###); - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "@"]); + let content = test_env.jj_cmd_success(&repo_path, &["file", "print", "file", "-r", "@"]); insta::assert_snapshot!(content, @r###" CONTENT "###); diff --git a/cli/tests/test_global_opts.rs b/cli/tests/test_global_opts.rs index 5639de0bf5..5ab67dfd9f 100644 --- a/cli/tests/test_global_opts.rs +++ b/cli/tests/test_global_opts.rs @@ -236,7 +236,7 @@ fn test_bad_path() { test_env.add_config("ui.allow-filesets = true"); // cwd == workspace_root - let stderr = test_env.jj_cmd_failure(&repo_path, &["cat", "../out"]); + let stderr = test_env.jj_cmd_failure(&repo_path, &["file", "print", "../out"]); insta::assert_snapshot!(stderr.replace('\\', "/"), @r###" Error: Failed to parse fileset: Invalid file pattern Caused by: @@ -251,7 +251,7 @@ fn test_bad_path() { "###); // cwd != workspace_root, can't be parsed as repo-relative path - let stderr = test_env.jj_cmd_failure(&subdir, &["cat", "../.."]); + let stderr = test_env.jj_cmd_failure(&subdir, &["file", "print", "../.."]); insta::assert_snapshot!(stderr.replace('\\', "/"), @r###" Error: Failed to parse fileset: Invalid file pattern Caused by: @@ -266,7 +266,7 @@ fn test_bad_path() { "###); // cwd != workspace_root, can be parsed as repo-relative path - let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["cat", "-Rrepo", "out"]); + let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["file", "print", "-Rrepo", "out"]); insta::assert_snapshot!(stderr.replace('\\', "/"), @r###" Error: Failed to parse fileset: Invalid file pattern Caused by: @@ -284,7 +284,7 @@ fn test_bad_path() { test_env.add_config("ui.allow-filesets = false"); // If fileset/pattern syntax is disabled, no hint should be generated - let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["cat", "-Rrepo", "out"]); + let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["file", "print", "-Rrepo", "out"]); insta::assert_snapshot!(stderr.replace('\\', "/"), @r###" Error: Path "out" is not in the repo "repo" Caused by: Invalid component ".." in repo-relative path "../out" diff --git a/cli/tests/test_immutable_commits.rs b/cli/tests/test_immutable_commits.rs index e5966db15e..44a41245e5 100644 --- a/cli/tests/test_immutable_commits.rs +++ b/cli/tests/test_immutable_commits.rs @@ -204,7 +204,7 @@ fn test_rewrite_immutable_commands() { Hint: Pass `--ignore-immutable` or configure the set of immutable commits via `revset-aliases.immutable_heads()`. "###); // chmod - let stderr = test_env.jj_cmd_failure(&repo_path, &["chmod", "-r=main", "x", "file"]); + let stderr = test_env.jj_cmd_failure(&repo_path, &["file", "chmod", "-r=main", "x", "file"]); insta::assert_snapshot!(stderr, @r###" Error: Commit 3e0250828ca5 is immutable Hint: Pass `--ignore-immutable` or configure the set of immutable commits via `revset-aliases.immutable_heads()`. diff --git a/cli/tests/test_move_command.rs b/cli/tests/test_move_command.rs index 1e30470c13..7d302a93df 100644 --- a/cli/tests/test_move_command.rs +++ b/cli/tests/test_move_command.rs @@ -103,12 +103,12 @@ fn test_move() { ◉ 000000000000 "###); // The change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); // File `file2`, which was not changed in source, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" f "###); @@ -136,7 +136,7 @@ fn test_move() { "###); // The change from the source has been applied (the file contents were already // "f", as is typically the case when moving changes from an ancestor) - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" f "###); @@ -164,7 +164,7 @@ fn test_move() { ◉ 000000000000 "###); // The change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "d"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "d"]); insta::assert_snapshot!(stdout, @r###" e "###); @@ -227,16 +227,16 @@ fn test_move_partial() { ◉ 000000000000 "###); // The changes from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" c "###); // File `file3`, which was not changed in source, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file3"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -262,17 +262,17 @@ fn test_move_partial() { ◉ 000000000000 "###); // The selected change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); // The unselected change from the source has not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" a "###); // File `file3`, which was changed in source's parent, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file3"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -299,17 +299,17 @@ fn test_move_partial() { ◉ 000000000000 "###); // The selected change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); // The unselected change from the source has not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" a "###); // File `file3`, which was changed in source's parent, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file3"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -335,12 +335,12 @@ fn test_move_partial() { ◉ 000000000000 "###); // The selected change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" c "###); // The unselected change from the source has not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" a "###); diff --git a/cli/tests/test_new_command.rs b/cli/tests/test_new_command.rs index d77e555bf5..2baab83bde 100644 --- a/cli/tests/test_new_command.rs +++ b/cli/tests/test_new_command.rs @@ -85,9 +85,9 @@ fn test_new_merge() { ├─╯ ◉ 0000000000000000000000000000000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @"a"); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @"b"); // Same test with `--no-edit` diff --git a/cli/tests/test_squash_command.rs b/cli/tests/test_squash_command.rs index da672d923a..a6ebad54f7 100644 --- a/cli/tests/test_squash_command.rs +++ b/cli/tests/test_squash_command.rs @@ -51,7 +51,7 @@ fn test_squash() { ◉ 90aeefd03044 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); @@ -70,11 +70,11 @@ fn test_squash() { ◉ 893c93ae2a87 a b ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); @@ -123,7 +123,7 @@ fn test_squash() { ◉ 90aeefd03044 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "e"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "e"]); insta::assert_snapshot!(stdout, @r###" e "###); @@ -169,7 +169,7 @@ fn test_squash_partial() { ◉ c9f931cd78af a b ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "a"]); insta::assert_snapshot!(stdout, @r###" b "###); @@ -190,19 +190,19 @@ fn test_squash_partial() { ◉ 0c5ddc685260 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "a"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "a"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "a"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); @@ -224,19 +224,19 @@ fn test_squash_partial() { ◉ 70621f4c7a42 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "a"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "a"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "a"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); @@ -332,12 +332,12 @@ fn test_squash_from_to() { ◉ 000000000000 "###); // The change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); // File `file2`, which was not changed in source, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" f "###); @@ -363,7 +363,7 @@ fn test_squash_from_to() { "###); // The change from the source has been applied (the file contents were already // "f", as is typically the case when moving changes from an ancestor) - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" f "###); @@ -390,7 +390,7 @@ fn test_squash_from_to() { ◉ 000000000000 "###); // The change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "d"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "d"]); insta::assert_snapshot!(stdout, @r###" e "###); @@ -451,16 +451,16 @@ fn test_squash_from_to_partial() { ◉ 000000000000 "###); // The changes from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" c "###); // File `file3`, which was not changed in source, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file3"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -484,17 +484,17 @@ fn test_squash_from_to_partial() { ◉ 000000000000 "###); // The selected change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); // The unselected change from the source has not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" a "###); // File `file3`, which was changed in source's parent, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file3"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -519,17 +519,17 @@ fn test_squash_from_to_partial() { ◉ 000000000000 "###); // The selected change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); // The unselected change from the source has not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2"]); insta::assert_snapshot!(stdout, @r###" a "###); // File `file3`, which was changed in source's parent, is unchanged - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file3"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -555,12 +555,12 @@ fn test_squash_from_to_partial() { ◉ 000000000000 "###); // The selected change from the source has been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" c "###); // The unselected change from the source has not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" a "###); @@ -647,7 +647,7 @@ fn test_squash_from_multiple() { ◉ 000000000000 "###); // The changes from the sources have been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=d", "file"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=d", "file"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base #1 to side #1 @@ -680,7 +680,7 @@ fn test_squash_from_multiple() { ◉ 000000000000 "###); // The changes from the sources have been applied to the destination - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=e", "file"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=e", "file"]); insta::assert_snapshot!(stdout, @r###" f "###); @@ -775,16 +775,16 @@ fn test_squash_from_multiple_partial() { ◉ 000000000000 "###); // The selected changes have been removed from the sources - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=b", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=b", "file1"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=c", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=c", "file1"]); insta::assert_snapshot!(stdout, @r###" a "###); // The selected changes from the sources have been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=d", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=d", "file1"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< Conflict 1 of 1 %%%%%%% Changes from base #1 to side #1 @@ -799,7 +799,7 @@ fn test_squash_from_multiple_partial() { "###); // The unselected change from the sources have not been applied to the // destination - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=d", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=d", "file2"]); insta::assert_snapshot!(stdout, @r###" d "###); @@ -827,25 +827,25 @@ fn test_squash_from_multiple_partial() { ◉ 000000000000 "###); // The selected changes have been removed from the sources - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=b", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=b", "file1"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=c", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=c", "file1"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=f", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=f", "file1"]); insta::assert_snapshot!(stdout, @r###" f "###); // The selected changes from the sources have been applied to the destination - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=e", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=e", "file1"]); insta::assert_snapshot!(stdout, @r###" f "###); // The unselected changes from the sources have not been applied - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "-r=d", "file2"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "-r=d", "file2"]); insta::assert_snapshot!(stdout, @r###" d "###); diff --git a/cli/tests/test_unsquash_command.rs b/cli/tests/test_unsquash_command.rs index f2e3b6ddd8..0379279360 100644 --- a/cli/tests/test_unsquash_command.rs +++ b/cli/tests/test_unsquash_command.rs @@ -50,7 +50,7 @@ fn test_unsquash() { ◉ 90aeefd03044 a b ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); @@ -69,11 +69,11 @@ fn test_unsquash() { ◉ 9146bcc8d996 b ◉ 000000000000 a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" c "###); @@ -122,7 +122,7 @@ fn test_unsquash() { ◉ 90aeefd03044 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1"]); insta::assert_snapshot!(stdout, @r###" e "###); @@ -169,7 +169,7 @@ fn test_unsquash_partial() { ◉ ee67504598b6 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "a"]); insta::assert_snapshot!(stdout, @r###" a "###); @@ -189,19 +189,19 @@ fn test_unsquash_partial() { ◉ 47a1e795d146 a ◉ 000000000000 "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "c"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "c"]); insta::assert_snapshot!(stdout, @r###" c "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "c"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "c"]); insta::assert_snapshot!(stdout, @r###" c "###); @@ -221,19 +221,19 @@ fn test_unsquash_partial() { Working copy now at: mzvwutvl 1c82d27c c | (no description set) Parent commit : kkmpptxz b9d23fd8 b | (no description set) "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" a "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "b"]); insta::assert_snapshot!(stdout, @r###" b "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "c"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file1", "-r", "c"]); insta::assert_snapshot!(stdout, @r###" c "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "c"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["file", "print", "file2", "-r", "c"]); insta::assert_snapshot!(stdout, @r###" c "###);