Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cli/examples/custom-command/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn run_custom_command(
.set_description("Frobnicated!")
.write()
.await?;
tx.finish(ui, "frobnicate")?;
tx.finish(ui, "frobnicate").await?;
writeln!(
ui.status(),
"Frobnicated revision: {}",
Expand Down
140 changes: 79 additions & 61 deletions cli/src/cli_util.rs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions cli/src/commands/abandon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ pub(crate) async fn cmd_abandon(
}
.resolve()?;
let visible_expr = target_expr.intersection(&RevsetExpression::visible_heads().ancestors());
workspace_command.check_rewritable_expr(&visible_expr)?;
workspace_command
.check_rewritable_expr(&visible_expr)
.await?;
let visible: IndexSet<_> = visible_expr
.evaluate(workspace_command.repo().as_ref())?
.stream()
Expand Down Expand Up @@ -182,7 +184,7 @@ pub(crate) async fn cmd_abandon(
to_abandon.len() - 1
)
};
tx.finish(ui, transaction_description)?;
tx.finish(ui, transaction_description).await?;

#[cfg(feature = "git")]
if jj_lib::git::get_git_backend(workspace_command.repo().store()).is_ok() {
Expand Down
7 changes: 5 additions & 2 deletions cli/src/commands/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ pub(crate) async fn cmd_absorb(
writeln!(ui.warning_default(), "Skipping {ui_path}: {reason}")?;
}

workspace_command.check_rewritable(selected_trees.target_commits.keys())?;
workspace_command
.check_rewritable(selected_trees.target_commits.keys())
.await?;

let mut tx = workspace_command.start_transaction();
let stats = absorb_hunks(tx.repo_mut(), &source, selected_trees.target_commits).await?;
Expand Down Expand Up @@ -131,7 +133,8 @@ pub(crate) async fn cmd_absorb(
"absorb changes into {} commits",
stats.rewritten_destinations.len()
),
)?;
)
.await?;

if let Some(mut formatter) = ui.status_formatter()
&& let Some(commit) = &stats.rewritten_source
Expand Down
6 changes: 4 additions & 2 deletions cli/src/commands/arrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ pub(crate) async fn cmd_arrange(
.parse_union_revsets(ui, &[&*args.revisions_pos, &*args.revisions_opt].concat())?
}
.resolve()?;
workspace_command.check_rewritable_expr(&target_expression)?;
workspace_command
.check_rewritable_expr(&target_expression)
.await?;

let gaps_revset = target_expression
.connected()
Expand Down Expand Up @@ -156,7 +158,7 @@ pub(crate) async fn cmd_arrange(
let mut tx = workspace_command.start_transaction();
let rewrites = new_state.to_rewrite_plan();
rewrites.execute(tx.repo_mut()).await?;
tx.finish(ui, "arrange revisions")?;
tx.finish(ui, "arrange revisions").await?;
Ok(())
} else {
Err(user_error("Canceled by user"))
Expand Down
7 changes: 4 additions & 3 deletions cli/src/commands/bisect/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub(crate) async fn cmd_bisect_run(
}

let cmd = get_command(args);
let evaluation = evaluate_commit(ui, &mut workspace_command, cmd, &commit)?;
let evaluation = evaluate_commit(ui, &mut workspace_command, cmd, &commit).await?;

{
let mut formatter = ui.stdout_formatter();
Expand Down Expand Up @@ -232,7 +232,7 @@ fn get_command(args: &BisectRunArgs) -> std::process::Command {
}
}

fn evaluate_commit(
async fn evaluate_commit(
ui: &mut Ui,
workspace_command: &mut WorkspaceCommandHelper,
mut cmd: std::process::Command,
Expand All @@ -244,7 +244,8 @@ fn evaluate_commit(
tx.finish(
ui,
format!("Updated to revision {commit_id_hex} for bisection"),
)?;
)
.await?;

let jj_executable_path = std::env::current_exe().map_err(|err| {
internal_error_with_message("Could not get path for the jj executable", err)
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 @@ -212,6 +212,7 @@ pub async fn cmd_bookmark_advance(
.join(", "),
id = target_commit.id().hex()
),
)?;
)
.await?;
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub async fn cmd_bookmark_create(
names = bookmark_names.iter().map(|n| n.as_symbol()).join(", "),
id = target_commit.id().hex()
),
)?;
)
.await?;
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub async fn cmd_bookmark_delete(
.map(|(name, _)| name.as_symbol())
.join(", ")
),
)?;
)
.await?;
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ pub async fn cmd_bookmark_forget(
.iter()
.map(|(name, _)| name.as_symbol())
.join(", ");
tx.finish(ui, format!("forget bookmark {forgotten_bookmarks}"))?;
tx.finish(ui, format!("forget bookmark {forgotten_bookmarks}"))
.await?;
Ok(())
}

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 @@ -160,6 +160,7 @@ pub async fn cmd_bookmark_move(
.join(", "),
id = target_commit.id().hex()
),
)?;
)
.await?;
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ pub async fn cmd_bookmark_rename(
old_bookmark = old_bookmark.as_symbol(),
new_bookmark = new_bookmark.as_symbol()
),
)?;
)
.await?;

if tracked_present_old_remotes_exist {
writeln!(
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub async fn cmd_bookmark_set(
names = bookmark_names.iter().map(|n| n.as_symbol()).join(", "),
id = target_commit.id().hex()
),
)?;
)
.await?;
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ pub async fn cmd_bookmark_track(
tx.finish(
ui,
format!("track remote bookmark {}", symbols.iter().join(", ")),
)?;
)
.await?;

//show conflicted bookmarks if there are some

Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/bookmark/untrack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub async fn cmd_bookmark_untrack(
tx.finish(
ui,
format!("untrack remote bookmark {}", symbols.iter().join(", ")),
)?;
)
.await?;
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ new working-copy commit.
tx.repo_mut().edit(name, &new_wc_commit).await.unwrap();
}
}
tx.finish(ui, format!("commit {}", commit.id().hex()))?;
tx.finish(ui, format!("commit {}", commit.id().hex()))
.await?;
Ok(())
}
6 changes: 4 additions & 2 deletions cli/src/commands/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ pub(crate) async fn cmd_describe(
workspace_command.parse_revset(ui, &RevisionArg::AT)?
}
.resolve()?;
workspace_command.check_rewritable_expr(&target_expr)?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;
let commits: Vec<_> = target_expr
.evaluate(workspace_command.repo().as_ref())?
.stream()
Expand Down Expand Up @@ -344,6 +346,6 @@ pub(crate) async fn cmd_describe(
if num_reparented > 0 {
writeln!(ui.status(), "Rebased {num_reparented} descendant commits")?;
}
tx.finish(ui, tx_description)?;
tx.finish(ui, tx_description).await?;
Ok(())
}
7 changes: 5 additions & 2 deletions cli/src/commands/diffedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ pub(crate) async fn cmd_diffedit(
base_commits = target_commit.parents().await?;
diff_description = "The diff initially shows the commit's changes.".to_string();
}
workspace_command.check_rewritable([target_commit.id()])?;
workspace_command
.check_rewritable([target_commit.id()])
.await?;

let diff_editor = workspace_command.diff_editor(ui, args.tool.as_deref())?;
let mut tx = workspace_command.start_transaction();
Expand Down Expand Up @@ -163,7 +165,8 @@ don't make any changes, then the operation will be aborted.",
"Rebased {num_rebased} descendant commits{extra_msg}"
)?;
}
tx.finish(ui, format!("edit commit {}", target_commit.id().hex()))?;
tx.finish(ui, format!("edit commit {}", target_commit.id().hex()))
.await?;
}
print_unmatched_explicit_paths(
ui,
Expand Down
22 changes: 13 additions & 9 deletions cli/src/commands/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,17 @@ pub(crate) async fn cmd_duplicate(
if args.onto.is_none() && args.insert_after.is_none() && args.insert_before.is_none() {
None
} else {
Some(compute_commit_location(
ui,
&workspace_command,
args.onto.as_deref(),
args.insert_after.as_deref(),
args.insert_before.as_deref(),
"duplicated commits",
)?)
Some(
compute_commit_location(
ui,
&workspace_command,
args.onto.as_deref(),
args.insert_after.as_deref(),
args.insert_before.as_deref(),
"duplicated commits",
)
.await?,
)
};

let mut tx = workspace_command.start_transaction();
Expand Down Expand Up @@ -215,6 +218,7 @@ pub(crate) async fn cmd_duplicate(
)?;
}
}
tx.finish(ui, format!("duplicate {num_to_duplicate} commit(s)"))?;
tx.finish(ui, format!("duplicate {num_to_duplicate} commit(s)"))
.await?;
Ok(())
}
7 changes: 5 additions & 2 deletions cli/src/commands/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ pub(crate) async fn cmd_edit(
.or(args.revision_opt.as_ref())
.expect("either positional or -r arg should be provided");
let new_commit = workspace_command.resolve_single_rev(ui, revision_arg)?;
workspace_command.check_rewritable([new_commit.id()])?;
workspace_command
.check_rewritable([new_commit.id()])
.await?;
if workspace_command.get_wc_commit_id() == Some(new_commit.id()) {
writeln!(ui.status(), "Already editing that commit")?;
} else {
let mut tx = workspace_command.start_transaction();
tx.edit(&new_commit)?;
tx.finish(ui, format!("edit commit {}", new_commit.id().hex()))?;
tx.finish(ui, format!("edit commit {}", new_commit.id().hex()))
.await?;
}
Ok(())
}
3 changes: 2 additions & 1 deletion cli/src/commands/file/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub(crate) async fn cmd_file_chmod(

let mut workspace_command = command.workspace_helper(ui)?;
let commit = workspace_command.resolve_single_rev(ui, &args.revision)?;
workspace_command.check_rewritable([commit.id()])?;
workspace_command.check_rewritable([commit.id()]).await?;
let tree = commit.tree();
// TODO: No need to add special case for empty paths when switching to
// parse_union_filesets(). paths = [] should be "none()" if supported.
Expand Down Expand Up @@ -132,4 +132,5 @@ pub(crate) async fn cmd_file_chmod(
commit.id().hex(),
),
)
.await
}
2 changes: 1 addition & 1 deletion cli/src/commands/file/untrack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Make sure they're ignored, then try again.",
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?;
}
if working_copy_shared_with_git {
export_working_copy_changes_to_git(ui, tx.repo_mut(), &wc_tree, &new_commit.tree())?;
export_working_copy_changes_to_git(ui, tx.repo_mut(), &wc_tree, &new_commit.tree()).await?;
}
let repo = tx.commit("untrack paths").await?;
locked_ws.finish(repo.op_id().clone()).await?;
Expand Down
5 changes: 4 additions & 1 deletion cli/src/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ pub(crate) async fn cmd_fix(
workspace_command.parse_union_revsets(ui, &args.source)?
}
.resolve()?;
workspace_command.check_rewritable_expr(&target_expr)?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;

let repo = workspace_command.repo();

Expand Down Expand Up @@ -246,6 +248,7 @@ pub(crate) async fn cmd_fix(
summary.num_checked_commits
)?;
tx.finish(ui, format!("fixed {} commits", summary.num_fixed_commits))
.await
}

/// Invokes all matching tools (if any) to file_to_fix. If the content is
Expand Down
4 changes: 3 additions & 1 deletion cli/src/commands/gerrit/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ pub async fn cmd_gerrit_upload(
let target_expr = workspace_command
.parse_union_revsets(ui, &args.revisions)?
.resolve()?;
workspace_command.check_rewritable_expr(&target_expr)?;
workspace_command
.check_rewritable_expr(&target_expr)
.await?;
target_expr
.evaluate(workspace_command.repo().as_ref())?
.stream()
Expand Down
9 changes: 6 additions & 3 deletions cli/src/commands/git/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ pub async fn cmd_git_clone(
tx.finish(
ui,
format!("check out git remote's branch: {}", name.as_symbol()),
)?;
)
.await?;
}
}

Expand Down Expand Up @@ -315,7 +316,8 @@ async fn configure_remote(
fetch_tags.as_fetch_tags(),
&ref_expr.bookmark,
)?;
tx.finish(ui, format!("add git remote {}", remote_name.as_symbol()))?;
tx.finish(ui, format!("add git remote {}", remote_name.as_symbol()))
.await?;
// Reload workspace to apply new remote configuration to
// gix::ThreadSafeRepository behind the store.
let workspace = command.load_workspace_at(
Expand Down Expand Up @@ -436,6 +438,7 @@ async fn fetch_new_remote(
`git.auto-local-bookmark` is enabled."
)?;
}
tx.finish(ui, "fetch from git remote into empty repo")?;
tx.finish(ui, "fetch from git remote into empty repo")
.await?;
Ok((working_branch.map(ToOwned::to_owned), working_is_default))
}
Loading