Skip to content

Commit

Permalink
cli: git push: evaluate default revset as user expression
Browse files Browse the repository at this point in the history
This one is the last caller of .evaluate_programmatic() who needs symbol
resolution. Let's switch to the user revset machinery and resolve "@" as a
symbol. If this expression didn't contain "remote=<remote>" parameter, the
default would be expressed as a string RevisionArg::from("...").
  • Loading branch information
yuja committed Nov 6, 2024
1 parent e819cec commit 1042448
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions cli/src/commands/git/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,28 +600,29 @@ fn find_bookmarks_targeted_by_revisions<'a>(
) -> Result<Vec<(&'a str, LocalAndRemoteRef<'a>)>, CommandError> {
let mut revision_commit_ids = HashSet::new();
if use_default_revset {
let Some(wc_commit_id) = workspace_command.get_wc_commit_id().cloned() else {
return Err(user_error("Nothing checked out in this workspace"));
};
let current_bookmarks_expression = RevsetExpression::remote_bookmarks(
// remote_bookmarks(remote=<remote>)..@
let workspace_id = workspace_command.workspace_id();
let expression = RevsetExpression::remote_bookmarks(
StringPattern::everything(),
StringPattern::exact(remote_name),
None,
)
.range(&RevsetExpression::commit(wc_commit_id))
.range(&RevsetExpression::working_copy(workspace_id.clone()))
.intersection(&RevsetExpression::bookmarks(StringPattern::everything()));
let current_bookmarks_revset = current_bookmarks_expression
.evaluate_programmatic(workspace_command.repo().as_ref())?;
for commit_id in current_bookmarks_revset.iter() {
revision_commit_ids.insert(commit_id?);
}
if revision_commit_ids.is_empty() {
let mut commit_ids = workspace_command
.attach_revset_evaluator(expression)
.evaluate_to_commit_ids()?
.peekable();
if commit_ids.peek().is_none() {
writeln!(
ui.warning_default(),
"No bookmarks found in the default push revset: \
remote_bookmarks(remote={remote_name})..@"
)?;
}
for commit_id in commit_ids {
revision_commit_ids.insert(commit_id?);
}
}
for rev_arg in revisions {
let mut expression = workspace_command.parse_revset(ui, rev_arg)?;
Expand Down

0 comments on commit 1042448

Please sign in to comment.