Skip to content

Commit

Permalink
cli: inline resolve_revset_default_single()
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Apr 1, 2024
1 parent 97f8a88 commit cebee94
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,19 @@ impl WorkspaceCommandHelper {
) -> Result<IndexSet<Commit>, 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) {
Expand All @@ -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<Vec<Commit>, 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,
Expand Down

0 comments on commit cebee94

Please sign in to comment.