From a5abd9807633099587a6a4cbbd35089087f2f01e Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 31 Mar 2024 13:46:29 +0900 Subject: [PATCH] cli: inline resolve_revset() to caller There's only one caller, and the implementation is straightforward. --- cli/src/cli_util.rs | 8 -------- cli/src/commands/squash.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index d48f8ad975..9ed7e49a0d 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -799,14 +799,6 @@ impl WorkspaceCommandHelper { } } - /// Resolve a revset any number of revisions (including 0). - pub fn resolve_revset(&self, revision_str: &str) -> Result, CommandError> { - Ok(self - .parse_revset(revision_str)? - .evaluate_to_commits()? - .try_collect()?) - } - pub fn parse_revset( &self, revision_str: &str, diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index eb0883b8c8..484116498d 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use itertools::Itertools as _; use jj_lib::commit::Commit; use jj_lib::matchers::Matcher; use jj_lib::object_id::ObjectId; @@ -80,10 +81,13 @@ pub(crate) fn cmd_squash( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let mut sources; + let mut sources: Vec; let destination; if args.from.is_some() || args.into.is_some() { - sources = workspace_command.resolve_revset(args.from.as_deref().unwrap_or("@"))?; + sources = workspace_command + .parse_revset(args.from.as_deref().unwrap_or("@"))? + .evaluate_to_commits()? + .try_collect()?; destination = workspace_command.resolve_single_rev(args.into.as_deref().unwrap_or("@"))?; if sources.iter().any(|source| source.id() == destination.id()) { return Err(user_error("Source and destination cannot be the same"));