Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cli/examples/custom-commit-templater/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use std::sync::Arc;

use async_trait::async_trait;
use futures::TryStreamExt as _;
use jj_cli::cli_util::CliRunner;
use jj_cli::commit_templater::CommitTemplateBuildFnTable;
Expand Down Expand Up @@ -90,8 +91,9 @@ struct TheDigitestResolver {
cache: MostDigitsInId,
}

#[async_trait(?Send)]
impl PartialSymbolResolver for TheDigitestResolver {
fn resolve_symbol(
async fn resolve_symbol(
&self,
repo: &dyn Repo,
symbol: &str,
Expand Down
16 changes: 10 additions & 6 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl CommandHelper {
self.resolve_operation(ui, workspace.repo_loader(), workspace.workspace_name())?;
let repo = workspace.repo_loader().load_at(&op_head).await?;
if let Err(err) =
revset_util::try_resolve_trunk_alias(repo.as_ref(), &env.revset_parse_context())
revset_util::try_resolve_trunk_alias(repo.as_ref(), &env.revset_parse_context()).await
{
// The fallback can be builtin_trunk() if we're willing to support
// inferred trunk forever. (#7990)
Expand Down Expand Up @@ -1109,7 +1109,7 @@ impl WorkspaceCommandEnvironment {

/// Resolves the effective `immutable()` expression to test against commits
/// during a rewrite, taking the `--ignore-immutable` flag into account.
fn resolve_immutable_expression(
async fn resolve_immutable_expression(
&self,
repo: &dyn Repo,
) -> Result<Arc<ResolvedRevsetExpression>, CommandError> {
Expand All @@ -1130,6 +1130,7 @@ impl WorkspaceCommandEnvironment {
immutable_expression,
)
.resolve()
.await
.map_err(|e| config_error_with_message("Invalid `revset-aliases.immutable_heads()`", e))
}

Expand Down Expand Up @@ -1811,7 +1812,7 @@ to the current parents may contain changes from multiple commits.
let mut all_commits = IndexSet::new();
for revision_arg in revision_args {
let expression = self.parse_revset(ui, revision_arg)?;
let mut stream = expression.evaluate_to_commit_ids()?;
let mut stream = expression.evaluate_to_commit_ids().await?;
while let Some(commit_id) = stream.try_next().await? {
all_commits.insert(commit_id);
}
Expand Down Expand Up @@ -2007,7 +2008,7 @@ to the current parents may contain changes from multiple commits.
to_rewrite_expr: &Arc<ResolvedRevsetExpression>,
) -> Result<(), CommandError> {
let repo = self.repo().as_ref();
let immutable_expr = self.env.resolve_immutable_expression(repo)?;
let immutable_expr = self.env.resolve_immutable_expression(repo).await?;
let Some(commit_id) = immutable_expr
.intersection(to_rewrite_expr)
.evaluate(repo)?
Expand Down Expand Up @@ -2099,6 +2100,7 @@ to the current parents may contain changes from multiple commits.
let immutable_expr = self
.env
.resolve_immutable_expression(tx.repo())
.await
.map_err(snapshot_command_error)?;
let wc_immutable = !immutable_expr
.intersection(&RevsetExpression::commit(wc_commit.id().clone()))
Expand Down Expand Up @@ -2316,7 +2318,7 @@ to the current parents may contain changes from multiple commits.
// failures can be ignored. snapshot_working_copy() ensures that the
// working-copy commit is mutable.
let maybe_new_wc_commit = if let Some(wc_commit) = &maybe_new_wc_commit
&& let Ok(immutable_expr) = self.env.resolve_immutable_expression(tx.repo())
&& let Ok(immutable_expr) = self.env.resolve_immutable_expression(tx.repo()).await
&& !immutable_expr
.intersection(&RevsetExpression::commit(wc_commit.id().clone()))
.evaluate(tx.repo())?
Expand Down Expand Up @@ -2927,7 +2929,9 @@ async fn rebase_mutable_descendants(
// tx.base_repo() here because we're interested in existing immutable
// commits that are still reachable.
let mut num_rebased = 0;
let immutable = env.resolve_immutable_expression(tx.base_repo().as_ref())?;
let immutable = env
.resolve_immutable_expression(tx.base_repo().as_ref())
.await?;
tx.repo_mut()
.rebase_descendants_with_options(
&immutable,
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/abandon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ pub(crate) async fn cmd_abandon(
} else {
workspace_command.parse_revset(ui, &RevisionArg::AT)?
}
.resolve()?;
.resolve()
.await?;
let visible_expr = target_expr.intersection(&RevsetExpression::visible_heads().ancestors());
workspace_command
.check_rewritable_expr(&visible_expr)
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ pub(crate) async fn cmd_absorb(
let source_commit = workspace_command.resolve_single_rev(ui, &args.from).await?;
let destinations = workspace_command
.parse_union_revsets(ui, &args.into)?
.resolve()?;
.resolve()
.await?;

let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let matcher = fileset_expression.to_matcher();
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/arrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ pub(crate) async fn cmd_arrange(
workspace_command
.parse_union_revsets(ui, &[&*args.revisions_pos, &*args.revisions_opt].concat())?
}
.resolve()?;
.resolve()
.await?;
workspace_command
.check_rewritable_expr(&target_expression)
.await?;
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/bench/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fn bench_revset<M: Measurement>(
SymbolResolver::new(repo, &([] as [Box<dyn SymbolResolverExtension>; 0]));
let resolved = expression
.resolve_user_expression(repo, &symbol_resolver)
.block_on()
.unwrap();
let revset = resolved.evaluate(repo).unwrap();
revset.stream().count().block_on()
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/bisect/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ pub(crate) async fn cmd_bisect_run(

let input_range = workspace_command
.parse_union_revsets(ui, &args.range)?
.resolve()?;
.resolve()
.await?;

let initial_repo = workspace_command.repo().clone();

Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/advance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ pub async fn cmd_bookmark_advance(

let is_source_commit = workspace_command
.attach_revset_evaluator(expression)
.evaluate()?
.evaluate()
.await?
.containing_fn();
let is_source_ref = async |target: &RefTarget| -> Result<bool, CommandError> {
Ok(
Expand Down
6 changes: 5 additions & 1 deletion cli/src/commands/bookmark/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ pub async fn cmd_bookmark_list(
// Intersects with the set of local bookmark targets to minimize the lookup
// space.
expression.intersect_with(&RevsetExpression::bookmarks(StringExpression::all()));
expression.evaluate_to_commit_ids()?.try_collect().await?
expression
.evaluate_to_commit_ids()
.await?
.try_collect()
.await?
} else {
HashSet::new()
};
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ pub async fn cmd_bookmark_move(
Some(
workspace_command
.parse_union_revsets(ui, &args.from)?
.evaluate()?
.evaluate()
.await?
.containing_fn(),
)
} else {
Expand Down
4 changes: 3 additions & 1 deletion cli/src/commands/debug/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ pub async fn cmd_debug_revset(
command.revset_extensions().symbol_resolvers(),
workspace_command.id_prefix_context(),
);
let mut expression = expression.resolve_user_expression(repo, &symbol_resolver)?;
let mut expression = expression
.resolve_user_expression(repo, &symbol_resolver)
.await?;
writeln!(ui.stdout(), "-- Resolved:")?;
writeln!(ui.stdout(), "{expression:#?}")?;
writeln!(ui.stdout())?;
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ pub(crate) async fn cmd_describe(
} else {
workspace_command.parse_revset(ui, &RevisionArg::AT)?
}
.resolve()?;
.resolve()
.await?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;
Expand Down
9 changes: 6 additions & 3 deletions cli/src/commands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ pub(crate) async fn cmd_diff(
.range(&target_expression.heads())
.minus(target_expression),
)
.evaluate_to_commit_ids()?;
.evaluate_to_commit_ids()
.await?;
if let Some(commit_id) = gaps_revset.try_next().await? {
return Err(
user_error("Cannot diff revsets with gaps in.").hinted(format!(
Expand All @@ -165,12 +166,14 @@ pub(crate) async fn cmd_diff(
}
let heads: Vec<_> = workspace_command
.attach_revset_evaluator(target_expression.heads())
.evaluate_to_commits()?
.evaluate_to_commits()
.await?
.try_collect()
.await?;
let roots: Vec<_> = workspace_command
.attach_revset_evaluator(target_expression.roots())
.evaluate_to_commits()?
.evaluate_to_commits()
.await?
.try_collect()
.await?;

Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ pub(crate) async fn cmd_duplicate(
} else {
workspace_command.parse_revset(ui, &RevisionArg::AT)?
}
.evaluate_to_commit_ids()?
.evaluate_to_commit_ids()
.await?
.try_collect()
.await?; // in reverse topological order
if to_duplicate.is_empty() {
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/evolog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ pub(crate) async fn cmd_evolog(

let start_commit_ids: Vec<_> = workspace_command
.parse_union_revsets(ui, &args.revisions)?
.evaluate_to_commit_ids()?
.evaluate_to_commit_ids()
.await?
.try_collect()
.await?;

Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ pub(crate) async fn cmd_fix(
} else {
workspace_command.parse_union_revsets(ui, &args.source)?
}
.resolve()?;
.resolve()
.await?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;
Expand Down
6 changes: 4 additions & 2 deletions cli/src/commands/gerrit/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ pub async fn cmd_gerrit_upload(
} else {
let target_expr = workspace_command
.parse_union_revsets(ui, &args.revisions)?
.resolve()?;
.resolve()
.await?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;
Expand All @@ -488,7 +489,8 @@ pub async fn cmd_gerrit_upload(
.immutable_expression()
.range(&RevsetExpression::commits(revisions.clone())),
)
.evaluate_to_commits()?
.evaluate_to_commits()
.await?
.try_collect()
.await?;

Expand Down
24 changes: 14 additions & 10 deletions cli/src/commands/git/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub async fn cmd_git_push(
let mut ref_updates = GitPushRefTargets::default();
if args.all {
let mut commits_validator =
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args)?;
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args).await?;
for (name, targets) in view.local_remote_bookmarks(remote) {
let remote_symbol = name.to_remote_symbol(remote);
let allow_new = true; // implied by --all
Expand Down Expand Up @@ -317,7 +317,7 @@ pub async fn cmd_git_push(
);
} else if args.tracked {
let mut commits_validator =
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args)?;
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args).await?;
for (name, targets) in view.local_remote_bookmarks(remote) {
if !targets.remote_ref.is_tracked() {
continue;
Expand Down Expand Up @@ -355,7 +355,7 @@ pub async fn cmd_git_push(
} else if args.deleted {
// There shouldn't be new heads to push, but we run validation for consistency.
let mut commits_validator =
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args)?;
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args).await?;
for (name, targets) in view.local_remote_bookmarks(remote) {
if targets.local_target.is_present() {
continue;
Expand Down Expand Up @@ -486,7 +486,7 @@ pub async fn cmd_git_push(
}

let mut commits_validator =
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args)?;
CommitsValidator::new(ui, tx.base_workspace_helper(), remote, args).await?;
// Error out if explicitly-specified targets can't be pushed.
commits_validator
.validate_updates(&ref_updates)
Expand Down Expand Up @@ -670,7 +670,7 @@ struct CommitsValidator<'repo> {
}

impl<'repo> CommitsValidator<'repo> {
fn new(
async fn new(
ui: &Ui,
workspace_helper: &'repo WorkspaceCommandHelper,
remote: &RemoteName,
Expand All @@ -685,13 +685,15 @@ impl<'repo> CommitsValidator<'repo> {
.collect();
let immutable_heads = workspace_helper
.attach_revset_evaluator(workspace_helper.env().immutable_heads_expression().clone())
.resolve()?;
.resolve()
.await?;
let private_commits = if !args.allow_private {
let settings = workspace_helper.settings();
let revset_str = settings.get_string("git.private-commits")?;
let is_private = workspace_helper
.parse_revset(ui, &RevisionArg::from(revset_str.clone()))?
.evaluate()?
.evaluate()
.await?
.containing_fn();
Some((revset_str, is_private))
} else {
Expand Down Expand Up @@ -809,7 +811,8 @@ async fn sign_commits_before_push(
let commit_ids: IndexSet<CommitId> = tx
.base_workspace_helper()
.attach_revset_evaluator(commits_to_push)
.evaluate_to_commits()?
.evaluate_to_commits()
.await?
// TODO: make filter condition configurable by revset?
.try_filter(|commit| {
future::ready(!commit.is_signed() && sign_settings.should_sign(commit.store_commit()))
Expand Down Expand Up @@ -1293,7 +1296,8 @@ async fn find_default_target_revisions(
);
let commit_ids = workspace_command
.attach_revset_evaluator(expression)
.evaluate_to_commit_ids()?
.evaluate_to_commit_ids()
.await?
.peekable();
let mut commit_ids = std::pin::pin!(commit_ids);
if commit_ids.as_mut().peek().await.is_none() {
Expand All @@ -1319,7 +1323,7 @@ async fn find_target_revisions(
&RevsetExpression::bookmarks(StringExpression::all())
.union(&RevsetExpression::tags(StringExpression::all())),
);
let commit_ids = expression.evaluate_to_commit_ids()?.peekable();
let commit_ids = expression.evaluate_to_commit_ids().await?.peekable();
let mut commit_ids = std::pin::pin!(commit_ids);
if commit_ids.as_mut().as_mut().peek().await.is_none() {
writeln!(
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub(crate) async fn cmd_log(
expression
};

let revset = revset_expression.evaluate()?;
let revset = revset_expression.evaluate().await?;

if args.count {
let (lower, upper) = revset.count_estimate()?;
Expand Down Expand Up @@ -224,7 +224,7 @@ pub(crate) async fn cmd_log(
let mut stream: LocalBoxStream<_> = {
let mut topo_order = TopoGroupedGraph::new(revset.stream_graph(), |id| id);

let mut prio_stream = prio_revset.evaluate_to_commit_ids()?;
let mut prio_stream = prio_revset.evaluate_to_commit_ids().await?;
while let Some(prio) = prio_stream.try_next().await? {
topo_order.prioritize_branch(prio);
}
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/metaedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ pub(crate) async fn cmd_metaedit(
} else {
workspace_command.parse_revset(ui, &RevisionArg::AT)?
}
.resolve()?;
.resolve()
.await?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;
Expand Down
Loading
Loading