From ed14292aa2c2889242928cfce80f35233d4053a5 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 7 Nov 2022 16:41:53 +0900 Subject: [PATCH] revset: add EagerRevset::empty() constructor for convenience --- lib/src/revset.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 526823483..848667d94 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1152,6 +1152,14 @@ struct EagerRevset<'repo> { index_entries: Vec>, } +impl EagerRevset<'static> { + pub const fn empty() -> Self { + EagerRevset { + index_entries: Vec::new(), + } + } +} + impl<'repo> Revset<'repo> for EagerRevset<'repo> { fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { RevsetIterator::new(Box::new(self.index_entries.iter().cloned())) @@ -1403,9 +1411,7 @@ pub fn evaluate_expression<'repo>( workspace_ctx: Option<&RevsetWorkspaceContext>, ) -> Result + 'repo>, RevsetError> { match expression { - RevsetExpression::None => Ok(Box::new(EagerRevset { - index_entries: vec![], - })), + RevsetExpression::None => Ok(Box::new(EagerRevset::empty())), RevsetExpression::All => evaluate_expression( repo, &RevsetExpression::visible_heads().ancestors(),