History

revset: propagate error from is_empty(), replace .try_next().is_some()

Yuya Nishihara committed 3 months ago

Commit 4e55a6c1 parent fd3fdb04 files · +8 −11Browse files

Unified · Split

4 files
  1. cli/src/cli_util.rs +3 −6
  2. cli/src/commands/log.rs +1 −1
  3. lib/src/default_index/revset_engine.rs +2 −2
  4. lib/src/revset.rs +2 −2
cli/src/cli_util.rs+3−6
@@ -2072,15 +2072,12 @@ to the current parents may contain changes from multiple commits. · 2071 unmodified lines
2072 .env2072 .env
2073 .resolve_immutable_expression(tx.repo())2073 .resolve_immutable_expression(tx.repo())
2074 .map_err(snapshot_command_error)?;2074 .map_err(snapshot_command_error)?;
2075 let wc_immutable = immutable_expr2075 let wc_immutable = !immutable_expr
2076 .intersection(&RevsetExpression::commit(wc_commit.id().clone()))2076 .intersection(&RevsetExpression::commit(wc_commit.id().clone()))
2077 .evaluate(tx.repo())2077 .evaluate(tx.repo())
2078 .map_err(snapshot_command_error)?2078 .map_err(snapshot_command_error)?
2079 .stream()2079 .is_empty()
2080 .try_next()2080 .map_err(snapshot_command_error)?;
2081 .await
2082 .map_err(snapshot_command_error)?
2083 .is_some();
2084 let mut_repo = tx.repo_mut();2081 let mut_repo = tx.repo_mut();
2085 let new_wc_commit;2082 let new_wc_commit;
2086 if wc_immutable {2083 if wc_immutable {
cli/src/commands/log.rs+1−1
@@ -382,7 +382,7 @@ pub(crate) async fn cmd_log( · 381 unmodified lines
382 this is often not useful because all non-empty commits touch '.'. If you meant \382 this is often not useful because all non-empty commits touch '.'. If you meant \
383 to show the working copy commit, pass -r '@' instead."383 to show the working copy commit, pass -r '@' instead."
384 )?;384 )?;
385 } else if revset.is_empty()385 } else if revset.is_empty()?
386 && workspace_command386 && workspace_command
387 .parse_revset(ui, &RevisionArg::from(only_path.to_owned()))387 .parse_revset(ui, &RevisionArg::from(only_path.to_owned()))
388 .is_ok()388 .is_ok()
lib/src/default_index/revset_engine.rs+2−2
@@ -188,8 +188,8 @@ impl<I: AsCompositeIndex + Clone> Revset for RevsetImpl<I> { · 187 unmodified lines
188 futures::stream::iter(self.iter_graph_impl(skip_transitive_edges)).boxed_local()188 futures::stream::iter(self.iter_graph_impl(skip_transitive_edges)).boxed_local()
189 }189 }
190 190
191 fn is_empty(&self) -> bool {191 fn is_empty(&self) -> Result<bool, RevsetEvaluationError> {
192 self.positions().next().is_none()192 Ok(self.positions().next().transpose()?.is_none())
193 }193 }
194 194
195 fn count_estimate(&self) -> Result<(usize, Option<usize>), RevsetEvaluationError> {195 fn count_estimate(&self) -> Result<(usize, Option<usize>), RevsetEvaluationError> {
lib/src/revset.rs+2−2
@@ -3407,8 +3407,8 @@ pub trait Revset: fmt::Debug { · 3406 unmodified lines
3407 where3407 where
3408 Self: 'a;3408 Self: 'a;
3409 3409
3410 /// Returns true if iterator will emit no commit nor error.3410 /// Returns true if iterator will emit no commit.
3411 fn is_empty(&self) -> bool;3411 fn is_empty(&self) -> Result<bool, RevsetEvaluationError>;
3412 3412
3413 /// Inclusive lower bound and, optionally, inclusive upper bound of how many3413 /// Inclusive lower bound and, optionally, inclusive upper bound of how many
3414 /// commits are in the revset. The implementation can use its discretion as3414 /// commits are in the revset. The implementation can use its discretion as