diff --git a/cli/examples/custom-command/main.rs b/cli/examples/custom-command/main.rs index e87ca4ec9..31d43f4e7 100644 --- a/cli/examples/custom-command/main.rs +++ b/cli/examples/custom-command/main.rs @@ -41,7 +41,7 @@ fn run_custom_command( match command { CustomCommand::Frobnicate(args) => { let mut workspace_command = command_helper.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; let mut tx = workspace_command.start_transaction(); let new_commit = tx .repo_mut() diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index fad187b2d..e3e83cc75 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -375,7 +375,7 @@ impl CommandHelper { let op_head = self.resolve_operation(ui, workspace.repo_loader())?; let repo = workspace.repo_loader().load_at(&op_head)?; let env = self.workspace_environment(ui, &workspace)?; - WorkspaceCommandHelper::new(workspace, repo, env, self.is_at_head_operation()) + WorkspaceCommandHelper::new(ui, workspace, repo, env, self.is_at_head_operation()) } pub fn get_working_copy_factory(&self) -> Result<&dyn WorkingCopyFactory, CommandError> { @@ -491,7 +491,7 @@ impl CommandHelper { ) -> Result { let env = self.workspace_environment(ui, &workspace)?; let loaded_at_head = true; - WorkspaceCommandHelper::new(workspace, repo, env, loaded_at_head) + WorkspaceCommandHelper::new(ui, workspace, repo, env, loaded_at_head) } } @@ -618,8 +618,8 @@ impl WorkspaceCommandEnvironment { immutable_heads_expression: RevsetExpression::root(), short_prefixes_expression: None, }; - env.immutable_heads_expression = env.load_immutable_heads_expression()?; - env.short_prefixes_expression = env.load_short_prefixes_expression()?; + env.immutable_heads_expression = env.load_immutable_heads_expression(ui)?; + env.short_prefixes_expression = env.load_short_prefixes_expression(ui)?; Ok(env) } @@ -678,12 +678,18 @@ impl WorkspaceCommandEnvironment { &self.immutable_heads_expression } - fn load_immutable_heads_expression(&self) -> Result, CommandError> { + fn load_immutable_heads_expression( + &self, + _ui: &Ui, + ) -> Result, CommandError> { revset_util::parse_immutable_heads_expression(&self.revset_parse_context()) .map_err(|e| config_error_with_message("Invalid `revset-aliases.immutable_heads()`", e)) } - fn load_short_prefixes_expression(&self) -> Result>, CommandError> { + fn load_short_prefixes_expression( + &self, + _ui: &Ui, + ) -> Result>, CommandError> { let revset_string = self .settings() .config() @@ -761,6 +767,7 @@ impl WorkspaceCommandEnvironment { /// be one of the `L::wrap_*()` functions. pub fn parse_template<'a, C: Clone + 'a, L: TemplateLanguage<'a> + ?Sized>( &self, + _ui: &Ui, language: &L, template_text: &str, wrap_self: impl Fn(PropertyPlaceholder) -> L::Property, @@ -808,6 +815,7 @@ pub struct WorkspaceCommandHelper { impl WorkspaceCommandHelper { #[instrument(skip_all)] fn new( + ui: &Ui, workspace: Workspace, repo: Arc, env: WorkspaceCommandEnvironment, @@ -831,9 +839,9 @@ impl WorkspaceCommandHelper { }; // Parse commit_summary template early to report error before starting // mutable operation. - helper.parse_operation_template(&helper.op_summary_template_text)?; - helper.parse_commit_template(&helper.commit_summary_template_text)?; - helper.parse_commit_template(SHORT_CHANGE_ID_TEMPLATE_TEXT)?; + helper.parse_operation_template(ui, &helper.op_summary_template_text)?; + helper.parse_commit_template(ui, &helper.commit_summary_template_text)?; + helper.parse_commit_template(ui, SHORT_CHANGE_ID_TEMPLATE_TEXT)?; Ok(helper) } @@ -1051,6 +1059,7 @@ impl WorkspaceCommandHelper { /// Parses the given strings as file patterns. pub fn parse_file_patterns( &self, + ui: &Ui, values: &[String], ) -> Result { // TODO: This function might be superseded by parse_union_filesets(), @@ -1059,7 +1068,7 @@ impl WorkspaceCommandHelper { if values.is_empty() { Ok(FilesetExpression::all()) } else if self.settings().config().get_bool("ui.allow-filesets")? { - self.parse_union_filesets(values) + self.parse_union_filesets(ui, values) } else { let expressions = values .iter() @@ -1073,6 +1082,7 @@ impl WorkspaceCommandHelper { /// Parses the given fileset expressions and concatenates them all. pub fn parse_union_filesets( &self, + _ui: &Ui, file_args: &[String], // TODO: introduce FileArg newtype? ) -> Result { let expressions: Vec<_> = file_args @@ -1082,7 +1092,7 @@ impl WorkspaceCommandHelper { Ok(FilesetExpression::union_all(expressions)) } - pub fn auto_tracking_matcher(&self) -> Result, CommandError> { + pub fn auto_tracking_matcher(&self, _ui: &Ui) -> Result, CommandError> { let pattern = self.settings().config().get_string("snapshot.auto-track")?; let expression = fileset::parse( &pattern, @@ -1223,8 +1233,12 @@ impl WorkspaceCommandHelper { /// Resolve a revset to a single revision. Return an error if the revset is /// empty or has multiple revisions. - pub fn resolve_single_rev(&self, revision_arg: &RevisionArg) -> Result { - let expression = self.parse_revset(revision_arg)?; + pub fn resolve_single_rev( + &self, + ui: &Ui, + revision_arg: &RevisionArg, + ) -> Result { + let expression = self.parse_revset(ui, revision_arg)?; let should_hint_about_all_prefix = false; revset_util::evaluate_revset_to_single_commit( revision_arg.as_ref(), @@ -1241,11 +1255,12 @@ impl WorkspaceCommandHelper { /// any number of revisions (including 0.) pub fn resolve_some_revsets_default_single( &self, + ui: &Ui, revision_args: &[RevisionArg], ) -> Result, CommandError> { let mut all_commits = IndexSet::new(); for revision_arg in revision_args { - let (expression, modifier) = self.parse_revset_with_modifier(revision_arg)?; + let (expression, modifier) = self.parse_revset_with_modifier(ui, revision_arg)?; let all = match modifier { Some(RevsetModifier::All) => true, None => self @@ -1282,9 +1297,10 @@ impl WorkspaceCommandHelper { pub fn parse_revset( &self, + ui: &Ui, revision_arg: &RevisionArg, ) -> Result, CommandError> { - let (expression, modifier) = self.parse_revset_with_modifier(revision_arg)?; + let (expression, modifier) = self.parse_revset_with_modifier(ui, revision_arg)?; // Whether the caller accepts multiple revisions or not, "all:" should // be valid. For example, "all:@" is a valid single-rev expression. let (None | Some(RevsetModifier::All)) = modifier; @@ -1293,6 +1309,7 @@ impl WorkspaceCommandHelper { fn parse_revset_with_modifier( &self, + _ui: &Ui, revision_arg: &RevisionArg, ) -> Result<(RevsetExpressionEvaluator<'_>, Option), CommandError> { let context = self.revset_parse_context(); @@ -1303,6 +1320,7 @@ impl WorkspaceCommandHelper { /// Parses the given revset expressions and concatenates them all. pub fn parse_union_revsets( &self, + _ui: &Ui, revision_args: &[RevisionArg], ) -> Result, CommandError> { let context = self.revset_parse_context(); @@ -1347,11 +1365,13 @@ impl WorkspaceCommandHelper { /// be one of the `L::wrap_*()` functions. pub fn parse_template<'a, C: Clone + 'a, L: TemplateLanguage<'a> + ?Sized>( &self, + ui: &Ui, language: &L, template_text: &str, wrap_self: impl Fn(PropertyPlaceholder) -> L::Property, ) -> TemplateParseResult> { - self.env.parse_template(language, template_text, wrap_self) + self.env + .parse_template(ui, language, template_text, wrap_self) } /// Parses template that is validated by `Self::new()`. @@ -1369,10 +1389,12 @@ impl WorkspaceCommandHelper { /// Parses commit template into evaluation tree. pub fn parse_commit_template( &self, + ui: &Ui, template_text: &str, ) -> TemplateParseResult> { let language = self.commit_template_language(); self.parse_template( + ui, &language, template_text, CommitTemplateLanguage::wrap_commit, @@ -1382,10 +1404,12 @@ impl WorkspaceCommandHelper { /// Parses commit template into evaluation tree. pub fn parse_operation_template( &self, + ui: &Ui, template_text: &str, ) -> TemplateParseResult> { let language = self.operation_template_language(); self.parse_template( + ui, &language, template_text, OperationTemplateLanguage::wrap_operation, @@ -1484,7 +1508,7 @@ impl WorkspaceCommandHelper { return Ok(()); }; let base_ignores = self.base_ignores()?; - let auto_tracking_matcher = self.auto_tracking_matcher()?; + let auto_tracking_matcher = self.auto_tracking_matcher(ui)?; // Compare working-copy tree and operation with repo's, and reload as needed. let fsmonitor_settings = self.settings().fsmonitor_settings()?; @@ -2003,10 +2027,12 @@ impl WorkspaceCommandTransaction<'_> { /// Parses commit template with the current transaction state. pub fn parse_commit_template( &self, + ui: &Ui, template_text: &str, ) -> TemplateParseResult> { let language = self.commit_template_language(); self.helper.env.parse_template( + ui, &language, template_text, CommitTemplateLanguage::wrap_commit, diff --git a/cli/src/commands/abandon.rs b/cli/src/commands/abandon.rs index f32357c23..a0a891738 100644 --- a/cli/src/commands/abandon.rs +++ b/cli/src/commands/abandon.rs @@ -53,7 +53,7 @@ pub(crate) fn cmd_abandon( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let to_abandon: Vec<_> = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commits()? .try_collect()?; if to_abandon.is_empty() { diff --git a/cli/src/commands/backout.rs b/cli/src/commands/backout.rs index 4c0941021..452c21eeb 100644 --- a/cli/src/commands/backout.rs +++ b/cli/src/commands/backout.rs @@ -43,7 +43,7 @@ pub(crate) fn cmd_backout( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let to_back_out: Vec<_> = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commits()? .try_collect()?; // in reverse topological order if to_back_out.is_empty() { @@ -52,7 +52,7 @@ pub(crate) fn cmd_backout( } let mut parents = vec![]; for revision_str in &args.destination { - let destination = workspace_command.resolve_single_rev(revision_str)?; + let destination = workspace_command.resolve_single_rev(ui, revision_str)?; parents.push(destination); } let mut tx = workspace_command.start_transaction(); diff --git a/cli/src/commands/bench.rs b/cli/src/commands/bench.rs index af8ac7916..48c98e350 100644 --- a/cli/src/commands/bench.rs +++ b/cli/src/commands/bench.rs @@ -143,8 +143,8 @@ pub(crate) fn cmd_bench( match subcommand { BenchCommand::CommonAncestors(args) => { let workspace_command = command.workspace_helper(ui)?; - let commit1 = workspace_command.resolve_single_rev(&args.revision1)?; - let commit2 = workspace_command.resolve_single_rev(&args.revision2)?; + let commit1 = workspace_command.resolve_single_rev(ui, &args.revision1)?; + let commit2 = workspace_command.resolve_single_rev(ui, &args.revision2)?; let index = workspace_command.repo().index(); let routine = || index.common_ancestors(&[commit1.id().clone()], &[commit2.id().clone()]); @@ -157,8 +157,8 @@ pub(crate) fn cmd_bench( } BenchCommand::IsAncestor(args) => { let workspace_command = command.workspace_helper(ui)?; - let ancestor_commit = workspace_command.resolve_single_rev(&args.ancestor)?; - let descendant_commit = workspace_command.resolve_single_rev(&args.descendant)?; + let ancestor_commit = workspace_command.resolve_single_rev(ui, &args.ancestor)?; + let descendant_commit = workspace_command.resolve_single_rev(ui, &args.descendant)?; let index = workspace_command.repo().index(); let routine = || index.is_ancestor(ancestor_commit.id(), descendant_commit.id()); run_bench( @@ -213,7 +213,12 @@ fn bench_revset( revset: &RevisionArg, ) -> Result<(), CommandError> { writeln!(ui.status(), "----------Testing revset: {revset}----------")?; - let expression = revset::optimize(workspace_command.parse_revset(revset)?.expression().clone()); + let expression = revset::optimize( + workspace_command + .parse_revset(ui, revset)? + .expression() + .clone(), + ); // Time both evaluation and iteration. let routine = |workspace_command: &WorkspaceCommandHelper, expression: Rc| { // Evaluate the expression without parsing/evaluating short-prefixes. diff --git a/cli/src/commands/bookmark/create.rs b/cli/src/commands/bookmark/create.rs index a7d60fbc2..ec1d7100e 100644 --- a/cli/src/commands/bookmark/create.rs +++ b/cli/src/commands/bookmark/create.rs @@ -44,8 +44,8 @@ pub fn cmd_bookmark_create( args: &BookmarkCreateArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let target_commit = - workspace_command.resolve_single_rev(args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; + let target_commit = workspace_command + .resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; let view = workspace_command.repo().view(); let bookmark_names = &args.names; for name in bookmark_names { diff --git a/cli/src/commands/bookmark/list.rs b/cli/src/commands/bookmark/list.rs index 6c230b80b..da2eececc 100644 --- a/cli/src/commands/bookmark/list.rs +++ b/cli/src/commands/bookmark/list.rs @@ -96,7 +96,7 @@ pub fn cmd_bookmark_list( } if !args.revisions.is_empty() { // Match against local targets only, which is consistent with "jj git push". - let mut expression = workspace_command.parse_union_revsets(&args.revisions)?; + let mut expression = workspace_command.parse_union_revsets(ui, &args.revisions)?; // Intersects with the set of local bookmark targets to minimize the lookup // space. expression.intersect_with(&RevsetExpression::bookmarks(StringPattern::everything())); @@ -121,7 +121,7 @@ pub fn cmd_bookmark_list( None => command.settings().config().get("templates.bookmark_list")?, }; workspace_command - .parse_template(&language, &text, CommitTemplateLanguage::wrap_ref_name)? + .parse_template(ui, &language, &text, CommitTemplateLanguage::wrap_ref_name)? .labeled("bookmark_list") }; diff --git a/cli/src/commands/bookmark/move.rs b/cli/src/commands/bookmark/move.rs index bcc7d85f0..8a9507331 100644 --- a/cli/src/commands/bookmark/move.rs +++ b/cli/src/commands/bookmark/move.rs @@ -70,11 +70,11 @@ pub fn cmd_bookmark_move( let mut workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo().clone(); - let target_commit = workspace_command.resolve_single_rev(&args.to)?; + let target_commit = workspace_command.resolve_single_rev(ui, &args.to)?; let matched_bookmarks = { let is_source_commit = if !args.from.is_empty() { workspace_command - .parse_union_revsets(&args.from)? + .parse_union_revsets(ui, &args.from)? .evaluate()? .containing_fn() } else { diff --git a/cli/src/commands/bookmark/set.rs b/cli/src/commands/bookmark/set.rs index b87ea81e3..8207246e1 100644 --- a/cli/src/commands/bookmark/set.rs +++ b/cli/src/commands/bookmark/set.rs @@ -46,8 +46,8 @@ pub fn cmd_bookmark_set( args: &BookmarkSetArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let target_commit = - workspace_command.resolve_single_rev(args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; + let target_commit = workspace_command + .resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; let repo = workspace_command.repo().as_ref(); let bookmark_names = &args.names; let mut new_bookmark_count = 0; diff --git a/cli/src/commands/bookmark/track.rs b/cli/src/commands/bookmark/track.rs index c8849c28a..807a8c615 100644 --- a/cli/src/commands/bookmark/track.rs +++ b/cli/src/commands/bookmark/track.rs @@ -87,7 +87,7 @@ pub fn cmd_bookmark_track( .config() .get::("templates.bookmark_list")?; workspace_command - .parse_template(&language, &text, CommitTemplateLanguage::wrap_ref_name)? + .parse_template(ui, &language, &text, CommitTemplateLanguage::wrap_ref_name)? .labeled("bookmark_list") }; diff --git a/cli/src/commands/checkout.rs b/cli/src/commands/checkout.rs index 56217eda3..2918f20ea 100644 --- a/cli/src/commands/checkout.rs +++ b/cli/src/commands/checkout.rs @@ -53,7 +53,7 @@ pub(crate) fn cmd_checkout( "`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(&args.revision)?; + let target = workspace_command.resolve_single_rev(ui, &args.revision)?; let mut tx = workspace_command.start_transaction(); let commit_builder = tx .repo_mut() diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index 978a0c4ae..01b7ee2c1 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -65,7 +65,7 @@ pub(crate) fn cmd_commit( .ok_or_else(|| user_error("This command requires a working copy"))?; let commit = workspace_command.repo().store().get_commit(commit_id)?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let advanceable_bookmarks = workspace_command.get_advanceable_bookmarks(commit.parent_ids())?; let diff_selector = @@ -114,7 +114,7 @@ new working-copy commit. commit_builder.set_description(command.settings().default_description()); } let temp_commit = commit_builder.write_hidden()?; - let template = description_template(&tx, "", &temp_commit)?; + let template = description_template(ui, &tx, "", &temp_commit)?; edit_description(tx.base_workspace_helper(), &template, command.settings())? }; commit_builder.set_description(description); diff --git a/cli/src/commands/debug/copy_detection.rs b/cli/src/commands/debug/copy_detection.rs index c8ddac1ed..5aecc7dc9 100644 --- a/cli/src/commands/debug/copy_detection.rs +++ b/cli/src/commands/debug/copy_detection.rs @@ -42,7 +42,7 @@ pub fn cmd_debug_copy_detection( writeln!(ui.stderr(), "Not a git backend.")?; return Ok(()); }; - let commit = ws.resolve_single_rev(&args.revision)?; + let commit = ws.resolve_single_rev(ui, &args.revision)?; for parent_id in commit.parent_ids() { for CopyRecord { target, source, .. } in block_on_stream(git.get_copy_records(None, parent_id, commit.id())?) diff --git a/cli/src/commands/debug/tree.rs b/cli/src/commands/debug/tree.rs index bf5e5fdde..7c40d33b5 100644 --- a/cli/src/commands/debug/tree.rs +++ b/cli/src/commands/debug/tree.rs @@ -58,11 +58,11 @@ pub fn cmd_debug_tree( MergedTree::resolved(tree) } else { let commit = workspace_command - .resolve_single_rev(args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; + .resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; commit.tree()? }; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); for (path, value) in tree.entries_matching(matcher.as_ref()) { let ui_path = workspace_command.format_file_path(&path); diff --git a/cli/src/commands/describe.rs b/cli/src/commands/describe.rs index 2c0f1daeb..2391a523f 100644 --- a/cli/src/commands/describe.rs +++ b/cli/src/commands/describe.rs @@ -82,7 +82,7 @@ pub(crate) fn cmd_describe( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let commits: Vec<_> = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commits()? .try_collect()?; // in reverse topological order if commits.is_empty() { @@ -145,7 +145,7 @@ pub(crate) fn cmd_describe( .try_collect()?; if let [(_, temp_commit)] = &*temp_commits { - let template = description_template(&tx, "", temp_commit)?; + let template = description_template(ui, &tx, "", temp_commit)?; let description = edit_description(tx.base_workspace_helper(), &template, command.settings())?; @@ -156,7 +156,7 @@ pub(crate) fn cmd_describe( missing, duplicates, unexpected, - } = edit_multiple_descriptions(&tx, &temp_commits, command.settings())?; + } = edit_multiple_descriptions(ui, &tx, &temp_commits, command.settings())?; if !missing.is_empty() { return Err(user_error(format!( "The description for the following commits were not found in the edited \ diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index ad8204811..582d0b0e9 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -67,10 +67,10 @@ pub(crate) fn cmd_diff( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo(); - let fileset_expression = workspace_command.parse_file_patterns(&args.paths)?; + let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?; let matcher = fileset_expression.to_matcher(); let resolve_revision = |r: &Option| { - workspace_command.resolve_single_rev(r.as_ref().unwrap_or(&RevisionArg::AT)) + workspace_command.resolve_single_rev(ui, r.as_ref().unwrap_or(&RevisionArg::AT)) }; let from_tree; diff --git a/cli/src/commands/diffedit.rs b/cli/src/commands/diffedit.rs index d5f52b69d..10d89e5ef 100644 --- a/cli/src/commands/diffedit.rs +++ b/cli/src/commands/diffedit.rs @@ -76,18 +76,17 @@ pub(crate) fn cmd_diffedit( let (target_commit, base_commits, diff_description); if args.from.is_some() || args.to.is_some() { - target_commit = - workspace_command.resolve_single_rev(args.to.as_ref().unwrap_or(&RevisionArg::AT))?; - base_commits = - vec![workspace_command - .resolve_single_rev(args.from.as_ref().unwrap_or(&RevisionArg::AT))?]; + target_commit = workspace_command + .resolve_single_rev(ui, args.to.as_ref().unwrap_or(&RevisionArg::AT))?; + base_commits = vec![workspace_command + .resolve_single_rev(ui, args.from.as_ref().unwrap_or(&RevisionArg::AT))?]; diff_description = format!( "The diff initially shows the commit's changes relative to:\n{}", workspace_command.format_commit_summary(&base_commits[0]) ); } else { target_commit = workspace_command - .resolve_single_rev(args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; + .resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; base_commits = target_commit.parents().try_collect()?; diff_description = "The diff initially shows the commit's changes.".to_string(); }; diff --git a/cli/src/commands/duplicate.rs b/cli/src/commands/duplicate.rs index 667348f64..7ae929f74 100644 --- a/cli/src/commands/duplicate.rs +++ b/cli/src/commands/duplicate.rs @@ -46,7 +46,7 @@ pub(crate) fn cmd_duplicate( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let to_duplicate: Vec = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commit_ids()? .collect(); // in reverse topological order if to_duplicate.is_empty() { diff --git a/cli/src/commands/edit.rs b/cli/src/commands/edit.rs index 609c0bc95..84fbada99 100644 --- a/cli/src/commands/edit.rs +++ b/cli/src/commands/edit.rs @@ -44,7 +44,7 @@ pub(crate) fn cmd_edit( args: &EditArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let new_commit = workspace_command.resolve_single_rev(&args.revision)?; + let new_commit = workspace_command.resolve_single_rev(ui, &args.revision)?; workspace_command.check_rewritable([new_commit.id()])?; if workspace_command.get_wc_commit_id() == Some(new_commit.id()) { writeln!(ui.status(), "Already editing that commit")?; diff --git a/cli/src/commands/evolog.rs b/cli/src/commands/evolog.rs index b60c452b4..3a2327ecf 100644 --- a/cli/src/commands/evolog.rs +++ b/cli/src/commands/evolog.rs @@ -77,7 +77,7 @@ pub(crate) fn cmd_evolog( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; - let start_commit = workspace_command.resolve_single_rev(&args.revision)?; + let start_commit = workspace_command.resolve_single_rev(ui, &args.revision)?; let diff_renderer = workspace_command.diff_renderer_for_log(&args.diff_format, args.patch)?; let graph_style = GraphStyle::from_settings(command.settings())?; @@ -93,6 +93,7 @@ pub(crate) fn cmd_evolog( }; template = workspace_command .parse_template( + ui, &language, &template_string, CommitTemplateLanguage::wrap_commit, @@ -100,6 +101,7 @@ pub(crate) fn cmd_evolog( .labeled("log"); node_template = workspace_command .parse_template( + ui, &language, &get_node_template(graph_style, command.settings())?, CommitTemplateLanguage::wrap_commit_opt, diff --git a/cli/src/commands/file/chmod.rs b/cli/src/commands/file/chmod.rs index dc56683db..9f90a282f 100644 --- a/cli/src/commands/file/chmod.rs +++ b/cli/src/commands/file/chmod.rs @@ -62,12 +62,12 @@ pub(crate) fn cmd_file_chmod( }; let mut workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; workspace_command.check_rewritable([commit.id()])?; let tree = commit.tree()?; // TODO: No need to add special case for empty paths when switching to // parse_union_filesets(). paths = [] should be "none()" if supported. - let fileset_expression = workspace_command.parse_file_patterns(&args.paths)?; + let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?; let matcher = fileset_expression.to_matcher(); print_unmatched_explicit_paths(ui, &workspace_command, &fileset_expression, [&tree])?; diff --git a/cli/src/commands/file/list.rs b/cli/src/commands/file/list.rs index 634157d2e..8c0268b22 100644 --- a/cli/src/commands/file/list.rs +++ b/cli/src/commands/file/list.rs @@ -39,10 +39,10 @@ pub(crate) fn cmd_file_list( args: &FileListArgs, ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; let tree = commit.tree()?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); ui.request_pager(); for (name, _value) in tree.entries_matching(matcher.as_ref()) { diff --git a/cli/src/commands/file/show.rs b/cli/src/commands/file/show.rs index 04f65be13..14482bc3d 100644 --- a/cli/src/commands/file/show.rs +++ b/cli/src/commands/file/show.rs @@ -56,11 +56,11 @@ pub(crate) fn cmd_file_show( args: &FileShowArgs, ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; let tree = commit.tree()?; // TODO: No need to add special case for empty paths when switching to // parse_union_filesets(). paths = [] should be "none()" if supported. - let fileset_expression = workspace_command.parse_file_patterns(&args.paths)?; + let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?; // Try fast path for single file entry if let Some(path) = get_single_path(&fileset_expression) { diff --git a/cli/src/commands/file/track.rs b/cli/src/commands/file/track.rs index d6110ecb1..4b2e2072b 100644 --- a/cli/src/commands/file/track.rs +++ b/cli/src/commands/file/track.rs @@ -45,7 +45,7 @@ pub(crate) fn cmd_file_track( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let mut tx = workspace_command.start_transaction().into_inner(); diff --git a/cli/src/commands/file/untrack.rs b/cli/src/commands/file/untrack.rs index cb720126a..97752226b 100644 --- a/cli/src/commands/file/untrack.rs +++ b/cli/src/commands/file/untrack.rs @@ -46,12 +46,12 @@ pub(crate) fn cmd_file_untrack( let mut workspace_command = command.workspace_helper(ui)?; let store = workspace_command.repo().store().clone(); let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let mut tx = workspace_command.start_transaction().into_inner(); let base_ignores = workspace_command.base_ignores()?; - let auto_tracking_matcher = workspace_command.auto_tracking_matcher()?; + let auto_tracking_matcher = workspace_command.auto_tracking_matcher(ui)?; let (mut locked_ws, wc_commit) = workspace_command.start_working_copy_mutation()?; // Create a new tree without the unwanted files let mut tree_builder = MergedTreeBuilder::new(wc_commit.tree_id().clone()); diff --git a/cli/src/commands/fix.rs b/cli/src/commands/fix.rs index 09accd64b..b098e602e 100644 --- a/cli/src/commands/fix.rs +++ b/cli/src/commands/fix.rs @@ -142,17 +142,16 @@ pub(crate) fn cmd_fix( let mut workspace_command = command.workspace_helper(ui)?; let tools_config = get_tools_config(ui, command.settings().config())?; let root_commits: Vec = if args.source.is_empty() { - workspace_command.parse_revset(&RevisionArg::from( - command.settings().config().get_string("revsets.fix")?, - ))? + let revs = command.settings().config().get_string("revsets.fix")?; + workspace_command.parse_revset(ui, &RevisionArg::from(revs))? } else { - workspace_command.parse_union_revsets(&args.source)? + workspace_command.parse_union_revsets(ui, &args.source)? } .evaluate_to_commit_ids()? .collect(); workspace_command.check_rewritable(root_commits.iter())?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let mut tx = workspace_command.start_transaction(); diff --git a/cli/src/commands/git/push.rs b/cli/src/commands/git/push.rs index 19aaa92f9..bcfd04702 100644 --- a/cli/src/commands/git/push.rs +++ b/cli/src/commands/git/push.rs @@ -263,7 +263,7 @@ pub fn cmd_git_push( return Ok(()); } - validate_commits_ready_to_push(&bookmark_updates, &remote, &tx, command, args)?; + validate_commits_ready_to_push(ui, &bookmark_updates, &remote, &tx, command, args)?; if let Some(mut formatter) = ui.status_formatter() { writeln!(formatter, "Changes to push to {remote}:")?; print_commits_ready_to_push(formatter.as_mut(), repo.as_ref(), &bookmark_updates)?; @@ -305,6 +305,7 @@ pub fn cmd_git_push( /// Validates that the commits that will be pushed are ready (have authorship /// information, are not conflicted, etc.) fn validate_commits_ready_to_push( + ui: &Ui, bookmark_updates: &[(String, BookmarkPushUpdate)], remote: &str, tx: &WorkspaceCommandTransaction, @@ -331,7 +332,7 @@ fn validate_commits_ready_to_push( let config = command.settings().config(); let is_private = if let Ok(revset) = config.get_string("git.private-commits") { workspace_helper - .parse_revset(&RevisionArg::from(revset))? + .parse_revset(ui, &RevisionArg::from(revset))? .evaluate()? .containing_fn() } else { @@ -528,7 +529,7 @@ fn update_change_bookmarks( let mut bookmark_names = Vec::new(); let workspace_command = tx.base_workspace_helper(); - let all_commits = workspace_command.resolve_some_revsets_default_single(changes)?; + let all_commits = workspace_command.resolve_some_revsets_default_single(ui, changes)?; for commit in all_commits { let workspace_command = tx.base_workspace_helper(); @@ -539,7 +540,7 @@ fn update_change_bookmarks( // A local bookmark with the full change ID doesn't exist already, so use the // short ID if it's not ambiguous (which it shouldn't be most of the time). if workspace_command - .resolve_single_rev(&RevisionArg::from(short_change_id.clone())) + .resolve_single_rev(ui, &RevisionArg::from(short_change_id.clone())) .is_ok() { // Short change ID is not ambiguous, so update the bookmark name to use it. @@ -621,7 +622,7 @@ fn find_bookmarks_targeted_by_revisions<'a>( } } for rev_arg in revisions { - let mut expression = workspace_command.parse_revset(rev_arg)?; + let mut expression = workspace_command.parse_revset(ui, rev_arg)?; expression.intersect_with(&RevsetExpression::bookmarks(StringPattern::everything())); let mut commit_ids = expression.evaluate_to_commit_ids()?.peekable(); if commit_ids.peek().is_none() { diff --git a/cli/src/commands/git/submodule.rs b/cli/src/commands/git/submodule.rs index c0a42940f..c9e81a734 100644 --- a/cli/src/commands/git/submodule.rs +++ b/cli/src/commands/git/submodule.rs @@ -63,7 +63,7 @@ fn cmd_submodule_print( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo(); - let commit = workspace_command.resolve_single_rev(&args.revisions)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revisions)?; let tree = commit.tree()?; let gitmodules_path = RepoPath::from_internal_string(".gitmodules"); let mut gitmodules_file = match tree.path_value(gitmodules_path)?.into_resolved() { diff --git a/cli/src/commands/interdiff.rs b/cli/src/commands/interdiff.rs index b93b711eb..adbf13bc7 100644 --- a/cli/src/commands/interdiff.rs +++ b/cli/src/commands/interdiff.rs @@ -52,10 +52,11 @@ pub(crate) fn cmd_interdiff( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let from = - workspace_command.resolve_single_rev(args.from.as_ref().unwrap_or(&RevisionArg::AT))?; - let to = workspace_command.resolve_single_rev(args.to.as_ref().unwrap_or(&RevisionArg::AT))?; + 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(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let diff_renderer = workspace_command.diff_renderer_for(&args.format)?; ui.request_pager(); diff --git a/cli/src/commands/log.rs b/cli/src/commands/log.rs index f7cdca960..0daf0c24a 100644 --- a/cli/src/commands/log.rs +++ b/cli/src/commands/log.rs @@ -93,14 +93,14 @@ pub(crate) fn cmd_log( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; - let fileset_expression = workspace_command.parse_file_patterns(&args.paths)?; + let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?; let revset_expression = { // only use default revset if neither revset nor path are specified let mut expression = if args.revisions.is_empty() && args.paths.is_empty() { workspace_command - .parse_revset(&RevisionArg::from(command.settings().default_revset()))? + .parse_revset(ui, &RevisionArg::from(command.settings().default_revset()))? } else if !args.revisions.is_empty() { - workspace_command.parse_union_revsets(&args.revisions)? + workspace_command.parse_union_revsets(ui, &args.revisions)? } else { // a path was specified so we use all() and add path filter later workspace_command.attach_revset_evaluator(RevsetExpression::all()) @@ -138,6 +138,7 @@ pub(crate) fn cmd_log( }; template = workspace_command .parse_template( + ui, &language, &template_string, CommitTemplateLanguage::wrap_commit, @@ -145,6 +146,7 @@ pub(crate) fn cmd_log( .labeled("log"); node_template = workspace_command .parse_template( + ui, &language, &get_node_template(graph_style, command.settings())?, CommitTemplateLanguage::wrap_commit_opt, @@ -281,7 +283,7 @@ pub(crate) fn cmd_log( )?; } else if revset.is_empty() && workspace_command - .parse_revset(&RevisionArg::from(only_path.to_owned())) + .parse_revset(ui, &RevisionArg::from(only_path.to_owned())) .is_ok() { writeln!( diff --git a/cli/src/commands/move.rs b/cli/src/commands/move.rs index 989ea1cc6..157ee4c16 100644 --- a/cli/src/commands/move.rs +++ b/cli/src/commands/move.rs @@ -75,14 +75,14 @@ pub(crate) fn cmd_move( )?; let mut workspace_command = command.workspace_helper(ui)?; let source = - workspace_command.resolve_single_rev(args.from.as_ref().unwrap_or(&RevisionArg::AT))?; + workspace_command.resolve_single_rev(ui, args.from.as_ref().unwrap_or(&RevisionArg::AT))?; let destination = - workspace_command.resolve_single_rev(args.to.as_ref().unwrap_or(&RevisionArg::AT))?; + workspace_command.resolve_single_rev(ui, args.to.as_ref().unwrap_or(&RevisionArg::AT))?; if source.id() == destination.id() { return Err(user_error("Source and destination cannot be the same.")); } let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let diff_selector = workspace_command.diff_selector(ui, args.tool.as_deref(), args.interactive)?; diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index 5eb4592b2..70a30cab7 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -97,12 +97,12 @@ pub(crate) fn cmd_new( if !args.insert_before.is_empty() && !args.insert_after.is_empty() { parent_commits = workspace_command - .resolve_some_revsets_default_single(&args.insert_after)? + .resolve_some_revsets_default_single(ui, &args.insert_after)? .into_iter() .collect_vec(); parent_commit_ids = parent_commits.iter().ids().cloned().collect(); children_commits = workspace_command - .resolve_some_revsets_default_single(&args.insert_before)? + .resolve_some_revsets_default_single(ui, &args.insert_before)? .into_iter() .collect_vec(); let children_commit_ids = children_commits.iter().ids().cloned().collect(); @@ -119,7 +119,7 @@ pub(crate) fn cmd_new( // The parents of the new commit will be the parents of the target commits // which are not descendants of other target commits. children_commits = workspace_command - .resolve_some_revsets_default_single(&args.insert_before)? + .resolve_some_revsets_default_single(ui, &args.insert_before)? .into_iter() .collect_vec(); let children_commit_ids = children_commits.iter().ids().cloned().collect(); @@ -144,7 +144,7 @@ pub(crate) fn cmd_new( .try_collect()?; } else if !args.insert_after.is_empty() { parent_commits = workspace_command - .resolve_some_revsets_default_single(&args.insert_after)? + .resolve_some_revsets_default_single(ui, &args.insert_after)? .into_iter() .collect_vec(); parent_commit_ids = parent_commits.iter().ids().cloned().collect(); @@ -162,7 +162,7 @@ pub(crate) fn cmd_new( .try_collect()?; } else { parent_commits = workspace_command - .resolve_some_revsets_default_single(&args.revisions)? + .resolve_some_revsets_default_single(ui, &args.revisions)? .into_iter() .collect_vec(); parent_commit_ids = parent_commits.iter().ids().cloned().collect(); diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index 813f028c6..84642bfca 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -119,7 +119,7 @@ pub fn cmd_op_diff( .settings() .config() .get_string("templates.commit_summary")?; - workspace_env.parse_template(&language, &text, CommitTemplateLanguage::wrap_commit)? + workspace_env.parse_template(ui, &language, &text, CommitTemplateLanguage::wrap_commit)? }; let op_summary_template = workspace_command.operation_summary_template(); diff --git a/cli/src/commands/operation/log.rs b/cli/src/commands/operation/log.rs index aabba7087..0c422dc3e 100644 --- a/cli/src/commands/operation/log.rs +++ b/cli/src/commands/operation/log.rs @@ -124,10 +124,16 @@ fn do_op_log( None => settings.config().get_string("templates.op_log")?, }; template = workspace_env - .parse_template(&language, &text, OperationTemplateLanguage::wrap_operation)? + .parse_template( + ui, + &language, + &text, + OperationTemplateLanguage::wrap_operation, + )? .labeled("op_log"); op_node_template = workspace_env .parse_template( + ui, &language, &get_node_template(graph_style, settings)?, OperationTemplateLanguage::wrap_operation, @@ -152,6 +158,7 @@ fn do_op_log( let language = workspace_env.commit_template_language(repo.as_ref(), &id_prefix_context); workspace_env.parse_template( + ui, &language, &template_text, CommitTemplateLanguage::wrap_commit, diff --git a/cli/src/commands/operation/show.rs b/cli/src/commands/operation/show.rs index cdfb35f26..bc67e19b2 100644 --- a/cli/src/commands/operation/show.rs +++ b/cli/src/commands/operation/show.rs @@ -66,7 +66,7 @@ pub fn cmd_op_show( .settings() .config() .get_string("templates.commit_summary")?; - workspace_env.parse_template(&language, &text, CommitTemplateLanguage::wrap_commit)? + workspace_env.parse_template(ui, &language, &text, CommitTemplateLanguage::wrap_commit)? }; let graph_style = GraphStyle::from_settings(command.settings())?; @@ -81,7 +81,7 @@ pub fn cmd_op_show( let template = { let text = command.settings().config().get_string("templates.op_log")?; workspace_command - .parse_operation_template(&text)? + .parse_operation_template(ui, &text)? .labeled("op_log") }; diff --git a/cli/src/commands/parallelize.rs b/cli/src/commands/parallelize.rs index db3b707c9..3971e0c82 100644 --- a/cli/src/commands/parallelize.rs +++ b/cli/src/commands/parallelize.rs @@ -68,7 +68,7 @@ pub(crate) fn cmd_parallelize( // The target commits are the commits being parallelized. They are ordered // here with children before parents. let target_commits: Vec = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commits()? .try_collect()?; workspace_command.check_rewritable(target_commits.iter().ids())?; diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index a95db5187..2fcc3f598 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -246,14 +246,14 @@ pub(crate) fn cmd_rebase( "clap should forbid `-r --skip-empty`" ); let target_commits: Vec<_> = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commits()? .try_collect()?; // in reverse topological order if !args.insert_after.is_empty() && !args.insert_before.is_empty() { let after_commits = - workspace_command.resolve_some_revsets_default_single(&args.insert_after)?; + workspace_command.resolve_some_revsets_default_single(ui, &args.insert_after)?; let before_commits = - workspace_command.resolve_some_revsets_default_single(&args.insert_before)?; + workspace_command.resolve_some_revsets_default_single(ui, &args.insert_before)?; rebase_revisions_after_before( ui, command.settings(), @@ -264,7 +264,7 @@ pub(crate) fn cmd_rebase( )?; } else if !args.insert_after.is_empty() { let after_commits = - workspace_command.resolve_some_revsets_default_single(&args.insert_after)?; + workspace_command.resolve_some_revsets_default_single(ui, &args.insert_after)?; rebase_revisions_after( ui, command.settings(), @@ -274,7 +274,7 @@ pub(crate) fn cmd_rebase( )?; } else if !args.insert_before.is_empty() { let before_commits = - workspace_command.resolve_some_revsets_default_single(&args.insert_before)?; + workspace_command.resolve_some_revsets_default_single(ui, &args.insert_before)?; rebase_revisions_before( ui, command.settings(), @@ -284,7 +284,7 @@ pub(crate) fn cmd_rebase( )?; } else { let new_parents = workspace_command - .resolve_some_revsets_default_single(&args.destination)? + .resolve_some_revsets_default_single(ui, &args.destination)? .into_iter() .collect_vec(); rebase_revisions( @@ -297,10 +297,11 @@ pub(crate) fn cmd_rebase( } } else if !args.source.is_empty() { let new_parents = workspace_command - .resolve_some_revsets_default_single(&args.destination)? + .resolve_some_revsets_default_single(ui, &args.destination)? .into_iter() .collect_vec(); - let source_commits = workspace_command.resolve_some_revsets_default_single(&args.source)?; + let source_commits = + workspace_command.resolve_some_revsets_default_single(ui, &args.source)?; rebase_descendants_transaction( ui, command.settings(), @@ -311,13 +312,13 @@ pub(crate) fn cmd_rebase( )?; } else { let new_parents = workspace_command - .resolve_some_revsets_default_single(&args.destination)? + .resolve_some_revsets_default_single(ui, &args.destination)? .into_iter() .collect_vec(); let branch_commits = if args.branch.is_empty() { - IndexSet::from([workspace_command.resolve_single_rev(&RevisionArg::AT)?]) + IndexSet::from([workspace_command.resolve_single_rev(ui, &RevisionArg::AT)?]) } else { - workspace_command.resolve_some_revsets_default_single(&args.branch)? + workspace_command.resolve_some_revsets_default_single(ui, &args.branch)? }; rebase_branch( ui, diff --git a/cli/src/commands/resolve.rs b/cli/src/commands/resolve.rs index 726426695..9cce2cd58 100644 --- a/cli/src/commands/resolve.rs +++ b/cli/src/commands/resolve.rs @@ -68,9 +68,9 @@ pub(crate) fn cmd_resolve( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; let tree = commit.tree()?; let conflicts = tree .conflicts() diff --git a/cli/src/commands/restore.rs b/cli/src/commands/restore.rs index 00dac55e4..716dc8569 100644 --- a/cli/src/commands/restore.rs +++ b/cli/src/commands/restore.rs @@ -88,20 +88,20 @@ pub(crate) fn cmd_restore( )); } if args.from.is_some() || args.to.is_some() { - to_commit = - workspace_command.resolve_single_rev(args.to.as_ref().unwrap_or(&RevisionArg::AT))?; + to_commit = workspace_command + .resolve_single_rev(ui, args.to.as_ref().unwrap_or(&RevisionArg::AT))?; from_tree = workspace_command - .resolve_single_rev(args.from.as_ref().unwrap_or(&RevisionArg::AT))? + .resolve_single_rev(ui, args.from.as_ref().unwrap_or(&RevisionArg::AT))? .tree()?; } else { to_commit = workspace_command - .resolve_single_rev(args.changes_in.as_ref().unwrap_or(&RevisionArg::AT))?; + .resolve_single_rev(ui, args.changes_in.as_ref().unwrap_or(&RevisionArg::AT))?; from_tree = to_commit.parent_tree(workspace_command.repo().as_ref())?; } workspace_command.check_rewritable([to_commit.id()])?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let to_tree = to_commit.tree()?; let new_tree_id = restore_tree(&from_tree, &to_tree, matcher.as_ref())?; diff --git a/cli/src/commands/run.rs b/cli/src/commands/run.rs index 2a15607bb..0cabb833f 100644 --- a/cli/src/commands/run.rs +++ b/cli/src/commands/run.rs @@ -53,7 +53,7 @@ pub struct RunArgs { pub fn cmd_run(ui: &mut Ui, command: &CommandHelper, args: &RunArgs) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let _resolved_commits: Vec<_> = workspace_command - .parse_union_revsets(&args.revisions)? + .parse_union_revsets(ui, &args.revisions)? .evaluate_to_commits()? .try_collect()?; // Jobs are resolved in this order: diff --git a/cli/src/commands/show.rs b/cli/src/commands/show.rs index df0783ecf..e363d66b7 100644 --- a/cli/src/commands/show.rs +++ b/cli/src/commands/show.rs @@ -46,12 +46,12 @@ pub(crate) fn cmd_show( args: &ShowArgs, ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; let template_string = match &args.template { Some(value) => value.to_string(), None => command.settings().config().get_string("templates.show")?, }; - let template = workspace_command.parse_commit_template(&template_string)?; + let template = workspace_command.parse_commit_template(ui, &template_string)?; let diff_renderer = workspace_command.diff_renderer_for(&args.format)?; ui.request_pager(); let mut formatter = ui.stdout_formatter(); diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index 514757071..496172dac 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -71,7 +71,7 @@ pub(crate) fn cmd_split( args: &SplitArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; if commit.is_empty(workspace_command.repo().as_ref())? { return Err(user_error_with_hint( format!("Refusing to split empty commit {}.", commit.id().hex()), @@ -81,7 +81,7 @@ pub(crate) fn cmd_split( workspace_command.check_rewritable([commit.id()])?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let diff_selector = workspace_command.diff_selector( ui, @@ -136,6 +136,7 @@ the operation will be aborted. } let temp_commit = commit_builder.write_hidden()?; let template = description_template( + ui, &tx, "Enter a description for the first commit.", &temp_commit, @@ -179,6 +180,7 @@ the operation will be aborted. } else { let temp_commit = commit_builder.write_hidden()?; let template = description_template( + ui, &tx, "Enter a description for the second commit.", &temp_commit, diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index 794466524..8d54a62fa 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -98,14 +98,14 @@ pub(crate) fn cmd_squash( let destination; if !args.from.is_empty() || args.into.is_some() { sources = if args.from.is_empty() { - workspace_command.parse_revset(&RevisionArg::AT)? + workspace_command.parse_revset(ui, &RevisionArg::AT)? } else { - workspace_command.parse_union_revsets(&args.from)? + workspace_command.parse_union_revsets(ui, &args.from)? } .evaluate_to_commits()? .try_collect()?; - destination = - workspace_command.resolve_single_rev(args.into.as_ref().unwrap_or(&RevisionArg::AT))?; + destination = workspace_command + .resolve_single_rev(ui, args.into.as_ref().unwrap_or(&RevisionArg::AT))?; if sources.iter().any(|source| source.id() == destination.id()) { return Err(user_error("Source and destination cannot be the same")); } @@ -115,7 +115,7 @@ pub(crate) fn cmd_squash( sources.reverse(); } else { let source = workspace_command - .resolve_single_rev(args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; + .resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?; let mut parents: Vec<_> = source.parents().try_collect()?; if parents.len() != 1 { return Err(user_error_with_hint( @@ -128,7 +128,7 @@ pub(crate) fn cmd_squash( } let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); let diff_selector = workspace_command.diff_selector(ui, args.tool.as_deref(), args.interactive)?; @@ -252,7 +252,7 @@ from the source will be moved into the destination. if no_rev_arg && tx .base_workspace_helper() - .parse_revset(&RevisionArg::from(only_path.to_owned())) + .parse_revset(ui, &RevisionArg::from(only_path.to_owned())) .is_ok() { writeln!( diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index f413ce5d6..7945294b5 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -54,7 +54,7 @@ pub(crate) fn cmd_status( .map(|id| repo.store().get_commit(id)) .transpose()?; let matcher = workspace_command - .parse_file_patterns(&args.paths)? + .parse_file_patterns(ui, &args.paths)? .to_matcher(); ui.request_pager(); let mut formatter = ui.stdout_formatter(); diff --git a/cli/src/commands/tag.rs b/cli/src/commands/tag.rs index 8289d5c51..345169e38 100644 --- a/cli/src/commands/tag.rs +++ b/cli/src/commands/tag.rs @@ -72,7 +72,7 @@ fn cmd_tag_list( None => command.settings().config().get("templates.tag_list")?, }; workspace_command - .parse_template(&language, &text, CommitTemplateLanguage::wrap_ref_name)? + .parse_template(ui, &language, &text, CommitTemplateLanguage::wrap_ref_name)? .labeled("tag_list") }; diff --git a/cli/src/commands/unsquash.rs b/cli/src/commands/unsquash.rs index eb11a7a07..8368b2087 100644 --- a/cli/src/commands/unsquash.rs +++ b/cli/src/commands/unsquash.rs @@ -57,7 +57,7 @@ pub(crate) fn cmd_unsquash( args: &UnsquashArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; workspace_command.check_rewritable([commit.id()])?; if commit.parent_ids().len() > 1 { return Err(user_error("Cannot unsquash merge commits")); diff --git a/cli/src/commands/workspace/add.rs b/cli/src/commands/workspace/add.rs index 96d3d7572..0d61d99b5 100644 --- a/cli/src/commands/workspace/add.rs +++ b/cli/src/commands/workspace/add.rs @@ -177,7 +177,7 @@ pub fn cmd_workspace_add( } } else { old_workspace_command - .resolve_some_revsets_default_single(&args.revision)? + .resolve_some_revsets_default_single(ui, &args.revision)? .into_iter() .collect_vec() }; diff --git a/cli/src/description_util.rs b/cli/src/description_util.rs index 6d14d1c62..113780fd3 100644 --- a/cli/src/description_util.rs +++ b/cli/src/description_util.rs @@ -17,6 +17,7 @@ use crate::cli_util::WorkspaceCommandTransaction; use crate::command_error::CommandError; use crate::formatter::PlainTextFormatter; use crate::text_util; +use crate::ui::Ui; /// Cleanup a description by normalizing line endings, and removing leading and /// trailing blank lines. @@ -57,6 +58,7 @@ JJ: Lines starting with "JJ: " (like this one) will be removed. /// Edits the descriptions of the given commits in a single editor session. pub fn edit_multiple_descriptions( + ui: &Ui, tx: &WorkspaceCommandTransaction, commits: &[(&CommitId, Commit)], settings: &UserSettings, @@ -77,7 +79,7 @@ pub fn edit_multiple_descriptions( bulk_message.push_str(&commit_hash); bulk_message.push_str(" -------\n"); commits_map.insert(commit_hash, *commit_id); - let template = description_template(tx, "", temp_commit)?; + let template = description_template(ui, tx, "", temp_commit)?; bulk_message.push_str(&template); bulk_message.push('\n'); } @@ -225,6 +227,7 @@ pub fn join_message_paragraphs(paragraphs: &[String]) -> String { /// Renders commit description template, which will be edited by user. pub fn description_template( + ui: &Ui, tx: &WorkspaceCommandTransaction, intro: &str, commit: &Commit, @@ -238,7 +241,7 @@ pub fn description_template( // Named as "draft" because the output can contain "JJ: " comment lines. let template_key = "templates.draft_commit_description"; let template_text = tx.settings().config().get_string(template_key)?; - let template = tx.parse_commit_template(&template_text)?; + let template = tx.parse_commit_template(ui, &template_text)?; let mut output = Vec::new(); if !intro.is_empty() {