From c3fa13e76117b0c6fb18440d50d26c1c9d41a4bf Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 31 Mar 2024 13:38:03 +0900 Subject: [PATCH] cli: inline resolve_revset_default_single() --- cli/src/cli_util.rs | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index f3b9016f4..3daaf3395 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -771,7 +771,19 @@ impl WorkspaceCommandHelper { ) -> Result, CommandError> { let mut all_commits = IndexSet::new(); for revision_str in revision_args { - let commits = self.resolve_revset_default_single(revision_str)?; + let (expression, all) = self.parse_revset_with_all_prefix(revision_str)?; + let commits = if all { + expression.evaluate_to_commits()?.try_collect()? + } else { + let should_hint_about_all_prefix = true; + let commit = revset_util::evaluate_revset_to_single_commit( + revision_str, + &expression, + || self.commit_summary_template(), + should_hint_about_all_prefix, + )?; + vec![commit] + }; for commit in commits { let commit_hash = short_commit_hash(commit.id()); if !all_commits.insert(commit) { @@ -796,28 +808,6 @@ impl WorkspaceCommandHelper { .try_collect()?) } - /// Resolve a revset any number of revisions (including 0), but require the - /// user to indicate if they allow multiple revisions by prefixing the - /// expression with `all:`. - fn resolve_revset_default_single( - &self, - revision_str: &str, - ) -> Result, CommandError> { - let (expression, all) = self.parse_revset_with_all_prefix(revision_str)?; - if all { - Ok(expression.evaluate_to_commits()?.try_collect()?) - } else { - let should_hint_about_all_prefix = true; - let commit = revset_util::evaluate_revset_to_single_commit( - revision_str, - &expression, - || self.commit_summary_template(), - should_hint_about_all_prefix, - )?; - Ok(vec![commit]) - } - } - pub fn parse_revset( &self, revision_str: &str,