ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: create jj file list and deprecate jj files

This commit is contained in:
Matt Kulukundis 2024-06-15 13:27:01 -04:00 committed by Matt Fowles Kulukundis
parent 30f54862dd
commit 5d307e628b
9 changed files with 46 additions and 21 deletions

View file

@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `jj file chmod` replaces `jj chmod`.
* `jj file list` (aka `jj file ls`) replaces `jj files`.
### New features
* Support background filesystem monitoring via watchman triggers enabled with

View file

@ -22,7 +22,7 @@ use crate::ui::Ui;
/// List files in a revision
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct FilesArgs {
pub(crate) struct ListArgs {
/// The revision to list files in
#[arg(long, short, default_value = "@")]
revision: RevisionArg,
@ -32,10 +32,27 @@ pub(crate) struct FilesArgs {
}
#[instrument(skip_all)]
pub(crate) fn cmd_files(
pub(crate) fn deprecated_cmd_files(
ui: &mut Ui,
command: &CommandHelper,
args: &FilesArgs,
args: &ListArgs,
) -> Result<(), CommandError> {
writeln!(
ui.warning_default(),
"`jj files` is deprecated; use `jj file list` instead, which is equivalent"
)?;
writeln!(
ui.warning_default(),
"`jj files` will be removed in a future version, and this will be a hard error"
)?;
cmd_list(ui, command, args)
}
#[instrument(skip_all)]
pub(crate) fn cmd_list(
ui: &mut Ui,
command: &CommandHelper,
args: &ListArgs,
) -> Result<(), CommandError> {
let workspace_command = command.workspace_helper(ui)?;
let commit = workspace_command.resolve_single_rev(&args.revision)?;

View file

@ -13,6 +13,7 @@
// limitations under the License.
pub mod chmod;
pub mod list;
pub mod print;
use crate::cli_util::CommandHelper;
@ -24,6 +25,7 @@ use crate::ui::Ui;
pub enum FileCommand {
Print(print::PrintArgs),
Chmod(chmod::ChmodArgs),
List(list::ListArgs),
}
pub fn cmd_file(
@ -34,5 +36,6 @@ pub fn cmd_file(
match subcommand {
FileCommand::Print(sub_args) => print::cmd_print(ui, command, sub_args),
FileCommand::Chmod(sub_args) => chmod::cmd_chmod(ui, command, sub_args),
FileCommand::List(sub_args) => list::cmd_list(ui, command, sub_args),
}
}

View file

@ -27,7 +27,6 @@ mod diffedit;
mod duplicate;
mod edit;
mod file;
mod files;
mod fix;
mod git;
mod init;
@ -94,7 +93,9 @@ enum Command {
Edit(edit::EditArgs),
#[command(subcommand)]
File(file::FileCommand),
Files(files::FilesArgs),
/// List files in a revision (DEPRECATED use `jj file list`)
#[command(hide = true)]
Files(file::list::ListArgs),
Fix(fix::FixArgs),
#[command(subcommand)]
Git(git::GitCommand),
@ -174,8 +175,8 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co
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) => file::print::deprecated_cmd_cat(ui, command_helper, sub_args),
Command::Files(sub_args) => file::list::deprecated_cmd_files(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),

View file

@ -37,7 +37,7 @@ This document contains the help content for the `jj` command-line program.
* [`jj file`↴](#jj-file)
* [`jj file print`↴](#jj-file-print)
* [`jj file chmod`↴](#jj-file-chmod)
* [`jj files`↴](#jj-files)
* [`jj file list`↴](#jj-file-list)
* [`jj fix`↴](#jj-fix)
* [`jj git`↴](#jj-git)
* [`jj git remote`↴](#jj-git-remote)
@ -117,7 +117,6 @@ To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/d
* `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
* `init` — Create a new repo in the given directory
@ -655,6 +654,7 @@ File operations
* `print` — Print contents of files in a revision
* `chmod` — Sets or removes the executable bit for paths in the repo
* `list` — List files in a revision
@ -706,11 +706,11 @@ Unlike the POSIX `chmod`, `jj chmod` also works on Windows, on conflicted files,
## `jj files`
## `jj file list`
List files in a revision
**Usage:** `jj files [OPTIONS] [PATHS]...`
**Usage:** `jj file list [OPTIONS] [PATHS]...`
###### **Arguments:**

View file

@ -316,8 +316,10 @@ fn test_alias_in_repo_config() {
"###);
// No warning if the expanded command is identical.
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo1_path, &["files", "-R", repo2_path.to_str().unwrap()]);
let (stdout, stderr) = test_env.jj_cmd_ok(
&repo1_path,
&["file", "list", "-R", repo2_path.to_str().unwrap()],
);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");

View file

@ -49,7 +49,7 @@ fn test_sparse_manage_patterns() {
assert!(!repo_path.join("file2").exists());
assert!(!repo_path.join("file3").exists());
// But they're still in the commit
let stdout = test_env.jj_cmd_success(&repo_path, &["files"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
insta::assert_snapshot!(stdout, @r###"
file1
file2

View file

@ -35,7 +35,7 @@ fn test_untrack() {
// patterns
test_env.jj_cmd_ok(&repo_path, &["st"]);
std::fs::write(repo_path.join(".gitignore"), "*.bak\n").unwrap();
let files_before = test_env.jj_cmd_success(&repo_path, &["files"]);
let files_before = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
// Errors out when not run at the head operation
let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack", "file1", "--at-op", "@-"]);
@ -60,7 +60,7 @@ fn test_untrack() {
Hint: Files that are not ignored will be added back by the next command.
Make sure they're ignored, then try again.
"###);
let files_after = test_env.jj_cmd_success(&repo_path, &["files"]);
let files_after = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
// There should be no changes to the state when there was an error
assert_eq!(files_after, files_before);
@ -69,7 +69,7 @@ fn test_untrack() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["untrack", "file1.bak"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
let files_after = test_env.jj_cmd_success(&repo_path, &["files"]);
let files_after = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
// The file is no longer tracked
assert!(!files_after.contains("file1.bak"));
// Other files that match the ignore pattern are not untracked
@ -94,7 +94,7 @@ fn test_untrack() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["untrack", "target"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
let files_after = test_env.jj_cmd_success(&repo_path, &["files"]);
let files_after = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
assert!(!files_after.contains("target"));
}
@ -111,7 +111,7 @@ fn test_untrack_sparse() {
// When untracking a file that's not included in the sparse working copy, it
// doesn't need to be ignored (because it won't be automatically added
// back).
let stdout = test_env.jj_cmd_success(&repo_path, &["files"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
insta::assert_snapshot!(stdout, @r###"
file1
file2
@ -120,7 +120,7 @@ fn test_untrack_sparse() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["untrack", "file2"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
let stdout = test_env.jj_cmd_success(&repo_path, &["files"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["file", "list"]);
insta::assert_snapshot!(stdout, @r###"
file1
"###);

View file

@ -24,7 +24,7 @@ fn test_snapshot_large_file() {
// in bytes
test_env.add_config(r#"snapshot.max-new-file-size = 10"#);
std::fs::write(repo_path.join("large"), "a lot of text").unwrap();
let stderr = test_env.jj_cmd_failure(&repo_path, &["files"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["file", "list"]);
insta::assert_snapshot!(stderr, @r###"
Error: Failed to snapshot the working copy
The file '$TEST_ENV/repo/large' is too large to be snapshotted: it is 3 bytes too large; the maximum size allowed is 10 bytes (10.0B).
@ -40,7 +40,7 @@ fn test_snapshot_large_file() {
test_env.add_config(r#"snapshot.max-new-file-size = "10KB""#);
let big_string = vec![0; 1024 * 11];
std::fs::write(repo_path.join("large"), big_string).unwrap();
let stderr = test_env.jj_cmd_failure(&repo_path, &["files"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["file", "list"]);
insta::assert_snapshot!(stderr, @r###"
Error: Failed to snapshot the working copy
The file '$TEST_ENV/repo/large' is too large to be snapshotted: it is 1024 bytes too large; the maximum size allowed is 10240 bytes (10.0KiB).