From 6004efb3b2442b6c8d2044d7266c9c2aa538b22a Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 31 Mar 2024 18:53:42 +0900 Subject: [PATCH] cli: replace last use of evaluate_revset() with evaluate_programmatic() evaluate_programmatic() should be allowed here. AFAIK, the contract is that the expression should never contain any bare symbols and "fallible" symbol-like expressions, which doesn't apply to branches() and remote_branches() functions. evaluate_revset() is removed because there are no callers. However, it's simple and basic function, so we might want to reintroduce it if needed. --- cli/src/cli_util.rs | 11 ++--------- cli/src/commands/git.rs | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 459b97fdbf..71af456307 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -52,8 +52,8 @@ use jj_lib::repo::{ }; use jj_lib::repo_path::{FsPathParseError, RepoPath, RepoPathBuf}; use jj_lib::revset::{ - Revset, RevsetAliasesMap, RevsetCommitRef, RevsetExpression, RevsetFilterPredicate, - RevsetIteratorExt, RevsetParseContext, RevsetWorkspaceContext, + RevsetAliasesMap, RevsetCommitRef, RevsetExpression, RevsetFilterPredicate, RevsetIteratorExt, + RevsetParseContext, RevsetWorkspaceContext, }; use jj_lib::rewrite::restore_tree; use jj_lib::settings::{ConfigResultExt as _, UserSettings}; @@ -880,13 +880,6 @@ impl WorkspaceCommandHelper { self.attach_revset_evaluator(expression) } - pub fn evaluate_revset<'repo>( - &'repo self, - expression: Rc, - ) -> Result, CommandError> { - Ok(self.attach_revset_evaluator(expression)?.evaluate()?) - } - fn attach_revset_evaluator( &self, expression: Rc, diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 7b9fcda2b3..205e6258bd 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -1192,7 +1192,7 @@ fn find_branches_targeted_by_revisions<'a>( .range(&RevsetExpression::commit(wc_commit_id)) .intersection(&RevsetExpression::branches(StringPattern::everything())); let current_branches_revset = - workspace_command.evaluate_revset(current_branches_expression)?; + current_branches_expression.evaluate_programmatic(workspace_command.repo().as_ref())?; revision_commit_ids.extend(current_branches_revset.iter()); if revision_commit_ids.is_empty() { writeln!(