From cfae28575ba4e37f036fd444218b5cf5fa534dd0 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 25 Oct 2022 13:29:47 +0900 Subject: [PATCH] revset: add explicit RevsetExpression::All variant This isn't strictly necessary, but is useful while getting rid of redundant 'all() &' expression. --- lib/src/revset.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index bedfa89e8..2b9c87299 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -217,6 +217,7 @@ pub enum RevsetFilterPredicate { #[derive(Debug, PartialEq, Eq, Clone)] pub enum RevsetExpression { None, + All, Commits(Vec), Symbol(String), Parents(Rc), @@ -256,7 +257,7 @@ impl RevsetExpression { } pub fn all() -> Rc { - RevsetExpression::visible_heads().ancestors() + Rc::new(RevsetExpression::All) } pub fn symbol(value: String) -> Rc { @@ -1164,6 +1165,11 @@ pub fn evaluate_expression<'repo>( RevsetExpression::None => Ok(Box::new(EagerRevset { index_entries: vec![], })), + RevsetExpression::All => evaluate_expression( + repo, + &RevsetExpression::visible_heads().ancestors(), + workspace_ctx, + ), RevsetExpression::Commits(commit_ids) => Ok(revset_for_commit_ids(repo, commit_ids)), RevsetExpression::Symbol(symbol) => { let commit_ids = resolve_symbol(repo, symbol, workspace_ctx.map(|c| c.workspace_id))?;