cli: simplify check for non-empty revisions with/without "all:"

If "all:" is specified, an empty set should be allowed within that expression.
So the additional check we need here is to ensure that the resulting set is not
empty.
This commit is contained in:
Yuya Nishihara 2024-03-30 16:48:09 +09:00
parent 05242c95cd
commit db15571eca
2 changed files with 5 additions and 8 deletions

View file

@ -1658,9 +1658,6 @@ pub fn resolve_multiple_nonempty_revsets_default_single(
let mut all_commits = IndexSet::new();
for revision_str in revisions {
let commits = workspace_command.resolve_revset_default_single(revision_str)?;
if commits.is_empty() {
return Err(user_error("Empty revision set"));
}
for commit in commits {
let commit_hash = short_commit_hash(commit.id());
if !all_commits.insert(commit) {
@ -1670,7 +1667,11 @@ pub fn resolve_multiple_nonempty_revsets_default_single(
}
}
}
Ok(all_commits)
if all_commits.is_empty() {
Err(user_error("Empty revision set"))
} else {
Ok(all_commits)
}
}
pub fn update_working_copy(

View file

@ -96,10 +96,6 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.",
));
}
let mut workspace_command = command.workspace_helper(ui)?;
assert!(
!args.revisions.is_empty(),
"expected a non-empty list from clap"
);
let target_commits =
resolve_multiple_nonempty_revsets_default_single(&workspace_command, &args.revisions)?
.into_iter()