mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-08 21:48:08 +00:00
revset: add EagerRevset::empty() constructor for convenience
This commit is contained in:
parent
46fe0791e8
commit
ed14292aa2
1 changed files with 9 additions and 3 deletions
|
@ -1152,6 +1152,14 @@ struct EagerRevset<'repo> {
|
||||||
index_entries: Vec<IndexEntry<'repo>>,
|
index_entries: Vec<IndexEntry<'repo>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EagerRevset<'static> {
|
||||||
|
pub const fn empty() -> Self {
|
||||||
|
EagerRevset {
|
||||||
|
index_entries: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'repo> Revset<'repo> for EagerRevset<'repo> {
|
impl<'repo> Revset<'repo> for EagerRevset<'repo> {
|
||||||
fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> {
|
fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> {
|
||||||
RevsetIterator::new(Box::new(self.index_entries.iter().cloned()))
|
RevsetIterator::new(Box::new(self.index_entries.iter().cloned()))
|
||||||
|
@ -1403,9 +1411,7 @@ pub fn evaluate_expression<'repo>(
|
||||||
workspace_ctx: Option<&RevsetWorkspaceContext>,
|
workspace_ctx: Option<&RevsetWorkspaceContext>,
|
||||||
) -> Result<Box<dyn Revset<'repo> + 'repo>, RevsetError> {
|
) -> Result<Box<dyn Revset<'repo> + 'repo>, RevsetError> {
|
||||||
match expression {
|
match expression {
|
||||||
RevsetExpression::None => Ok(Box::new(EagerRevset {
|
RevsetExpression::None => Ok(Box::new(EagerRevset::empty())),
|
||||||
index_entries: vec![],
|
|
||||||
})),
|
|
||||||
RevsetExpression::All => evaluate_expression(
|
RevsetExpression::All => evaluate_expression(
|
||||||
repo,
|
repo,
|
||||||
&RevsetExpression::visible_heads().ancestors(),
|
&RevsetExpression::visible_heads().ancestors(),
|
||||||
|
|
Loading…
Reference in a new issue