Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions cli/src/commands/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use tracing::instrument;

use crate::cli_util::CommandHelper;
use crate::cli_util::RevisionArg;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::cli_util::print_updated_commits;
use crate::command_error::CommandError;
use crate::complete;
Expand Down Expand Up @@ -81,14 +82,20 @@ pub(crate) fn cmd_absorb(
.parse_union_revsets(ui, &args.into)?
.resolve()?;

let matcher = workspace_command
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();

let repo = workspace_command.repo().as_ref();
let source = AbsorbSource::from_commit(repo, source_commit)?;
let source = AbsorbSource::from_commit(repo, source_commit.clone())?;
let selected_trees = split_hunks_to_trees(repo, &source, &destinations, &matcher).block_on()?;

print_unmatched_explicit_paths(
ui,
&workspace_command,
&fileset_expression,
[&source_commit.tree().unwrap()],
)?;

let path_converter = workspace_command.path_converter();
for (path, reason) in selected_trees.skipped_paths {
let ui_path = path_converter.format_file_path(&path);
Expand Down
32 changes: 24 additions & 8 deletions cli/src/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use std::process::Stdio;

use clap_complete::ArgValueCompleter;
use itertools::Itertools as _;
use jj_lib::backend::CommitId;
use jj_lib::backend::FileId;
use jj_lib::commit::Commit;
use jj_lib::fileset;
use jj_lib::fileset::FilesetDiagnostics;
use jj_lib::fileset::FilesetExpression;
Expand All @@ -38,6 +38,7 @@ use tracing::instrument;

use crate::cli_util::CommandHelper;
use crate::cli_util::RevisionArg;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::command_error::config_error;
use crate::command_error::print_parse_diagnostics;
Expand Down Expand Up @@ -134,18 +135,25 @@ pub(crate) fn cmd_fix(
let workspace_root = workspace_command.workspace_root().to_owned();
let path_converter = workspace_command.path_converter().to_owned();
let tools_config = get_tools_config(ui, workspace_command.settings())?;
let root_commits: Vec<CommitId> = if args.source.is_empty() {
let root_commits: Vec<Commit> = if args.source.is_empty() {
let revs = workspace_command.settings().get_string("revsets.fix")?;
workspace_command.parse_revset(ui, &RevisionArg::from(revs))?
} else {
workspace_command.parse_union_revsets(ui, &args.source)?
}
.evaluate_to_commit_ids()?
.evaluate_to_commits()?
.try_collect()?;
workspace_command.check_rewritable(root_commits.iter())?;
let matcher = workspace_command
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
let root_commit_ids = root_commits
.iter()
.map(|commit| commit.id().clone())
.collect_vec();
let root_trees = root_commits
.iter()
.map(|commit| commit.tree().unwrap())
.collect_vec();
workspace_command.check_rewritable(root_commit_ids.iter())?;
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();

let mut tx = workspace_command.start_transaction();
let mut parallel_fixer = ParallelFileFixer::new(|store, file_to_fix| {
Expand All @@ -159,8 +167,16 @@ pub(crate) fn cmd_fix(
)
.block_on()
});

print_unmatched_explicit_paths(
ui,
tx.base_workspace_helper(),
&fileset_expression,
root_trees.iter(),
)?;

let summary = fix_files(
root_commits,
root_commit_ids,
&matcher,
args.include_unchanged_files,
tx.repo_mut(),
Expand Down
14 changes: 11 additions & 3 deletions cli/src/commands/interdiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use tracing::instrument;

use crate::cli_util::CommandHelper;
use crate::cli_util::RevisionArg;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::complete;
use crate::diff_util::DiffFormatArgs;
Expand Down Expand Up @@ -74,9 +75,8 @@ pub(crate) fn cmd_interdiff(
workspace_command.resolve_single_rev(ui, args.from.as_ref().unwrap_or(&RevisionArg::AT))?;
let to =
workspace_command.resolve_single_rev(ui, args.to.as_ref().unwrap_or(&RevisionArg::AT))?;
let matcher = workspace_command
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();
let diff_renderer = workspace_command.diff_renderer_for(&args.format)?;
ui.request_pager();
diff_renderer
Expand All @@ -89,5 +89,13 @@ pub(crate) fn cmd_interdiff(
ui.term_width(),
)
.block_on()?;

print_unmatched_explicit_paths(
ui,
&workspace_command,
&fileset_expression,
[&from.tree().unwrap(), &to.tree().unwrap()],
)?;

Ok(())
}
9 changes: 9 additions & 0 deletions cli/src/commands/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use jj_lib::graph::GraphEdge;
use jj_lib::graph::GraphEdgeType;
use jj_lib::graph::TopoGroupedGraphIterator;
use jj_lib::graph::reverse_graph;
use jj_lib::merged_tree::MergedTree;
use jj_lib::repo::Repo as _;
use jj_lib::revset::RevsetEvaluationError;
use jj_lib::revset::RevsetExpression;
Expand All @@ -33,6 +34,7 @@ use crate::cli_util::CommandHelper;
use crate::cli_util::LogContentFormat;
use crate::cli_util::RevisionArg;
use crate::cli_util::format_template;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::complete;
use crate::diff_util::DiffFormatArgs;
Expand Down Expand Up @@ -179,6 +181,7 @@ pub(crate) fn cmd_log(
.labeled(["log", "commit", "node"]);
}

let mut trees: Vec<MergedTree> = vec![];
{
ui.request_pager();
let mut formatter = ui.stdout_formatter();
Expand Down Expand Up @@ -250,6 +253,8 @@ pub(crate) fn cmd_log(
if !buffer.ends_with(b"\n") {
buffer.push(b'\n');
}

trees.push(commit.tree().unwrap());
if let Some(renderer) = &diff_renderer {
let mut formatter = ui.new_formatter(&mut buffer);
renderer
Expand Down Expand Up @@ -303,6 +308,8 @@ pub(crate) fn cmd_log(
let commit = commit_or_error?;
with_content_format
.write(formatter, |formatter| template.format(&commit, formatter))?;

trees.push(commit.tree().unwrap());
if let Some(renderer) = &diff_renderer {
let width = ui.term_width();
renderer
Expand All @@ -313,6 +320,8 @@ pub(crate) fn cmd_log(
}
}

print_unmatched_explicit_paths(ui, &workspace_command, &fileset_expression, trees.iter())?;

// Check to see if the user might have specified a path when they intended
// to specify a revset.
if let ([], [only_path]) = (args.revisions.as_slice(), args.paths.as_slice()) {
Expand Down
9 changes: 6 additions & 3 deletions cli/src/commands/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use tracing::instrument;
use crate::cli_util::CommandHelper;
use crate::cli_util::RevisionArg;
use crate::cli_util::print_conflicted_paths;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::command_error::cli_error;
use crate::complete;
Expand Down Expand Up @@ -87,15 +88,17 @@ pub(crate) fn cmd_resolve(
args: &ResolveArgs,
) -> Result<(), CommandError> {
let mut workspace_command = command.workspace_helper(ui)?;
let matcher = workspace_command
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();
let commit = workspace_command.resolve_single_rev(ui, &args.revision)?;
let tree = commit.tree()?;
let conflicts = tree
.conflicts()
.filter(|path| matcher.matches(&path.0))
.collect_vec();

print_unmatched_explicit_paths(ui, &workspace_command, &fileset_expression, [&tree])?;

if conflicts.is_empty() {
return Err(cli_error(if args.paths.is_empty() {
"No conflicts found at this revision"
Expand Down
14 changes: 11 additions & 3 deletions cli/src/commands/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use tracing::instrument;

use crate::cli_util::CommandHelper;
use crate::cli_util::RevisionArg;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::command_error::user_error;
use crate::complete;
Expand Down Expand Up @@ -140,9 +141,8 @@ pub(crate) fn cmd_restore(
}
workspace_command.check_rewritable([to_commit.id()])?;

let matcher = workspace_command
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();
let diff_selector =
workspace_command.diff_selector(ui, args.tool.as_deref(), args.interactive)?;
let to_tree = to_commit.tree()?;
Expand All @@ -164,6 +164,14 @@ pub(crate) fn cmd_restore(
};
let new_tree_id =
diff_selector.select([&to_tree, &from_tree], &matcher, format_instructions)?;

print_unmatched_explicit_paths(
ui,
&workspace_command,
&fileset_expression,
[&to_tree, &from_tree],
)?;

if &new_tree_id == to_commit.tree_id() {
writeln!(ui.status(), "Nothing changed.")?;
} else {
Expand Down
14 changes: 11 additions & 3 deletions cli/src/commands/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use crate::cli_util::RevisionArg;
use crate::cli_util::WorkspaceCommandHelper;
use crate::cli_util::WorkspaceCommandTransaction;
use crate::cli_util::compute_commit_location;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::command_error::user_error_with_hint;
use crate::complete;
Expand Down Expand Up @@ -158,9 +159,8 @@ impl SplitArgs {
));
}
workspace_command.check_rewritable([target_commit.id()])?;
let matcher = workspace_command
.parse_file_patterns(ui, &self.paths)?
.to_matcher();
let fileset_expression = workspace_command.parse_file_patterns(ui, &self.paths)?;
let matcher = fileset_expression.to_matcher();
let diff_selector = workspace_command.diff_selector(
ui,
self.tool.as_deref(),
Expand All @@ -181,6 +181,14 @@ impl SplitArgs {
} else {
Default::default()
};

print_unmatched_explicit_paths(
ui,
workspace_command,
&fileset_expression,
[&target_commit.tree().unwrap()],
)?;

Ok(ResolvedSplitArgs {
target_commit,
matcher,
Expand Down
17 changes: 14 additions & 3 deletions cli/src/commands/squash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::cli_util::DiffSelector;
use crate::cli_util::RevisionArg;
use crate::cli_util::WorkspaceCommandTransaction;
use crate::cli_util::compute_commit_location;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::command_error::user_error;
use crate::command_error::user_error_with_hint;
Expand Down Expand Up @@ -302,10 +303,10 @@ pub(crate) fn cmd_squash(
commit
};

let matcher = tx
let fileset_expression = tx
.base_workspace_helper()
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();
let diff_selector =
tx.base_workspace_helper()
.diff_selector(ui, args.tool.as_deref(), args.interactive)?;
Expand Down Expand Up @@ -377,6 +378,7 @@ pub(crate) fn cmd_squash(
}
let commit = commit_builder.write(tx.repo_mut())?;
let num_rebased = tx.repo_mut().rebase_descendants()?;

if let Some(mut formatter) = ui.status_formatter() {
if insert_destination_commit {
write!(formatter, "Created new commit ")?;
Expand Down Expand Up @@ -419,7 +421,16 @@ pub(crate) fn cmd_squash(
}
}
}

print_unmatched_explicit_paths(
ui,
tx.base_workspace_helper(),
&fileset_expression,
source_commits.iter().map(|commit| &commit.selected_tree),
)?;

tx.finish(ui, tx_description)?;

Ok(())
}

Expand Down
15 changes: 11 additions & 4 deletions cli/src/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use tracing::instrument;
use crate::cli_util::CommandHelper;
use crate::cli_util::print_conflicted_paths;
use crate::cli_util::print_snapshot_stats;
use crate::cli_util::print_unmatched_explicit_paths;
use crate::command_error::CommandError;
use crate::diff_util::DiffFormat;
use crate::diff_util::get_copy_records;
Expand Down Expand Up @@ -69,9 +70,8 @@ pub(crate) fn cmd_status(
.get_wc_commit_id()
.map(|id| repo.store().get_commit(id))
.transpose()?;
let matcher = workspace_command
.parse_file_patterns(ui, &args.paths)?
.to_matcher();
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();
ui.request_pager();
let mut formatter = ui.stdout_formatter();
let formatter = formatter.as_mut();
Expand Down Expand Up @@ -110,7 +110,7 @@ pub(crate) fn cmd_status(
writeln!(formatter, "Untracked paths:")?;
visit_collapsed_untracked_files(
snapshot_stats.untracked_paths.keys(),
tree,
tree.clone(),
|path, is_dir| {
let ui_path = workspace_command.path_converter().format_file_path(path);
writeln!(
Expand Down Expand Up @@ -178,6 +178,13 @@ pub(crate) fn cmd_status(
}
}
}

print_unmatched_explicit_paths(
ui,
&workspace_command,
&fileset_expression,
[&parent_tree, &tree],
)?;
} else {
writeln!(formatter, "No working copy")?;
}
Expand Down
3 changes: 2 additions & 1 deletion cli/tests/test_absorb_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,10 @@ fn test_absorb_paths() {
work_dir.write_file("file1", "1A\n");
work_dir.write_file("file2", "1A\n");

let output = work_dir.run_jj(["absorb", "unknown"]);
let output = work_dir.run_jj(["absorb", "nonexistent"]);
insta::assert_snapshot!(output, @r"
------- stderr -------
Warning: No matching entries for paths: nonexistent
Nothing changed.
[EOF]
");
Expand Down
Loading
Loading