revset: evaluate optimized expression

This commit is contained in:
Yuya Nishihara 2022-10-25 22:01:41 +09:00
parent 4d5936983a
commit f48675ad90
3 changed files with 8 additions and 6 deletions

View file

@ -21,7 +21,7 @@ use jujutsu_lib::op_store::{RefTarget, WorkspaceId};
use jujutsu_lib::repo::RepoRef;
use jujutsu_lib::repo_path::RepoPath;
use jujutsu_lib::revset::{
self, parse, resolve_symbol, RevsetError, RevsetExpression, RevsetWorkspaceContext,
self, optimize, parse, resolve_symbol, RevsetError, RevsetExpression, RevsetWorkspaceContext,
};
use jujutsu_lib::testutils::{CommitGraphBuilder, TestRepo, TestWorkspace};
use jujutsu_lib::workspace::Workspace;
@ -423,7 +423,7 @@ fn test_resolve_symbol_git_refs() {
}
fn resolve_commit_ids(repo: RepoRef, revset_str: &str) -> Vec<CommitId> {
let expression = parse(revset_str).unwrap();
let expression = optimize(parse(revset_str).unwrap());
expression
.evaluate(repo, None)
.unwrap()
@ -438,7 +438,7 @@ fn resolve_commit_ids_in_workspace(
workspace: &Workspace,
cwd: Option<&Path>,
) -> Vec<CommitId> {
let expression = parse(revset_str).unwrap();
let expression = optimize(parse(revset_str).unwrap());
let workspace_ctx = RevsetWorkspaceContext {
cwd: cwd.unwrap_or_else(|| workspace.workspace_root()),
workspace_id: workspace.workspace_id(),

View file

@ -554,7 +554,7 @@ impl WorkspaceCommandHelper {
}
pub fn resolve_single_rev(&self, revision_str: &str) -> Result<Commit, CommandError> {
let revset_expression = revset::parse(revision_str)?;
let revset_expression = revset::optimize(revset::parse(revision_str)?);
let revset = self.evaluate_revset(&revset_expression)?;
let mut iter = revset.iter().commits(self.repo.store());
match iter.next() {
@ -576,7 +576,7 @@ impl WorkspaceCommandHelper {
}
pub fn resolve_revset(&self, revision_str: &str) -> Result<Vec<Commit>, CommandError> {
let revset_expression = revset::parse(revision_str)?;
let revset_expression = revset::optimize(revset::parse(revision_str)?);
let revset = self.evaluate_revset(&revset_expression)?;
Ok(revset
.iter()

View file

@ -2070,7 +2070,9 @@ fn cmd_log(ui: &mut Ui, command: &CommandHelper, args: &LogArgs) -> Result<(), C
let workspace_command = command.workspace_helper(ui)?;
let default_revset = ui.settings().default_revset();
let revset_expression = revset::parse(args.revisions.as_ref().unwrap_or(&default_revset))?;
let revset_expression = revset::optimize(revset::parse(
args.revisions.as_ref().unwrap_or(&default_revset),
)?);
let repo = workspace_command.repo();
let workspace_id = workspace_command.workspace_id();
let checkout_id = repo.view().get_wc_commit_id(&workspace_id);