mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
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:
parent
05242c95cd
commit
db15571eca
2 changed files with 5 additions and 8 deletions
|
@ -1658,9 +1658,6 @@ pub fn resolve_multiple_nonempty_revsets_default_single(
|
||||||
let mut all_commits = IndexSet::new();
|
let mut all_commits = IndexSet::new();
|
||||||
for revision_str in revisions {
|
for revision_str in revisions {
|
||||||
let commits = workspace_command.resolve_revset_default_single(revision_str)?;
|
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 {
|
for commit in commits {
|
||||||
let commit_hash = short_commit_hash(commit.id());
|
let commit_hash = short_commit_hash(commit.id());
|
||||||
if !all_commits.insert(commit) {
|
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(
|
pub fn update_working_copy(
|
||||||
|
|
|
@ -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)?;
|
let mut workspace_command = command.workspace_helper(ui)?;
|
||||||
assert!(
|
|
||||||
!args.revisions.is_empty(),
|
|
||||||
"expected a non-empty list from clap"
|
|
||||||
);
|
|
||||||
let target_commits =
|
let target_commits =
|
||||||
resolve_multiple_nonempty_revsets_default_single(&workspace_command, &args.revisions)?
|
resolve_multiple_nonempty_revsets_default_single(&workspace_command, &args.revisions)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
Loading…
Reference in a new issue