Skip to content

Commit

Permalink
cli: replace last use of evaluate_revset() with evaluate_programmatic()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yuja committed Apr 1, 2024
1 parent b3d3b26 commit 6004efb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -880,13 +880,6 @@ impl WorkspaceCommandHelper {
self.attach_revset_evaluator(expression)
}

pub fn evaluate_revset<'repo>(
&'repo self,
expression: Rc<RevsetExpression>,
) -> Result<Box<dyn Revset + 'repo>, CommandError> {
Ok(self.attach_revset_evaluator(expression)?.evaluate()?)
}

fn attach_revset_evaluator(
&self,
expression: Rc<RevsetExpression>,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit 6004efb

Please sign in to comment.