diff --git a/cli/examples/custom-command/main.rs b/cli/examples/custom-command/main.rs index 2cbdddc09..7c1b607bc 100644 --- a/cli/examples/custom-command/main.rs +++ b/cli/examples/custom-command/main.rs @@ -39,13 +39,13 @@ fn run_custom_command( CustomCommand::Frobnicate(args) => { let mut workspace_command = command_helper.workspace_helper(ui)?; let commit = workspace_command.resolve_single_rev(&args.revision, ui)?; - let mut tx = workspace_command.start_transaction("Frobnicate"); + let mut tx = workspace_command.start_transaction(); let new_commit = tx .mut_repo() .rewrite_commit(command_helper.settings(), &commit) .set_description("Frobnicated!") .write()?; - tx.finish(ui)?; + tx.finish(ui, "Frobnicate")?; writeln!( ui.stderr(), "Frobnicated revision: {}", diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 83f8d1f73..12df3efad 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -628,12 +628,8 @@ impl CommandHelper { )?; let base_repo = repo_loader.load_at(&op_heads[0])?; // TODO: It may be helpful to print each operation we're merging here - let mut tx = start_repo_transaction( - &base_repo, - &self.settings, - &self.string_args, - "resolve concurrent operations", - ); + let mut tx = + start_repo_transaction(&base_repo, &self.settings, &self.string_args); for other_op_head in op_heads.into_iter().skip(1) { tx.merge_operation(other_op_head)?; let num_rebased = tx.mut_repo().rebase_descendants(&self.settings)?; @@ -645,7 +641,11 @@ impl CommandHelper { )?; } } - Ok(tx.write().leave_unpublished().operation().clone()) + Ok(tx + .write("resolve concurrent operations") + .leave_unpublished() + .operation() + .clone()) }, ) } else { @@ -797,7 +797,7 @@ impl WorkspaceCommandHelper { #[instrument(skip_all)] fn import_git_refs_and_head(&mut self, ui: &mut Ui) -> Result<(), CommandError> { let git_settings = self.settings.git_settings(); - let mut tx = self.start_transaction("import git refs"); + let mut tx = self.start_transaction(); // Automated import shouldn't fail because of reserved remote name. let stats = git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| { !git::is_reserved_git_remote_ref(ref_name) @@ -829,7 +829,7 @@ impl WorkspaceCommandHelper { let new_git_head_tree = new_git_head_commit.tree()?; locked_ws.locked_wc().reset(&new_git_head_tree)?; tx.mut_repo().rebase_descendants(&self.settings)?; - self.user_repo = ReadonlyUserRepo::new(tx.commit()); + self.user_repo = ReadonlyUserRepo::new(tx.commit("import git refs")); locked_ws.finish(self.user_repo.repo.op_id().clone())?; } _ => { @@ -841,7 +841,7 @@ impl WorkspaceCommandHelper { git" )?; } - self.finish_transaction(ui, tx)?; + self.finish_transaction(ui, tx, "import git refs")?; } } writeln!( @@ -1363,12 +1363,8 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin })?; drop(progress); if new_tree_id != *wc_commit.tree_id() { - let mut tx = start_repo_transaction( - &self.user_repo.repo, - &self.settings, - &self.string_args, - "snapshot working copy", - ); + let mut tx = + start_repo_transaction(&self.user_repo.repo, &self.settings, &self.string_args); let mut_repo = tx.mut_repo(); let commit = mut_repo .rewrite_commit(&self.settings, &wc_commit) @@ -1390,7 +1386,7 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin print_failed_git_export(ui, &failed_branches)?; } - self.user_repo = ReadonlyUserRepo::new(tx.commit()); + self.user_repo = ReadonlyUserRepo::new(tx.commit("snapshot working copy")); } locked_ws.finish(self.user_repo.repo.op_id().clone())?; Ok(()) @@ -1428,13 +1424,17 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin Ok(()) } - pub fn start_transaction(&mut self, description: &str) -> WorkspaceCommandTransaction { - let tx = - start_repo_transaction(self.repo(), &self.settings, &self.string_args, description); + pub fn start_transaction(&mut self) -> WorkspaceCommandTransaction { + let tx = start_repo_transaction(self.repo(), &self.settings, &self.string_args); WorkspaceCommandTransaction { helper: self, tx } } - fn finish_transaction(&mut self, ui: &mut Ui, mut tx: Transaction) -> Result<(), CommandError> { + fn finish_transaction( + &mut self, + ui: &mut Ui, + mut tx: Transaction, + description: impl Into, + ) -> Result<(), CommandError> { if !tx.mut_repo().has_changes() { writeln!(ui.stderr(), "Nothing changed.")?; return Ok(()); @@ -1465,7 +1465,7 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin let failed_branches = git::export_refs(tx.mut_repo())?; print_failed_git_export(ui, &failed_branches)?; } - self.user_repo = ReadonlyUserRepo::new(tx.commit()); + self.user_repo = ReadonlyUserRepo::new(tx.commit(description)); self.report_repo_changes(ui, &old_repo)?; if self.may_update_working_copy { @@ -1665,10 +1665,6 @@ impl WorkspaceCommandTransaction<'_> { self.tx.mut_repo() } - pub fn set_description(&mut self, description: &str) { - self.tx.set_description(description) - } - pub fn check_out(&mut self, commit: &Commit) -> Result { let workspace_id = self.helper.workspace_id().to_owned(); let settings = &self.helper.settings; @@ -1755,8 +1751,8 @@ impl WorkspaceCommandTransaction<'_> { template.format(commit, formatter) } - pub fn finish(self, ui: &mut Ui) -> Result<(), CommandError> { - self.helper.finish_transaction(ui, self.tx) + pub fn finish(self, ui: &mut Ui, description: impl Into) -> Result<(), CommandError> { + self.helper.finish_transaction(ui, self.tx, description) } pub fn into_inner(self) -> Transaction { @@ -1843,9 +1839,8 @@ pub fn start_repo_transaction( repo: &Arc, settings: &UserSettings, string_args: &[String], - description: &str, ) -> Transaction { - let mut tx = repo.start_transaction(settings, description); + let mut tx = repo.start_transaction(settings); // TODO: Either do better shell-escaping here or store the values in some list // type (which we currently don't have). let shell_escape = |arg: &String| { diff --git a/cli/src/commands/abandon.rs b/cli/src/commands/abandon.rs index cdacb10c9..3e4483377 100644 --- a/cli/src/commands/abandon.rs +++ b/cli/src/commands/abandon.rs @@ -58,7 +58,7 @@ pub(crate) fn cmd_abandon( to_abandon.len() - 1 ) }; - let mut tx = workspace_command.start_transaction(&transaction_description); + let mut tx = workspace_command.start_transaction(); for commit in &to_abandon { tx.mut_repo().record_abandoned_commit(commit.id().clone()); } @@ -86,6 +86,6 @@ pub(crate) fn cmd_abandon( "Rebased {num_rebased} descendant commits onto parents of abandoned commits" )?; } - tx.finish(ui)?; + tx.finish(ui, transaction_description)?; Ok(()) } diff --git a/cli/src/commands/backout.rs b/cli/src/commands/backout.rs index f89baa552..1e996ec1c 100644 --- a/cli/src/commands/backout.rs +++ b/cli/src/commands/backout.rs @@ -45,17 +45,17 @@ pub(crate) fn cmd_backout( let destination = workspace_command.resolve_single_rev(revision_str, ui)?; parents.push(destination); } - let mut tx = workspace_command.start_transaction(&format!( - "back out commit {}", - commit_to_back_out.id().hex() - )); + let mut tx = workspace_command.start_transaction(); back_out_commit( command.settings(), tx.mut_repo(), &commit_to_back_out, &parents, )?; - tx.finish(ui)?; + tx.finish( + ui, + format!("back out commit {}", commit_to_back_out.id().hex()), + )?; Ok(()) } diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index ffbf684a5..b86992682 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -285,16 +285,19 @@ fn cmd_branch_create( )?; } - let mut tx = workspace_command.start_transaction(&format!( - "create {} pointing to commit {}", - make_branch_term(branch_names), - target_commit.id().hex() - )); + let mut tx = workspace_command.start_transaction(); for branch_name in branch_names { tx.mut_repo() .set_local_branch_target(branch_name, RefTarget::normal(target_commit.id().clone())); } - tx.finish(ui)?; + tx.finish( + ui, + format!( + "create {} pointing to commit {}", + make_branch_term(branch_names), + target_commit.id().hex() + ), + )?; Ok(()) } @@ -339,16 +342,19 @@ fn cmd_branch_set( )?; } - let mut tx = workspace_command.start_transaction(&format!( - "point {} to commit {}", - make_branch_term(branch_names), - target_commit.id().hex() - )); + let mut tx = workspace_command.start_transaction(); for branch_name in branch_names { tx.mut_repo() .set_local_branch_target(branch_name, RefTarget::normal(target_commit.id().clone())); } - tx.finish(ui)?; + tx.finish( + ui, + format!( + "point {} to commit {}", + make_branch_term(branch_names), + target_commit.id().hex() + ), + )?; Ok(()) } @@ -453,13 +459,12 @@ fn cmd_branch_delete( } let name_patterns = [&args.names[..], &args.glob[..]].concat(); let names = find_local_branches(view, &name_patterns)?; - let mut tx = - workspace_command.start_transaction(&format!("delete {}", make_branch_term(&names))); + let mut tx = workspace_command.start_transaction(); for branch_name in names.iter() { tx.mut_repo() .set_local_branch_target(branch_name, RefTarget::absent()); } - tx.finish(ui)?; + tx.finish(ui, format!("delete {}", make_branch_term(&names)))?; if names.len() > 1 { writeln!(ui.stderr(), "Deleted {} branches.", names.len())?; } @@ -481,12 +486,11 @@ fn cmd_branch_forget( } let name_patterns = [&args.names[..], &args.glob[..]].concat(); let names = find_forgettable_branches(view, &name_patterns)?; - let mut tx = - workspace_command.start_transaction(&format!("forget {}", make_branch_term(&names))); + let mut tx = workspace_command.start_transaction(); for branch_name in names.iter() { tx.mut_repo().remove_branch(branch_name); } - tx.finish(ui)?; + tx.finish(ui, format!("forget {}", make_branch_term(&names)))?; if names.len() > 1 { writeln!(ui.stderr(), "Forgot {} branches.", names.len())?; } @@ -508,13 +512,12 @@ fn cmd_branch_track( names.push(name); } } - let mut tx = - workspace_command.start_transaction(&format!("track remote {}", make_branch_term(&names))); + let mut tx = workspace_command.start_transaction(); for name in &names { tx.mut_repo() .track_remote_branch(&name.branch, &name.remote); } - tx.finish(ui)?; + tx.finish(ui, format!("track remote {}", make_branch_term(&names)))?; if names.len() > 1 { writeln!( ui.stderr(), @@ -546,13 +549,12 @@ fn cmd_branch_untrack( names.push(name); } } - let mut tx = workspace_command - .start_transaction(&format!("untrack remote {}", make_branch_term(&names))); + let mut tx = workspace_command.start_transaction(); for name in &names { tx.mut_repo() .untrack_remote_branch(&name.branch, &name.remote); } - tx.finish(ui)?; + tx.finish(ui, format!("untrack remote {}", make_branch_term(&names)))?; if names.len() > 1 { writeln!( ui.stderr(), diff --git a/cli/src/commands/checkout.rs b/cli/src/commands/checkout.rs index a79ae5f0a..cb622e4b4 100644 --- a/cli/src/commands/checkout.rs +++ b/cli/src/commands/checkout.rs @@ -43,8 +43,7 @@ pub(crate) fn cmd_checkout( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let target = workspace_command.resolve_single_rev(&args.revision, ui)?; - let mut tx = - workspace_command.start_transaction(&format!("check out commit {}", target.id().hex())); + let mut tx = workspace_command.start_transaction(); let commit_builder = tx .mut_repo() .new_commit( @@ -55,6 +54,6 @@ pub(crate) fn cmd_checkout( .set_description(join_message_paragraphs(&args.message_paragraphs)); let new_commit = commit_builder.write()?; tx.edit(&new_commit).unwrap(); - tx.finish(ui)?; + tx.finish(ui, format!("check out commit {}", target.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/chmod.rs b/cli/src/commands/chmod.rs index e4204c06e..4d7836854 100644 --- a/cli/src/commands/chmod.rs +++ b/cli/src/commands/chmod.rs @@ -66,15 +66,7 @@ pub(crate) fn cmd_chmod( let commit = workspace_command.resolve_single_rev(&args.revision, ui)?; workspace_command.check_rewritable([&commit])?; - let mut tx = workspace_command.start_transaction(&format!( - "make paths {} in commit {}", - if executable_bit { - "executable" - } else { - "non-executable" - }, - commit.id().hex(), - )); + let mut tx = workspace_command.start_transaction(); let tree = commit.tree()?; let store = tree.store(); let mut tree_builder = MergedTreeBuilder::new(commit.tree_id().clone()); @@ -119,5 +111,16 @@ pub(crate) fn cmd_chmod( .rewrite_commit(command.settings(), &commit) .set_tree_id(new_tree_id) .write()?; - tx.finish(ui) + tx.finish( + ui, + format!( + "make paths {} in commit {}", + if executable_bit { + "executable" + } else { + "non-executable" + }, + commit.id().hex(), + ), + ) } diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index c606b8cd9..d41f87f0b 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -49,7 +49,7 @@ pub(crate) fn cmd_commit( .ok_or_else(|| user_error("This command requires a working copy"))?; let commit = workspace_command.repo().store().get_commit(commit_id)?; let matcher = workspace_command.matcher_from_values(&args.paths)?; - let mut tx = workspace_command.start_transaction(&format!("commit {}", commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let base_tree = merge_commit_trees(tx.repo(), &commit.parents())?; let instructions = format!( "\ @@ -117,6 +117,6 @@ new working-copy commit. tx.mut_repo().edit(workspace_id, &new_wc_commit).unwrap(); } } - tx.finish(ui)?; + tx.finish(ui, format!("commit {}", commit.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/describe.rs b/cli/src/commands/describe.rs index 78aa23f01..2be982767 100644 --- a/cli/src/commands/describe.rs +++ b/cli/src/commands/describe.rs @@ -77,8 +77,7 @@ pub(crate) fn cmd_describe( if description == *commit.description() && !args.reset_author { writeln!(ui.stderr(), "Nothing changed.")?; } else { - let mut tx = - workspace_command.start_transaction(&format!("describe commit {}", commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let mut commit_builder = tx .mut_repo() .rewrite_commit(command.settings(), &commit) @@ -88,7 +87,7 @@ pub(crate) fn cmd_describe( commit_builder = commit_builder.set_author(new_author); } commit_builder.write()?; - tx.finish(ui)?; + tx.finish(ui, format!("describe commit {}", commit.id().hex()))?; } Ok(()) } diff --git a/cli/src/commands/diffedit.rs b/cli/src/commands/diffedit.rs index a86152661..698b5163a 100644 --- a/cli/src/commands/diffedit.rs +++ b/cli/src/commands/diffedit.rs @@ -78,8 +78,7 @@ pub(crate) fn cmd_diffedit( }; workspace_command.check_rewritable([&target_commit])?; - let mut tx = - workspace_command.start_transaction(&format!("edit commit {}", target_commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let instructions = format!( "\ You are editing changes in: {} @@ -110,7 +109,7 @@ don't make any changes, then the operation will be aborted.", if num_rebased > 0 { writeln!(ui.stderr(), "Rebased {num_rebased} descendant commits")?; } - tx.finish(ui)?; + tx.finish(ui, format!("edit commit {}", target_commit.id().hex()))?; } Ok(()) } diff --git a/cli/src/commands/duplicate.rs b/cli/src/commands/duplicate.rs index 4b1f44dd4..6dafe4497 100644 --- a/cli/src/commands/duplicate.rs +++ b/cli/src/commands/duplicate.rs @@ -53,8 +53,7 @@ pub(crate) fn cmd_duplicate( } let mut duplicated_old_to_new: IndexMap = IndexMap::new(); - let mut tx = workspace_command - .start_transaction(&format!("duplicating {} commit(s)", to_duplicate.len())); + let mut tx = workspace_command.start_transaction(); let base_repo = tx.base_repo().clone(); let store = base_repo.store(); let mut_repo = tx.mut_repo(); @@ -97,6 +96,6 @@ pub(crate) fn cmd_duplicate( tx.write_commit_summary(ui.stderr_formatter().as_mut(), new)?; writeln!(ui.stderr())?; } - tx.finish(ui)?; + tx.finish(ui, format!("duplicating {} commit(s)", to_duplicate.len()))?; Ok(()) } diff --git a/cli/src/commands/edit.rs b/cli/src/commands/edit.rs index 2b82388fa..88c3a7010 100644 --- a/cli/src/commands/edit.rs +++ b/cli/src/commands/edit.rs @@ -45,10 +45,9 @@ pub(crate) fn cmd_edit( if workspace_command.get_wc_commit_id() == Some(new_commit.id()) { writeln!(ui.stderr(), "Already editing that commit")?; } else { - let mut tx = - workspace_command.start_transaction(&format!("edit commit {}", new_commit.id().hex())); + let mut tx = workspace_command.start_transaction(); tx.edit(&new_commit)?; - tx.finish(ui)?; + tx.finish(ui, format!("edit commit {}", new_commit.id().hex()))?; } Ok(()) } diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 230beafa6..9a1dc774a 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -257,11 +257,10 @@ fn cmd_git_remote_remove( let mut workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo(); let git_repo = get_git_repo(repo.store())?; - let mut tx = - workspace_command.start_transaction(&format!("remove git remote {}", &args.remote)); + let mut tx = workspace_command.start_transaction(); git::remove_remote(tx.mut_repo(), &git_repo, &args.remote)?; if tx.mut_repo().has_changes() { - tx.finish(ui) + tx.finish(ui, format!("remove git remote {}", &args.remote)) } else { Ok(()) // Do not print "Nothing changed." } @@ -275,11 +274,13 @@ fn cmd_git_remote_rename( let mut workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo(); let git_repo = get_git_repo(repo.store())?; - let mut tx = workspace_command - .start_transaction(&format!("rename git remote {} to {}", &args.old, &args.new)); + let mut tx = workspace_command.start_transaction(); git::rename_remote(tx.mut_repo(), &git_repo, &args.old, &args.new)?; if tx.mut_repo().has_changes() { - tx.finish(ui) + tx.finish( + ui, + format!("rename git remote {} to {}", &args.old, &args.new), + ) } else { Ok(()) // Do not print "Nothing changed." } @@ -320,16 +321,13 @@ fn cmd_git_fetch( } else { args.remotes.clone() }; - let mut tx = workspace_command.start_transaction(&format!( - "fetch from git remote(s) {}", - remotes.iter().join(",") - )); - for remote in remotes { + let mut tx = workspace_command.start_transaction(); + for remote in &remotes { let stats = with_remote_callbacks(ui, |cb| { git::fetch( tx.mut_repo(), &git_repo, - &remote, + remote, &args.branch, cb, &command.settings().git_settings(), @@ -356,7 +354,10 @@ fn cmd_git_fetch( })?; print_git_import_stats(ui, &stats.import_stats)?; } - tx.finish(ui)?; + tx.finish( + ui, + format!("fetch from git remote(s) {}", remotes.iter().join(",")), + )?; Ok(()) } @@ -505,12 +506,11 @@ fn cmd_git_clone( .view() .get_remote_branch(default_branch, remote_name); if let Some(commit_id) = default_branch_remote_ref.target.as_normal().cloned() { - let mut checkout_tx = - workspace_command.start_transaction("check out git remote's default branch"); + let mut checkout_tx = workspace_command.start_transaction(); if let Ok(commit) = checkout_tx.repo().store().get_commit(&commit_id) { checkout_tx.check_out(&commit)?; } - checkout_tx.finish(ui)?; + checkout_tx.finish(ui, "check out git remote's default branch")?; } } Ok(()) @@ -538,7 +538,7 @@ fn do_git_clone( let mut workspace_command = command.for_loaded_repo(ui, workspace, repo)?; maybe_add_gitignore(&workspace_command)?; git_repo.remote(remote_name, source).unwrap(); - let mut fetch_tx = workspace_command.start_transaction("fetch from git remote into empty repo"); + let mut fetch_tx = workspace_command.start_transaction(); let stats = with_remote_callbacks(ui, |cb| { git::fetch( @@ -561,7 +561,7 @@ fn do_git_clone( } })?; print_git_import_stats(ui, &stats.import_stats)?; - fetch_tx.finish(ui)?; + fetch_tx.finish(ui, "fetch from git remote into empty repo")?; Ok((workspace_command, stats)) } @@ -700,7 +700,7 @@ fn cmd_git_push( .map(|change_str| workspace_command.resolve_single_rev(change_str, ui)) .try_collect()?; - let mut tx = workspace_command.start_transaction(""); + let mut tx = workspace_command.start_transaction(); let tx_description; let mut branch_updates = vec![]; if args.all { @@ -855,8 +855,6 @@ fn cmd_git_push( return Ok(()); } - tx.set_description(&tx_description); - let mut new_heads = vec![]; let mut force_pushed_branches = hashset! {}; for (branch_name, update) in &branch_updates { @@ -976,7 +974,7 @@ fn cmd_git_push( ), _ => user_error(err.to_string()), })?; - tx.finish(ui)?; + tx.finish(ui, tx_description)?; Ok(()) } @@ -1088,10 +1086,10 @@ fn cmd_git_import( _args: &GitImportArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let mut tx = workspace_command.start_transaction("import git refs"); + let mut tx = workspace_command.start_transaction(); let stats = git::import_refs(tx.mut_repo(), &command.settings().git_settings())?; print_git_import_stats(ui, &stats)?; - tx.finish(ui)?; + tx.finish(ui, "import git refs")?; Ok(()) } @@ -1101,9 +1099,9 @@ fn cmd_git_export( _args: &GitExportArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let mut tx = workspace_command.start_transaction("export git refs"); + let mut tx = workspace_command.start_transaction(); let failed_branches = git::export_refs(tx.mut_repo())?; - tx.finish(ui)?; + tx.finish(ui, "export git refs")?; print_failed_git_export(ui, &failed_branches)?; Ok(()) } diff --git a/cli/src/commands/init.rs b/cli/src/commands/init.rs index ea8d6dc13..d13fca644 100644 --- a/cli/src/commands/init.rs +++ b/cli/src/commands/init.rs @@ -86,7 +86,7 @@ pub(crate) fn cmd_init( git::maybe_add_gitignore(&workspace_command)?; workspace_command.snapshot(ui)?; if !workspace_command.working_copy_shared_with_git() { - let mut tx = workspace_command.start_transaction("import git refs"); + let mut tx = workspace_command.start_transaction(); let stats = jj_lib::git::import_some_refs( tx.mut_repo(), &command.settings().git_settings(), @@ -98,7 +98,7 @@ pub(crate) fn cmd_init( tx.check_out(&git_head_commit)?; } if tx.mut_repo().has_changes() { - tx.finish(ui)?; + tx.finish(ui, "import git refs")?; } } print_trackable_remote_branches(ui, workspace_command.repo().view())?; diff --git a/cli/src/commands/move.rs b/cli/src/commands/move.rs index 770b63410..ff65ed40e 100644 --- a/cli/src/commands/move.rs +++ b/cli/src/commands/move.rs @@ -66,11 +66,7 @@ pub(crate) fn cmd_move( } workspace_command.check_rewritable([&source, &destination])?; let matcher = workspace_command.matcher_from_values(&args.paths)?; - let mut tx = workspace_command.start_transaction(&format!( - "move changes from {} to {}", - source.id().hex(), - destination.id().hex() - )); + let mut tx = workspace_command.start_transaction(); let parent_tree = merge_commit_trees(tx.repo(), &source.parents())?; let source_tree = source.tree()?; let instructions = format!( @@ -137,6 +133,13 @@ from the source will be moved into the destination. .set_tree_id(new_destination_tree.id().clone()) .set_description(description) .write()?; - tx.finish(ui)?; + tx.finish( + ui, + format!( + "move changes from {} to {}", + source.id().hex(), + destination.id().hex() + ), + )?; Ok(()) } diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index af9afd136..6435bb2f6 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -102,7 +102,7 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.", .into_iter() .collect_vec(); let target_ids = target_commits.iter().map(|c| c.id().clone()).collect_vec(); - let mut tx = workspace_command.start_transaction("new empty commit"); + let mut tx = workspace_command.start_transaction(); let mut num_rebased; let new_commit; if args.insert_before { @@ -206,6 +206,6 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.", if num_rebased > 0 { writeln!(ui.stderr(), "Rebased {num_rebased} descendant commits")?; } - tx.finish(ui)?; + tx.finish(ui, "new empty commit")?; Ok(()) } diff --git a/cli/src/commands/next.rs b/cli/src/commands/next.rs index c4740bf23..b05ebeceb 100644 --- a/cli/src/commands/next.rs +++ b/cli/src/commands/next.rs @@ -115,16 +115,17 @@ pub(crate) fn cmd_next( if edit { // We're editing, the target must be rewritable. workspace_command.check_rewritable([target])?; - let mut tx = workspace_command - .start_transaction(&format!("next: {current_short} -> editing {target_short}")); + let mut tx = workspace_command.start_transaction(); tx.edit(target)?; - tx.finish(ui)?; + tx.finish( + ui, + format!("next: {current_short} -> editing {target_short}"), + )?; return Ok(()); } - let mut tx = - workspace_command.start_transaction(&format!("next: {current_short} -> {target_short}")); + let mut tx = workspace_command.start_transaction(); // Move the working-copy commit to the new parent. tx.check_out(target)?; - tx.finish(ui)?; + tx.finish(ui, format!("next: {current_short} -> {target_short}"))?; Ok(()) } diff --git a/cli/src/commands/operation.rs b/cli/src/commands/operation.rs index 5bc6db376..03166adf3 100644 --- a/cli/src/commands/operation.rs +++ b/cli/src/commands/operation.rs @@ -200,8 +200,7 @@ pub fn cmd_op_undo( return Err(user_error("Cannot undo a merge operation")); } - let mut tx = - workspace_command.start_transaction(&format!("undo operation {}", bad_op.id().hex())); + let mut tx = workspace_command.start_transaction(); let repo_loader = tx.base_repo().loader(); let bad_repo = repo_loader.load_at(&bad_op)?; let parent_repo = repo_loader.load_at(&parent_op)?; @@ -212,7 +211,7 @@ pub fn cmd_op_undo( &args.what, ); tx.mut_repo().set_view(new_view); - tx.finish(ui)?; + tx.finish(ui, format!("undo operation {}", bad_op.id().hex()))?; Ok(()) } @@ -224,15 +223,14 @@ fn cmd_op_restore( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let target_op = workspace_command.resolve_single_op(&args.operation)?; - let mut tx = workspace_command - .start_transaction(&format!("restore to operation {}", target_op.id().hex())); + let mut tx = workspace_command.start_transaction(); let new_view = view_with_desired_portions_restored( target_op.view()?.store_view(), tx.base_repo().view().store_view(), &args.what, ); tx.mut_repo().set_view(new_view); - tx.finish(ui)?; + tx.finish(ui, format!("restore to operation {}", target_op.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/prev.rs b/cli/src/commands/prev.rs index e5f2c027b..8056edefe 100644 --- a/cli/src/commands/prev.rs +++ b/cli/src/commands/prev.rs @@ -109,15 +109,16 @@ pub(crate) fn cmd_prev( if edit { // The target must be rewritable if we're editing. workspace_command.check_rewritable([target])?; - let mut tx = workspace_command - .start_transaction(&format!("prev: {current_short} -> editing {target_short}")); + let mut tx = workspace_command.start_transaction(); tx.edit(target)?; - tx.finish(ui)?; + tx.finish( + ui, + format!("prev: {current_short} -> editing {target_short}"), + )?; return Ok(()); } - let mut tx = - workspace_command.start_transaction(&format!("prev: {current_short} -> {target_short}")); + let mut tx = workspace_command.start_transaction(); tx.check_out(target)?; - tx.finish(ui)?; + tx.finish(ui, format!("prev: {current_short} -> {target_short}"))?; Ok(()) } diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index fd172e1a3..f20cd1908 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -285,7 +285,7 @@ fn rebase_descendants( } else { format!("rebase {} commits and their descendants", old_commits.len()) }; - let mut tx = workspace_command.start_transaction(&tx_message); + let mut tx = workspace_command.start_transaction(); // `rebase_descendants` takes care of sorting in reverse topological order, so // no need to do it here. for old_commit in old_commits { @@ -301,7 +301,7 @@ fn rebase_descendants( + tx.mut_repo() .rebase_descendants_with_options(settings, rebase_options)?; writeln!(ui.stderr(), "Rebased {num_rebased} commits")?; - tx.finish(ui)?; + tx.finish(ui, tx_message)?; Ok(()) } @@ -333,8 +333,7 @@ fn rebase_revision( debug_assert!(workspace_command.check_rewritable(&child_commits).is_ok()); // First, rebase the children of `old_commit`. - let mut tx = - workspace_command.start_transaction(&format!("rebase commit {}", old_commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let mut rebased_commit_ids = HashMap::new(); for child_commit in &child_commits { let new_child_parent_ids: Vec = child_commit @@ -430,7 +429,7 @@ fn rebase_revision( commit" )?; } - tx.finish(ui)?; + tx.finish(ui, format!("rebase commit {}", old_commit.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/resolve.rs b/cli/src/commands/resolve.rs index d0dd5fc51..2ca605c73 100644 --- a/cli/src/commands/resolve.rs +++ b/cli/src/commands/resolve.rs @@ -95,17 +95,17 @@ pub(crate) fn cmd_resolve( let (repo_path, _) = conflicts.first().unwrap(); workspace_command.check_rewritable([&commit])?; - let mut tx = workspace_command.start_transaction(&format!( - "Resolve conflicts in commit {}", - commit.id().hex() - )); + let mut tx = workspace_command.start_transaction(); let new_tree_id = tx.run_mergetool(ui, &tree, repo_path)?; let new_commit = tx .mut_repo() .rewrite_commit(command.settings(), &commit) .set_tree_id(new_tree_id) .write()?; - tx.finish(ui)?; + tx.finish( + ui, + format!("Resolve conflicts in commit {}", commit.id().hex()), + )?; if !args.quiet { let new_tree = new_commit.tree()?; diff --git a/cli/src/commands/restore.rs b/cli/src/commands/restore.rs index 66a30f2d6..cb83caa4a 100644 --- a/cli/src/commands/restore.rs +++ b/cli/src/commands/restore.rs @@ -102,8 +102,7 @@ pub(crate) fn cmd_restore( if &new_tree_id == to_commit.tree_id() { writeln!(ui.stderr(), "Nothing changed.")?; } else { - let mut tx = workspace_command - .start_transaction(&format!("restore into commit {}", to_commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let mut_repo = tx.mut_repo(); let new_commit = mut_repo .rewrite_commit(command.settings(), &to_commit) @@ -118,7 +117,7 @@ pub(crate) fn cmd_restore( if num_rebased > 0 { writeln!(ui.stderr(), "Rebased {num_rebased} descendant commits")?; } - tx.finish(ui)?; + tx.finish(ui, format!("restore into commit {}", to_commit.id().hex()))?; } Ok(()) } diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index b84223c04..7fe391452 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -59,8 +59,7 @@ pub(crate) fn cmd_split( let commit = workspace_command.resolve_single_rev(&args.revision, ui)?; workspace_command.check_rewritable([&commit])?; let matcher = workspace_command.matcher_from_values(&args.paths)?; - let mut tx = - workspace_command.start_transaction(&format!("split commit {}", commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let end_tree = commit.tree()?; let base_tree = merge_commit_trees(tx.repo(), &commit.parents())?; let interactive = args.interactive || args.paths.is_empty(); @@ -152,6 +151,6 @@ don't make any changes, then the operation will be aborted. write!(ui.stderr(), "\nSecond part: ")?; tx.write_commit_summary(ui.stderr_formatter().as_mut(), &second_commit)?; writeln!(ui.stderr())?; - tx.finish(ui)?; + tx.finish(ui, format!("split commit {}", commit.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index 8bd45d55b..cd8123e7a 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -63,8 +63,7 @@ pub(crate) fn cmd_squash( let parent = &parents[0]; workspace_command.check_rewritable(&parents[..1])?; let matcher = workspace_command.matcher_from_values(&args.paths)?; - let mut tx = - workspace_command.start_transaction(&format!("squash commit {}", commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let instructions = format!( "\ You are moving changes from: {} @@ -143,6 +142,6 @@ from the source will be moved into the parent. .set_parents(vec![new_parent.id().clone()]) .write()?; } - tx.finish(ui)?; + tx.finish(ui, format!("squash commit {}", commit.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/unsquash.rs b/cli/src/commands/unsquash.rs index 2ccc911b4..d0140b8ea 100644 --- a/cli/src/commands/unsquash.rs +++ b/cli/src/commands/unsquash.rs @@ -58,8 +58,7 @@ pub(crate) fn cmd_unsquash( } let parent = &parents[0]; workspace_command.check_rewritable(&parents[..1])?; - let mut tx = - workspace_command.start_transaction(&format!("unsquash commit {}", commit.id().hex())); + let mut tx = workspace_command.start_transaction(); let parent_base_tree = merge_commit_trees(tx.repo(), &parent.parents())?; let new_parent_tree_id; if args.interactive { @@ -117,6 +116,6 @@ aborted. .set_parents(vec![new_parent.id().clone()]) .write()?; } - tx.finish(ui)?; + tx.finish(ui, format!("unsquash commit {}", commit.id().hex()))?; Ok(()) } diff --git a/cli/src/commands/untrack.rs b/cli/src/commands/untrack.rs index 621986e11..445ee97db 100644 --- a/cli/src/commands/untrack.rs +++ b/cli/src/commands/untrack.rs @@ -42,9 +42,7 @@ pub(crate) fn cmd_untrack( let store = workspace_command.repo().store().clone(); let matcher = workspace_command.matcher_from_values(&args.paths)?; - let mut tx = workspace_command - .start_transaction("untrack paths") - .into_inner(); + let mut tx = workspace_command.start_transaction().into_inner(); let base_ignores = workspace_command.base_ignores(); let (mut locked_ws, wc_commit) = workspace_command.start_working_copy_mutation()?; // Create a new tree without the unwanted files @@ -100,7 +98,7 @@ Make sure they're ignored, then try again.", if num_rebased > 0 { writeln!(ui.stderr(), "Rebased {num_rebased} descendant commits")?; } - let repo = tx.commit(); + let repo = tx.commit("untrack paths"); locked_ws.finish(repo.op_id().clone())?; Ok(()) } diff --git a/cli/src/commands/workspace.rs b/cli/src/commands/workspace.rs index fa33c391a..f0e94a588 100644 --- a/cli/src/commands/workspace.rs +++ b/cli/src/commands/workspace.rs @@ -164,10 +164,7 @@ fn cmd_workspace_add( )?; let mut new_workspace_command = WorkspaceCommandHelper::new(ui, command, new_workspace, repo)?; - let mut tx = new_workspace_command.start_transaction(&format!( - "Create initial working-copy commit in workspace {}", - &name - )); + let mut tx = new_workspace_command.start_transaction(); // If no parent revisions are specified, create a working-copy commit based // on the parent of the current working-copy commit. @@ -197,7 +194,10 @@ fn cmd_workspace_add( .write()?; tx.edit(&new_wc_commit)?; - tx.finish(ui)?; + tx.finish( + ui, + format!("Create initial working-copy commit in workspace {}", &name), + )?; Ok(()) } @@ -247,9 +247,9 @@ fn cmd_workspace_forget( // bundle every workspace forget into a single transaction, so that e.g. // undo correctly restores all of them at once. - let mut tx = workspace_command.start_transaction(&description); + let mut tx = workspace_command.start_transaction(); wss.iter().for_each(|ws| tx.mut_repo().remove_wc_commit(ws)); - tx.finish(ui)?; + tx.finish(ui, description)?; Ok(()) } diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 6fd87ee43..9b4b35779 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -294,10 +294,9 @@ impl ReadonlyRepo { pub fn start_transaction( self: &Arc, user_settings: &UserSettings, - description: &str, ) -> Transaction { let mut_repo = MutableRepo::new(self.clone(), self.readonly_index(), &self.view); - Transaction::new(mut_repo, user_settings, description) + Transaction::new(mut_repo, user_settings) } pub fn reload_at_head( @@ -707,12 +706,14 @@ impl RepoLoader { user_settings: &UserSettings, ) -> Result { let base_repo = self.load_at(&op_heads[0])?; - let mut tx = base_repo.start_transaction(user_settings, "resolve concurrent operations"); + let mut tx = base_repo.start_transaction(user_settings); for other_op_head in op_heads.into_iter().skip(1) { tx.merge_operation(other_op_head)?; tx.mut_repo().rebase_descendants(user_settings)?; } - let merged_repo = tx.write().leave_unpublished(); + let merged_repo = tx + .write("resolve concurrent operations") + .leave_unpublished(); Ok(merged_repo.operation().clone()) } diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 6a0c382fd..eeef3f208 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -35,13 +35,9 @@ pub struct Transaction { } impl Transaction { - pub fn new( - mut_repo: MutableRepo, - user_settings: &UserSettings, - description: &str, - ) -> Transaction { + pub fn new(mut_repo: MutableRepo, user_settings: &UserSettings) -> Transaction { let parent_ops = vec![mut_repo.base_repo().operation().clone()]; - let op_metadata = create_op_metadata(user_settings, description.to_string()); + let op_metadata = create_op_metadata(user_settings, "".to_string()); let end_time = user_settings.operation_timestamp(); Transaction { mut_repo, @@ -55,10 +51,6 @@ impl Transaction { self.mut_repo.base_repo() } - pub fn set_description(&mut self, description: &str) { - self.op_metadata.description = description.to_string(); - } - pub fn set_tag(&mut self, key: String, value: String) { self.op_metadata.tags.insert(key, value); } @@ -89,14 +81,14 @@ impl Transaction { } /// Writes the transaction to the operation store and publishes it. - pub fn commit(self) -> Arc { - self.write().publish() + pub fn commit(self, description: impl Into) -> Arc { + self.write(description).publish() } /// Writes the transaction to the operation store, but does not publish it. /// That means that a repo can be loaded at the operation, but the /// operation will not be seen when loading the repo at head. - pub fn write(mut self) -> UnpublishedOperation { + pub fn write(mut self, description: impl Into) -> UnpublishedOperation { let mut_repo = self.mut_repo; // TODO: Should we instead just do the rebasing here if necessary? assert!( @@ -107,6 +99,7 @@ impl Transaction { let (mut_index, view) = mut_repo.consume(); let view_id = base_repo.op_store().write_view(view.store_view()).unwrap(); + self.op_metadata.description = description.into(); self.op_metadata.end_time = self.end_time.unwrap_or_else(Timestamp::now); let parents = self.parent_ops.iter().map(|op| op.id().clone()).collect(); let store_operation = op_store::Operation { diff --git a/lib/src/workspace.rs b/lib/src/workspace.rs index 3138406b8..4bef895cc 100644 --- a/lib/src/workspace.rs +++ b/lib/src/workspace.rs @@ -106,16 +106,13 @@ fn init_working_copy( let working_copy_state_path = jj_dir.join("working_copy"); std::fs::create_dir(&working_copy_state_path).context(&working_copy_state_path)?; - let mut tx = repo.start_transaction( - user_settings, - &format!("add workspace '{}'", workspace_id.as_str()), - ); + let mut tx = repo.start_transaction(user_settings); tx.mut_repo().check_out( workspace_id.clone(), user_settings, &repo.store().root_commit(), )?; - let repo = tx.commit(); + let repo = tx.commit(format!("add workspace '{}'", workspace_id.as_str())); let working_copy = working_copy_initializer( repo.store().clone(), diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index cfa9a8faa..da5700c7f 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -105,12 +105,12 @@ fn test_bad_locking_children(backend: TestRepoBackend) { let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let initial = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![repo.store().root_commit_id().clone()]) .write() .unwrap(); - tx.commit(); + tx.commit("test"); // Simulate a write of a commit that happens on one machine let machine1_root = test_workspace.root_dir().join("machine1"); @@ -126,12 +126,12 @@ fn test_bad_locking_children(backend: TestRepoBackend) { .repo_loader() .load_at_head(&settings) .unwrap(); - let mut machine1_tx = machine1_repo.start_transaction(&settings, "test"); + let mut machine1_tx = machine1_repo.start_transaction(&settings); let child1 = create_random_commit(machine1_tx.mut_repo(), &settings) .set_parents(vec![initial.id().clone()]) .write() .unwrap(); - machine1_tx.commit(); + machine1_tx.commit("test"); // Simulate a write of a commit that happens on another machine let machine2_root = test_workspace.root_dir().join("machine2"); @@ -147,12 +147,12 @@ fn test_bad_locking_children(backend: TestRepoBackend) { .repo_loader() .load_at_head(&settings) .unwrap(); - let mut machine2_tx = machine2_repo.start_transaction(&settings, "test"); + let mut machine2_tx = machine2_repo.start_transaction(&settings); let child2 = create_random_commit(machine2_tx.mut_repo(), &settings) .set_parents(vec![initial.id().clone()]) .write() .unwrap(); - machine2_tx.commit(); + machine2_tx.commit("test"); // Simulate that the distributed file system now has received the changes from // both machines @@ -186,12 +186,12 @@ fn test_bad_locking_interrupted(backend: TestRepoBackend) { let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let initial = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![repo.store().root_commit_id().clone()]) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // Simulate a crash that resulted in the old op-head left in place. We simulate // it somewhat hackily by copying the .jj/op_heads/ directory before the @@ -200,12 +200,12 @@ fn test_bad_locking_interrupted(backend: TestRepoBackend) { let op_heads_dir = repo.repo_path().join("op_heads"); let backup_path = test_workspace.root_dir().join("backup"); copy_directory(&op_heads_dir, &backup_path); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![initial.id().clone()]) .write() .unwrap(); - let op_id = tx.commit().operation().id().clone(); + let op_id = tx.commit("test").operation().id().clone(); copy_directory(&backup_path, &op_heads_dir); // Reload the repo and check that only the new head is present. diff --git a/lib/tests/test_commit_builder.rs b/lib/tests/test_commit_builder.rs index 12cbde7fb..4d3816273 100644 --- a/lib/tests/test_commit_builder.rs +++ b/lib/tests/test_commit_builder.rs @@ -43,7 +43,7 @@ fn test_initial(backend: TestRepoBackend) { ], ); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let author_signature = Signature { name: "author name".to_string(), email: "author email".to_string(), @@ -75,7 +75,7 @@ fn test_initial(backend: TestRepoBackend) { assert_eq!(builder.author(), &author_signature); assert_eq!(builder.committer(), &committer_signature); let commit = builder.write().unwrap(); - tx.commit(); + tx.commit("test"); assert_eq!(commit.parents(), vec![store.root_commit()]); assert_eq!(commit.predecessors(), vec![]); @@ -115,7 +115,7 @@ fn test_rewrite(backend: TestRepoBackend) { ], ); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let initial_commit = tx .mut_repo() .new_commit( @@ -125,7 +125,7 @@ fn test_rewrite(backend: TestRepoBackend) { ) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let rewritten_tree = create_tree( &repo, @@ -143,7 +143,7 @@ fn test_rewrite(backend: TestRepoBackend) { .build() .unwrap(); let rewrite_settings = UserSettings::from_config(config); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let rewritten_commit = tx .mut_repo() .rewrite_commit(&rewrite_settings, &initial_commit) @@ -151,7 +151,7 @@ fn test_rewrite(backend: TestRepoBackend) { .write() .unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - tx.commit(); + tx.commit("test"); assert_eq!(rewritten_commit.parents(), vec![store.root_commit()]); assert_eq!( rewritten_commit.predecessors(), @@ -203,7 +203,7 @@ fn test_rewrite_update_missing_user(backend: TestRepoBackend) { let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&missing_user_settings, "test"); + let mut tx = repo.start_transaction(&missing_user_settings); let initial_commit = tx .mut_repo() .new_commit( @@ -252,15 +252,15 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) { let repo = &test_repo.repo; let store = repo.store().clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); let commit3 = graph_builder.commit_with_parents(&[&commit2]); - let repo = tx.commit(); + let repo = tx.commit("test"); // Test with for_new_commit() - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo() .new_commit( &settings, @@ -273,7 +273,7 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) { assert!(rebaser.rebase_next().unwrap().is_none()); // Test with for_rewrite_from() - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit4 = tx .mut_repo() .rewrite_commit(&settings, &commit2) @@ -284,7 +284,7 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) { assert!(rebaser.rebase_next().unwrap().is_none()); // Test with for_rewrite_from() but new change id - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo() .rewrite_commit(&settings, &commit2) .generate_new_change_id() diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index 4cde11ae2..f9fcd2637 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -54,9 +54,9 @@ fn test_commit_parallel(backend: TestRepoBackend) { let settings = settings.clone(); let repo = repo.clone(); s.spawn(move || { - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); write_random_commit(tx.mut_repo(), &settings); - tx.commit(); + tx.commit("test"); }); } }); @@ -85,9 +85,9 @@ fn test_commit_parallel_instances(backend: TestRepoBackend) { let settings = settings.clone(); let repo = load_repo_at_head(&settings, repo.repo_path()); s.spawn(move || { - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); write_random_commit(tx.mut_repo(), &settings); - tx.commit(); + tx.commit("test"); }); } }); diff --git a/lib/tests/test_default_revset_graph_iterator.rs b/lib/tests/test_default_revset_graph_iterator.rs index 60b566680..95b412de7 100644 --- a/lib/tests/test_default_revset_graph_iterator.rs +++ b/lib/tests/test_default_revset_graph_iterator.rs @@ -64,13 +64,13 @@ fn test_graph_iterator_linearized(skip_transitive_edges: bool) { // A ~ // | // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); let commit_c = graph_builder.commit_with_parents(&[&commit_a]); let commit_d = graph_builder.commit_with_parents(&[&commit_b, &commit_c]); - let repo = tx.commit(); + let repo = tx.commit("test"); let root_commit = repo.store().root_commit(); let revset = revset_for_commits(repo.as_ref(), &[&commit_a, &commit_d]); @@ -102,7 +102,7 @@ fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) { // A B C A B C // \|/ ~ ~ ~ // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.initial_commit(); @@ -110,7 +110,7 @@ fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) { let commit_d = graph_builder.commit_with_parents(&[&commit_a, &commit_b]); let commit_e = graph_builder.commit_with_parents(&[&commit_b, &commit_c]); let commit_f = graph_builder.commit_with_parents(&[&commit_d, &commit_e]); - let repo = tx.commit(); + let repo = tx.commit("test"); let root_commit = repo.store().root_commit(); let revset = revset_for_commits(repo.as_ref(), &[&commit_a, &commit_b, &commit_c, &commit_f]); @@ -154,14 +154,14 @@ fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) { // A // | // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); let commit_c = graph_builder.commit_with_parents(&[&commit_b]); let commit_d = graph_builder.commit_with_parents(&[&commit_b]); let commit_e = graph_builder.commit_with_parents(&[&commit_d]); - let repo = tx.commit(); + let repo = tx.commit("test"); let root_commit = repo.store().root_commit(); let revset = revset_for_commits(repo.as_ref(), &[&commit_a, &commit_c, &commit_e]); @@ -194,7 +194,7 @@ fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) { // a B c ~ // \|/ // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.initial_commit(); @@ -202,7 +202,7 @@ fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) { let commit_d = graph_builder.commit_with_parents(&[&commit_a, &commit_b]); let commit_e = graph_builder.commit_with_parents(&[&commit_b, &commit_c]); let commit_f = graph_builder.commit_with_parents(&[&commit_d, &commit_e]); - let repo = tx.commit(); + let repo = tx.commit("test"); let root_commit = repo.store().root_commit(); let revset = revset_for_commits(repo.as_ref(), &[&commit_b, &commit_f]); @@ -239,7 +239,7 @@ fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) { // a // | // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.initial_commit(); @@ -247,7 +247,7 @@ fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) { let commit_d = graph_builder.commit_with_parents(&[&commit_b, &commit_c]); let commit_e = graph_builder.commit_with_parents(&[&commit_c]); let commit_f = graph_builder.commit_with_parents(&[&commit_d, &commit_e]); - let repo = tx.commit(); + let repo = tx.commit("test"); let revset = revset_for_commits(repo.as_ref(), &[&commit_c, &commit_d, &commit_f]); let commits = revset @@ -290,7 +290,7 @@ fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) { // A // | // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -302,7 +302,7 @@ fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) { let commit_h = graph_builder.commit_with_parents(&[&commit_f]); let commit_i = graph_builder.commit_with_parents(&[&commit_e, &commit_h]); let commit_j = graph_builder.commit_with_parents(&[&commit_g, &commit_i]); - let repo = tx.commit(); + let repo = tx.commit("test"); let root_commit = repo.store().root_commit(); let revset = revset_for_commits( diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index 8e4f24cf9..532646603 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -106,10 +106,10 @@ fn test_import_refs() { git_repo.set_head("refs/heads/main").unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let stats = git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let view = repo.view(); assert!(stats.abandoned_commits.is_empty()); @@ -225,10 +225,10 @@ fn test_import_refs_reimport() { .reference("refs/tags/my-gpg-key", pgp_key_oid, false, "") .unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let stats = git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert!(stats.abandoned_commits.is_empty()); let expected_heads = hashset! { @@ -244,19 +244,19 @@ fn test_import_refs_reimport() { let commit5 = empty_git_commit(&git_repo, "refs/heads/feature2", &[&commit2]); // Also modify feature2 on the jj side - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit6 = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![jj_id(&commit2)]) .write() .unwrap(); tx.mut_repo() .set_local_branch_target("feature2", RefTarget::normal(commit6.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let stats = git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!( // The order is unstable just because we import heads from Git repo. @@ -329,7 +329,7 @@ fn test_import_refs_reimport_head_removed() { let git_repo = get_git_repo(repo); let commit = empty_git_commit(&git_repo, "refs/heads/main", &[]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); let commit_id = jj_id(&commit); @@ -356,7 +356,7 @@ fn test_import_refs_reimport_git_head_counts() { let commit = empty_git_commit(&git_repo, "refs/heads/main", &[]); git_repo.set_head_detached(commit.id()).unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); @@ -382,7 +382,7 @@ fn test_import_refs_reimport_git_head_without_ref() { let git_repo = get_git_repo(repo); // First, HEAD points to commit1. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit1 = write_random_commit(tx.mut_repo(), &settings); let commit2 = write_random_commit(tx.mut_repo(), &settings); git_repo.set_head_detached(git_id(&commit1)).unwrap(); @@ -416,7 +416,7 @@ fn test_import_refs_reimport_git_head_with_moved_ref() { let git_repo = get_git_repo(repo); // First, both HEAD and main point to commit1. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit1 = write_random_commit(tx.mut_repo(), &settings); let commit2 = write_random_commit(tx.mut_repo(), &settings); git_repo @@ -469,10 +469,10 @@ fn test_import_refs_reimport_with_deleted_remote_ref() { commit_remote_and_local.id(), ); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let expected_heads = hashset! { jj_id(&commit_main), @@ -525,10 +525,10 @@ fn test_import_refs_reimport_with_deleted_remote_ref() { delete_git_ref(&git_repo, "refs/remotes/origin/feature-remote-only"); delete_git_ref(&git_repo, "refs/remotes/origin/feature-remote-and-local"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let view = repo.view(); // The local branches were indeed deleted @@ -585,10 +585,10 @@ fn test_import_refs_reimport_with_moved_remote_ref() { commit_remote_and_local.id(), ); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let expected_heads = hashset! { jj_id(&commit_main), @@ -651,10 +651,10 @@ fn test_import_refs_reimport_with_moved_remote_ref() { &[&commit_base], ); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let view = repo.view(); assert_eq!(view.branches().count(), 3); @@ -718,10 +718,10 @@ fn test_import_refs_reimport_with_moved_untracked_remote_ref() { let remote_ref_name = "refs/remotes/origin/feature"; let commit_base = empty_git_commit(&git_repo, remote_ref_name, &[]); let commit_remote_t0 = empty_git_commit(&git_repo, remote_ref_name, &[&commit_base]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let view = repo.view(); assert_eq!(*view.heads(), hashset! { jj_id(&commit_remote_t0) }); @@ -738,10 +738,10 @@ fn test_import_refs_reimport_with_moved_untracked_remote_ref() { // Move the reference remotely and fetch the changes. delete_git_ref(&git_repo, remote_ref_name); let commit_remote_t1 = empty_git_commit(&git_repo, remote_ref_name, &[&commit_base]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let view = repo.view(); // commit_remote_t0 should be abandoned, but commit_base shouldn't because @@ -768,7 +768,7 @@ fn test_import_refs_reimport_git_head_with_fixed_ref() { let git_repo = get_git_repo(repo); // First, both HEAD and main point to commit1. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit1 = write_random_commit(tx.mut_repo(), &settings); let commit2 = write_random_commit(tx.mut_repo(), &settings); git_repo @@ -803,7 +803,7 @@ fn test_import_refs_reimport_all_from_root_removed() { let git_repo = get_git_repo(repo); let commit = empty_git_commit(&git_repo, "refs/heads/main", &[]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); // Test the setup @@ -834,7 +834,7 @@ fn test_import_refs_reimport_abandoning_disabled() { let commit1 = empty_git_commit(&git_repo, "refs/heads/main", &[]); let commit2 = empty_git_commit(&git_repo, "refs/heads/delete-me", &[&commit1]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); // Test the setup @@ -861,12 +861,12 @@ fn test_import_refs_reimport_conflicted_remote_branch() { let commit1 = empty_git_commit(&git_repo, "refs/heads/commit1", &[]); git_ref(&git_repo, "refs/remotes/origin/main", commit1.id()); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); git::import_refs(tx1.mut_repo(), &git_settings).unwrap(); let commit2 = empty_git_commit(&git_repo, "refs/heads/commit2", &[]); git_ref(&git_repo, "refs/remotes/origin/main", commit2.id()); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); git::import_refs(tx2.mut_repo(), &git_settings).unwrap(); // Remote branch can diverge by concurrent operations (like `jj git fetch`) @@ -884,9 +884,9 @@ fn test_import_refs_reimport_conflicted_remote_branch() { ); // The conflict can be resolved by importing the current Git state - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!( repo.view().get_git_ref("refs/remotes/origin/main"), &RefTarget::normal(jj_id(&commit2)), @@ -910,7 +910,7 @@ fn test_import_refs_reserved_remote_name() { empty_git_commit(&git_repo, "refs/remotes/git/main", &[]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let result = git::import_refs(tx.mut_repo(), &git_settings); assert_matches!(result, Err(GitImportError::RemoteReservedForLocalGitRepo)); } @@ -943,7 +943,7 @@ fn test_import_some_refs() { } // Import branches feature1, feature2, and feature3. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| { get_remote_branch(ref_name) .map(|branch| branch.starts_with("feature")) @@ -951,7 +951,7 @@ fn test_import_some_refs() { }) .unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // There are two heads, feature2 and feature4. let view = repo.view(); @@ -1022,13 +1022,13 @@ fn test_import_some_refs() { delete_git_ref(&git_repo, "refs/remotes/origin/feature1"); delete_git_ref(&git_repo, "refs/remotes/origin/feature3"); delete_git_ref(&git_repo, "refs/remotes/origin/feature4"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| { get_remote_branch(ref_name) == Some("feature2") }) .unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // feature2 and feature4 will still be heads, and all four branches should be // present. @@ -1038,14 +1038,14 @@ fn test_import_some_refs() { // Import feature1: this should cause the branch to be deleted, but the // corresponding commit should stay because it is reachable from feature2. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| { get_remote_branch(ref_name) == Some("feature1") }) .unwrap(); // No descendant should be rewritten. assert_eq!(tx.mut_repo().rebase_descendants(&settings).unwrap(), 0); - let repo = tx.commit(); + let repo = tx.commit("test"); // feature2 and feature4 should still be the heads, and all three branches // feature2, feature3, and feature3 should exist. @@ -1055,14 +1055,14 @@ fn test_import_some_refs() { // Import feature3: this should cause the branch to be deleted, but // feature4 should be left alone even though it is no longer in git. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| { get_remote_branch(ref_name) == Some("feature3") }) .unwrap(); // No descendant should be rewritten assert_eq!(tx.mut_repo().rebase_descendants(&settings).unwrap(), 0); - let repo = tx.commit(); + let repo = tx.commit("test"); // feature2 and feature4 should still be the heads, and both branches // should exist. @@ -1071,14 +1071,14 @@ fn test_import_some_refs() { assert_eq!(*view.heads(), expected_heads); // Import feature4: both the head and the branch will disappear. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| { get_remote_branch(ref_name) == Some("feature4") }) .unwrap(); // No descendant should be rewritten assert_eq!(tx.mut_repo().rebase_descendants(&settings).unwrap(), 0); - let repo = tx.commit(); + let repo = tx.commit("test"); // feature2 should now be the only head and only branch. let view = repo.view(); @@ -1148,14 +1148,12 @@ fn test_import_refs_empty_git_repo() { let test_data = GitRepoData::create(); let git_settings = GitSettings::default(); let heads_before = test_data.repo.view().heads().clone(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo() .rebase_descendants(&test_data.settings) .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!(*repo.view().heads(), heads_before); assert_eq!(repo.view().branches().count(), 0); assert_eq!(repo.view().tags().len(), 0); @@ -1183,7 +1181,7 @@ fn test_import_refs_missing_git_commit() { // Missing commit is ancestor of ref git_repo.set_head("refs/heads/unborn").unwrap(); fs::rename(&object_file, &backup_object_file).unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let result = git::import_refs(tx.mut_repo(), &git_settings); assert_matches!( result, @@ -1200,7 +1198,7 @@ fn test_import_refs_missing_git_commit() { .delete() .unwrap(); git_repo.set_head_detached(commit2.id()).unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let result = git::import_refs(tx.mut_repo(), &git_settings); assert_matches!( result, @@ -1218,7 +1216,7 @@ fn test_import_refs_missing_git_commit() { .unwrap(); git_repo.set_head("refs/heads/unborn").unwrap(); fs::rename(&object_file, &backup_object_file).unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let result = git::import_refs(tx.mut_repo(), &git_settings); assert!(result.is_ok()); @@ -1232,7 +1230,7 @@ fn test_import_refs_missing_git_commit() { .unwrap(); git_repo.set_head_detached(commit1.id()).unwrap(); fs::rename(&object_file, &backup_object_file).unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let result = git::import_refs(tx.mut_repo(), &git_settings); assert!(result.is_ok()); } @@ -1252,14 +1250,12 @@ fn test_import_refs_detached_head() { .unwrap(); test_data.git_repo.set_head_detached(commit1.id()).unwrap(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo() .rebase_descendants(&test_data.settings) .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let expected_heads = hashset! { jj_id(&commit1) }; assert_eq!(*repo.view().heads(), expected_heads); @@ -1276,9 +1272,7 @@ fn test_export_refs_no_detach() { let git_repo = test_data.git_repo; let commit1 = empty_git_commit(&git_repo, "refs/heads/main", &[]); git_repo.set_head("refs/heads/main").unwrap(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); git::import_refs(mut_repo, &git_settings).unwrap(); mut_repo.rebase_descendants(&test_data.settings).unwrap(); @@ -1308,9 +1302,7 @@ fn test_export_refs_branch_changed() { .unwrap(); git_repo.set_head("refs/heads/feature").unwrap(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); git::import_refs(mut_repo, &git_settings).unwrap(); mut_repo.rebase_descendants(&test_data.settings).unwrap(); @@ -1347,9 +1339,7 @@ fn test_export_refs_current_branch_changed() { let git_repo = test_data.git_repo; let commit1 = empty_git_commit(&git_repo, "refs/heads/main", &[]); git_repo.set_head("refs/heads/main").unwrap(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); git::import_refs(mut_repo, &git_settings).unwrap(); mut_repo.rebase_descendants(&test_data.settings).unwrap(); @@ -1384,9 +1374,7 @@ fn test_export_refs_unborn_git_branch() { let git_settings = GitSettings::default(); let git_repo = test_data.git_repo; git_repo.set_head("refs/heads/main").unwrap(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); git::import_refs(mut_repo, &git_settings).unwrap(); mut_repo.rebase_descendants(&test_data.settings).unwrap(); @@ -1422,9 +1410,7 @@ fn test_export_import_sequence() { let test_data = GitRepoData::create(); let git_settings = GitSettings::default(); let git_repo = test_data.git_repo; - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); let commit_a = write_random_commit(mut_repo, &test_data.settings); let commit_b = write_random_commit(mut_repo, &test_data.settings); @@ -1479,9 +1465,7 @@ fn test_import_export_non_tracking_branch() { let git_repo = test_data.git_repo; let commit_main_t0 = empty_git_commit(&git_repo, "refs/remotes/origin/main", &[]); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); git::import_refs(mut_repo, &git_settings).unwrap(); @@ -1563,9 +1547,7 @@ fn test_export_conflicts() { // We skip export of conflicted branches let test_data = GitRepoData::create(); let git_repo = test_data.git_repo; - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); let commit_a = write_random_commit(mut_repo, &test_data.settings); let commit_b = write_random_commit(mut_repo, &test_data.settings); @@ -1623,9 +1605,7 @@ fn test_export_conflicts() { fn test_export_branch_on_root_commit() { // We skip export of branches pointing to the root commit let test_data = GitRepoData::create(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); mut_repo.set_local_branch_target( "on_root", @@ -1642,9 +1622,7 @@ fn test_export_partial_failure() { // Check that we skip branches that fail to export let test_data = GitRepoData::create(); let git_repo = test_data.git_repo; - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); let commit_a = write_random_commit(mut_repo, &test_data.settings); let target = RefTarget::normal(commit_a.id().clone()); @@ -1729,9 +1707,7 @@ fn test_export_reexport_transitions() { // Test exporting after making changes on the jj side, or the git side, or both let test_data = GitRepoData::create(); let git_repo = test_data.git_repo; - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); let commit_a = write_random_commit(mut_repo, &test_data.settings); let commit_b = write_random_commit(mut_repo, &test_data.settings); @@ -1869,9 +1845,7 @@ fn test_export_reexport_transitions() { fn test_export_undo_reexport() { let test_data = GitRepoData::create(); let git_repo = test_data.git_repo; - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let mut_repo = tx.mut_repo(); // Initial export @@ -1922,7 +1896,7 @@ fn test_reset_head_to_root() { Workspace::init_external_git(&settings, &workspace_root, &workspace_root.join(".git")) .unwrap(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let root_commit_id = repo.store().root_commit_id(); @@ -2005,9 +1979,7 @@ fn test_fetch_empty_repo() { let test_data = GitRepoData::create(); let git_settings = GitSettings::default(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let stats = git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2030,9 +2002,7 @@ fn test_fetch_initial_commit() { let git_settings = GitSettings::default(); let initial_git_commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let stats = git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2045,7 +2015,7 @@ fn test_fetch_initial_commit() { // No default branch because the origin repo's HEAD wasn't set assert_eq!(stats.default_branch, None); assert!(stats.import_stats.abandoned_commits.is_empty()); - let repo = tx.commit(); + let repo = tx.commit("test"); // The initial commit is visible after git::fetch(). let view = repo.view(); assert!(view.heads().contains(&jj_id(&initial_git_commit))); @@ -2079,9 +2049,7 @@ fn test_fetch_success() { let git_settings = GitSettings::default(); let initial_git_commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2091,7 +2059,7 @@ fn test_fetch_success() { &git_settings, ) .unwrap(); - test_data.repo = tx.commit(); + test_data.repo = tx.commit("test"); test_data.origin_repo.set_head("refs/heads/main").unwrap(); let new_git_commit = empty_git_commit( @@ -2104,9 +2072,7 @@ fn test_fetch_success() { .reference("refs/tags/v1.0", new_git_commit.id(), false, "") .unwrap(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let stats = git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2119,7 +2085,7 @@ fn test_fetch_success() { // The default branch is "main" assert_eq!(stats.default_branch, Some("main".to_string())); assert!(stats.import_stats.abandoned_commits.is_empty()); - let repo = tx.commit(); + let repo = tx.commit("test"); // The new commit is visible after we fetch again let view = repo.view(); assert!(view.heads().contains(&jj_id(&new_git_commit))); @@ -2160,9 +2126,7 @@ fn test_fetch_prune_deleted_ref() { let git_settings = GitSettings::default(); let commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2201,9 +2165,7 @@ fn test_fetch_no_default_branch() { let git_settings = GitSettings::default(); let initial_git_commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2247,9 +2209,7 @@ fn test_fetch_empty_refspecs() { empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]); // Base refspecs shouldn't be respected - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2275,9 +2235,7 @@ fn test_fetch_empty_refspecs() { fn test_fetch_no_such_remote() { let test_data = GitRepoData::create(); let git_settings = GitSettings::default(); - let mut tx = test_data - .repo - .start_transaction(&test_data.settings, "test"); + let mut tx = test_data.repo.start_transaction(&test_data.settings); let result = git::fetch( tx.mut_repo(), &test_data.git_repo, @@ -2332,7 +2290,7 @@ fn set_up_push_repos(settings: &UserSettings, temp_dir: &TempDir) -> PushTestSet .store() .get_commit(&jj_id(&initial_git_commit)) .unwrap(); - let mut tx = jj_repo.start_transaction(settings, "test"); + let mut tx = jj_repo.start_transaction(settings); let new_commit = create_random_commit(tx.mut_repo(), settings) .set_parents(vec![initial_commit.id().clone()]) .write() @@ -2351,7 +2309,7 @@ fn set_up_push_repos(settings: &UserSettings, temp_dir: &TempDir) -> PushTestSet state: RemoteRefState::Tracking, }, ); - let jj_repo = tx.commit(); + let jj_repo = tx.commit("test"); PushTestSetup { source_repo_dir, jj_repo, @@ -2366,7 +2324,7 @@ fn test_push_branches_success() { let temp_dir = testutils::new_temp_dir(); let mut setup = set_up_push_repos(&settings, &temp_dir); let clone_repo = get_git_repo(&setup.jj_repo); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let targets = GitBranchPushTargets { branch_updates: vec![( @@ -2420,8 +2378,8 @@ fn test_push_branches_success() { ); // Check that the repo view reflects the changes in the Git repo - setup.jj_repo = tx.commit(); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + setup.jj_repo = tx.commit("test"); + let mut tx = setup.jj_repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &GitSettings::default()).unwrap(); assert!(!tx.mut_repo().has_changes()); } @@ -2432,7 +2390,7 @@ fn test_push_branches_deletion() { let temp_dir = testutils::new_temp_dir(); let mut setup = set_up_push_repos(&settings, &temp_dir); let clone_repo = get_git_repo(&setup.jj_repo); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let source_repo = git2::Repository::open(&setup.source_repo_dir).unwrap(); // Test the setup @@ -2473,8 +2431,8 @@ fn test_push_branches_deletion() { assert!(view.get_remote_branch("main", "origin").is_absent()); // Check that the repo view reflects the changes in the Git repo - setup.jj_repo = tx.commit(); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + setup.jj_repo = tx.commit("test"); + let mut tx = setup.jj_repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &GitSettings::default()).unwrap(); assert!(!tx.mut_repo().has_changes()); } @@ -2485,7 +2443,7 @@ fn test_push_branches_mixed_deletion_and_addition() { let temp_dir = testutils::new_temp_dir(); let mut setup = set_up_push_repos(&settings, &temp_dir); let clone_repo = get_git_repo(&setup.jj_repo); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let targets = GitBranchPushTargets { branch_updates: vec![ @@ -2543,8 +2501,8 @@ fn test_push_branches_mixed_deletion_and_addition() { ); // Check that the repo view reflects the changes in the Git repo - setup.jj_repo = tx.commit(); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + setup.jj_repo = tx.commit("test"); + let mut tx = setup.jj_repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &GitSettings::default()).unwrap(); assert!(!tx.mut_repo().has_changes()); } @@ -2554,10 +2512,10 @@ fn test_push_branches_not_fast_forward() { let settings = testutils::user_settings(); let temp_dir = testutils::new_temp_dir(); let mut setup = set_up_push_repos(&settings, &temp_dir); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let new_commit = write_random_commit(tx.mut_repo(), &settings); - setup.jj_repo = tx.commit(); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + setup.jj_repo = tx.commit("test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let targets = GitBranchPushTargets { branch_updates: vec![( @@ -2584,10 +2542,10 @@ fn test_push_branches_not_fast_forward_with_force() { let settings = testutils::user_settings(); let temp_dir = testutils::new_temp_dir(); let mut setup = set_up_push_repos(&settings, &temp_dir); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let new_commit = write_random_commit(tx.mut_repo(), &settings); - setup.jj_repo = tx.commit(); - let mut tx = setup.jj_repo.start_transaction(&settings, "test"); + setup.jj_repo = tx.commit("test"); + let mut tx = setup.jj_repo.start_transaction(&settings); let targets = GitBranchPushTargets { branch_updates: vec![( @@ -2709,10 +2667,10 @@ fn test_bulk_update_extra_on_import_refs() { .count() }; let import_refs = |repo: &Arc| { - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - tx.commit() + tx.commit("test") }; // Extra metadata table shouldn't be created per read_commit() call. The number @@ -2748,14 +2706,14 @@ fn test_rewrite_imported_commit() { // Import git commit, which generates change id from the commit id. let git_commit = empty_git_commit(&git_repo, "refs/heads/main", &[]); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let imported_commit = repo.store().get_commit(&jj_id(&git_commit)).unwrap(); // Try to create identical commit with different change id. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let authored_commit = tx .mut_repo() .new_commit( @@ -2768,7 +2726,7 @@ fn test_rewrite_imported_commit() { .set_description(imported_commit.description()) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // Imported commit shouldn't be reused, and the timestamp of the authored // commit should be adjusted to create new commit. @@ -2807,12 +2765,12 @@ fn test_concurrent_write_commit() { let sender = sender.clone(); s.spawn(move || { barrier.wait(); - let mut tx = repo.start_transaction(settings, &format!("writer {i}")); + let mut tx = repo.start_transaction(settings); let commit = create_rooted_commit(tx.mut_repo(), settings) .set_description("racy commit") .write() .unwrap(); - tx.commit(); + tx.commit(format!("writer {i}")); sender .send((commit.id().clone(), commit.change_id().clone())) .unwrap(); @@ -2892,12 +2850,12 @@ fn test_concurrent_read_write_commit() { let barrier = barrier.clone(); s.spawn(move || { barrier.wait(); - let mut tx = repo.start_transaction(settings, &format!("writer {i}")); + let mut tx = repo.start_transaction(settings); let commit = create_rooted_commit(tx.mut_repo(), settings) .set_description(format!("commit {i}")) .write() .unwrap(); - tx.commit(); + tx.commit(format!("writer {i}")); assert_eq!(commit.id(), commit_id); }); } @@ -2918,7 +2876,7 @@ fn test_concurrent_read_write_commit() { } repo = repo.reload_at_head(settings).unwrap(); let git_backend = get_git_backend(&repo); - let mut tx = repo.start_transaction(settings, &format!("reader {i}")); + let mut tx = repo.start_transaction(settings); pending_commit_ids = pending_commit_ids .into_iter() .filter_map(|commit_id| { @@ -2938,7 +2896,7 @@ fn test_concurrent_read_write_commit() { }) .collect_vec(); if tx.mut_repo().has_changes() { - tx.commit(); + tx.commit(format!("reader {i}")); } thread::yield_now(); } diff --git a/lib/tests/test_id_prefix.rs b/lib/tests/test_id_prefix.rs index a09aabf3e..de6b6c399 100644 --- a/lib/tests/test_id_prefix.rs +++ b/lib/tests/test_id_prefix.rs @@ -29,7 +29,7 @@ fn test_id_prefix() { let root_commit_id = repo.store().root_commit_id(); let root_change_id = repo.store().root_change_id(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut create_commit = |parent_id: &CommitId| { let signature = Signature { name: "Some One".to_string(), @@ -54,7 +54,7 @@ fn test_id_prefix() { for _ in 0..25 { commits.push(create_commit(commits.last().unwrap().id())); } - let repo = tx.commit(); + let repo = tx.commit("test"); // Print the commit IDs and change IDs for reference let commit_prefixes = commits diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index 3028328d6..99b410dd2 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -81,7 +81,7 @@ fn test_index_commits_standard_cases() { // o root let root_commit_id = repo.store().root_commit_id(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -91,7 +91,7 @@ fn test_index_commits_standard_cases() { let commit_f = graph_builder.commit_with_parents(&[&commit_b, &commit_e]); let commit_g = graph_builder.commit_with_parents(&[&commit_f]); let commit_h = graph_builder.commit_with_parents(&[&commit_e]); - let repo = tx.commit(); + let repo = tx.commit("test"); let index = as_readonly_composite(&repo); // There should be the root commit, plus 8 more @@ -138,7 +138,7 @@ fn test_index_commits_criss_cross() { // Create a long chain of criss-crossed merges. If they were traversed without // keeping track of visited nodes, it would be 2^50 visits, so if this test // finishes in reasonable time, we know that we don't do a naive traversal. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let mut left_commits = vec![graph_builder.initial_commit()]; let mut right_commits = vec![graph_builder.initial_commit()]; @@ -150,7 +150,7 @@ fn test_index_commits_criss_cross() { left_commits.push(new_left); right_commits.push(new_right); } - let repo = tx.commit(); + let repo = tx.commit("test"); let index = as_readonly_composite(&repo); // There should the root commit, plus 2 for each generation @@ -275,16 +275,16 @@ fn test_index_commits_previous_operations() { // |/ // o root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); let commit_c = graph_builder.commit_with_parents(&[&commit_b]); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo().remove_head(commit_c.id()); - let repo = tx.commit(); + let repo = tx.commit("test"); // Delete index from disk let index_operations_dir = repo.repo_path().join("index").join("operations"); @@ -323,24 +323,24 @@ fn test_index_commits_incremental() { // o root let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a = child_commit(tx.mut_repo(), &settings, &root_commit) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let index = as_readonly_composite(&repo); // There should be the root commit, plus 1 more assert_eq!(index.num_commits(), 1 + 1); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_b = child_commit(tx.mut_repo(), &settings, &commit_a) .write() .unwrap(); let commit_c = child_commit(tx.mut_repo(), &settings, &commit_b) .write() .unwrap(); - tx.commit(); + tx.commit("test"); let repo = load_repo_at_head(&settings, repo.repo_path()); let index = as_readonly_composite(&repo); @@ -374,17 +374,17 @@ fn test_index_commits_incremental_empty_transaction() { // o root let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a = child_commit(tx.mut_repo(), &settings, &root_commit) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let index = as_readonly_composite(&repo); // There should be the root commit, plus 1 more assert_eq!(index.num_commits(), 1 + 1); - repo.start_transaction(&settings, "test").commit(); + repo.start_transaction(&settings).commit("test"); let repo = load_repo_at_head(&settings, repo.repo_path()); let index = as_readonly_composite(&repo); @@ -416,15 +416,15 @@ fn test_index_commits_incremental_already_indexed() { // o root let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a = child_commit(tx.mut_repo(), &settings, &root_commit) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert!(repo.index().has_id(commit_a.id())); assert_eq!(as_readonly_composite(&repo).num_commits(), 1 + 1); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); mut_repo.add_head(&commit_a); assert_eq!(as_mutable_composite(mut_repo).num_commits(), 1 + 1); @@ -436,11 +436,11 @@ fn create_n_commits( repo: &Arc, num_commits: i32, ) -> Arc { - let mut tx = repo.start_transaction(settings, "test"); + let mut tx = repo.start_transaction(settings); for _ in 0..num_commits { write_random_commit(tx.mut_repo(), settings); } - tx.commit() + tx.commit("test") } fn as_readonly_composite(repo: &Arc) -> CompositeIndex<'_> { diff --git a/lib/tests/test_init.rs b/lib/tests/test_init.rs index 973ea5b37..b95bcb4f8 100644 --- a/lib/tests/test_init.rs +++ b/lib/tests/test_init.rs @@ -43,7 +43,7 @@ fn test_init_local() { assert_eq!(workspace.workspace_root(), &canonical); // Just test that we can write a commit to the store - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); write_random_commit(tx.mut_repo(), &settings); } @@ -71,7 +71,7 @@ fn test_init_internal_git() { ); // Just test that we can write a commit to the store - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); write_random_commit(tx.mut_repo(), &settings); } @@ -96,7 +96,7 @@ fn test_init_colocated_git() { ); // Just test that we can write a commit to the store - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); write_random_commit(tx.mut_repo(), &settings); } @@ -134,7 +134,7 @@ fn test_init_external_git() { ); // Just test that we can write a commit to the store - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); write_random_commit(tx.mut_repo(), &settings); } diff --git a/lib/tests/test_load_repo.rs b/lib/tests/test_load_repo.rs index 241145dde..96092a9ba 100644 --- a/lib/tests/test_load_repo.rs +++ b/lib/tests/test_load_repo.rs @@ -21,13 +21,13 @@ fn test_load_at_operation() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "add commit"); + let mut tx = repo.start_transaction(&settings); let commit = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("add commit"); - let mut tx = repo.start_transaction(&settings, "remove commit"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo().remove_head(commit.id()); - tx.commit(); + tx.commit("remove commit"); // If we load the repo at head, we should not see the commit since it was // removed diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index ea4b1e10e..ea8389186 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -159,9 +159,9 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) { return; } Kind::GitSubmodule => { - let mut tx = repo.start_transaction(settings, "test"); + let mut tx = repo.start_transaction(settings); let id = write_random_commit(tx.mut_repo(), settings).id().clone(); - tx.commit(); + tx.commit("test"); Merge::normal(TreeValue::GitSubmodule(id)) } }; @@ -847,9 +847,9 @@ fn test_gitsubmodule() { }, ); - let mut tx = repo.start_transaction(&settings, "create submodule commit"); + let mut tx = repo.start_transaction(&settings); let submodule_id = write_random_commit(tx.mut_repo(), &settings).id().clone(); - tx.commit(); + tx.commit("create submodule commit"); tree_builder.set( submodule_path.to_owned(), diff --git a/lib/tests/test_merge_trees.rs b/lib/tests/test_merge_trees.rs index 0b33f7487..107ce3abf 100644 --- a/lib/tests/test_merge_trees.rs +++ b/lib/tests/test_merge_trees.rs @@ -551,7 +551,7 @@ fn test_simplify_conflict_after_resolving_parent() { // rebase C2 (the rebased C) onto the resolved conflict. C3 should not have // a conflict since it changed an unrelated line. let path = RepoPath::from_internal_string("dir/file"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let tree_a = create_tree(repo, &[(path, "abc\ndef\nghi\n")]); let commit_a = tx .mut_repo() @@ -601,7 +601,7 @@ fn test_simplify_conflict_after_resolving_parent() { .unwrap(); let commit_c3 = rebase_commit(&settings, tx.mut_repo(), &commit_c2, &[commit_b3]).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // The conflict should now be resolved. let tree_c2 = commit_c3.tree().unwrap(); diff --git a/lib/tests/test_mut_repo.rs b/lib/tests/test_mut_repo.rs index 7c060a3fb..6050b81e2 100644 --- a/lib/tests/test_mut_repo.rs +++ b/lib/tests/test_mut_repo.rs @@ -27,14 +27,14 @@ fn test_edit() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let wc_commit = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let ws_id = WorkspaceId::default(); tx.mut_repo().edit(ws_id.clone(), &wc_commit).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!(repo.view().get_wc_commit_id(&ws_id), Some(wc_commit.id())); } @@ -45,11 +45,11 @@ fn test_checkout() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let wc_commit_parent = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let ws_id = WorkspaceId::default(); let wc_commit = tx .mut_repo() @@ -58,7 +58,7 @@ fn test_checkout() { assert_eq!(wc_commit.tree_id(), wc_commit_parent.tree_id()); assert_eq!(wc_commit.parents().len(), 1); assert_eq!(wc_commit.parents()[0].id(), wc_commit_parent.id()); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!(repo.view().get_wc_commit_id(&ws_id), Some(wc_commit.id())); } @@ -70,14 +70,14 @@ fn test_checkout_previous_not_empty() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let old_wc_commit = write_random_commit(mut_repo, &settings); let ws_id = WorkspaceId::default(); mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let new_wc_commit = write_random_commit(mut_repo, &settings); mut_repo.edit(ws_id, &new_wc_commit).unwrap(); @@ -93,7 +93,7 @@ fn test_checkout_previous_empty() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let old_wc_commit = mut_repo .new_commit( @@ -105,9 +105,9 @@ fn test_checkout_previous_empty() { .unwrap(); let ws_id = WorkspaceId::default(); mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let new_wc_commit = write_random_commit(mut_repo, &settings); mut_repo.edit(ws_id, &new_wc_commit).unwrap(); @@ -123,7 +123,7 @@ fn test_checkout_previous_empty_with_description() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let old_wc_commit = mut_repo .new_commit( @@ -136,9 +136,9 @@ fn test_checkout_previous_empty_with_description() { .unwrap(); let ws_id = WorkspaceId::default(); mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let new_wc_commit = write_random_commit(mut_repo, &settings); mut_repo.edit(ws_id, &new_wc_commit).unwrap(); @@ -154,7 +154,7 @@ fn test_checkout_previous_empty_with_local_branch() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let old_wc_commit = mut_repo .new_commit( @@ -167,9 +167,9 @@ fn test_checkout_previous_empty_with_local_branch() { mut_repo.set_local_branch_target("b", RefTarget::normal(old_wc_commit.id().clone())); let ws_id = WorkspaceId::default(); mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let new_wc_commit = write_random_commit(mut_repo, &settings); mut_repo.edit(ws_id, &new_wc_commit).unwrap(); @@ -185,7 +185,7 @@ fn test_checkout_previous_empty_non_head() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let old_wc_commit = mut_repo .new_commit( @@ -205,9 +205,9 @@ fn test_checkout_previous_empty_non_head() { .unwrap(); let ws_id = WorkspaceId::default(); mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let new_wc_commit = write_random_commit(mut_repo, &settings); mut_repo.edit(ws_id, &new_wc_commit).unwrap(); @@ -226,16 +226,16 @@ fn test_edit_initial() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let wc_commit = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let workspace_id = WorkspaceId::new("new-workspace".to_string()); tx.mut_repo() .edit(workspace_id.clone(), &wc_commit) .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!( repo.view().get_wc_commit_id(&workspace_id), Some(wc_commit.id()) @@ -252,18 +252,18 @@ fn test_add_head_success() { // Create a commit outside of the repo by using a temporary transaction. Then // add that as a head. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let new_commit = write_random_commit(tx.mut_repo(), &settings); drop(tx); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); assert!(!mut_repo.view().heads().contains(new_commit.id())); assert!(!mut_repo.index().has_id(new_commit.id())); mut_repo.add_head(&new_commit); assert!(mut_repo.view().heads().contains(new_commit.id())); assert!(mut_repo.index().has_id(new_commit.id())); - let repo = tx.commit(); + let repo = tx.commit("test"); assert!(repo.view().heads().contains(new_commit.id())); assert!(repo.index().has_id(new_commit.id())); } @@ -276,15 +276,15 @@ fn test_add_head_ancestor() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); let commit3 = graph_builder.commit_with_parents(&[&commit2]); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!(repo.view().heads(), &hashset! {commit3.id().clone()}); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); mut_repo.add_head(&commit1); assert_eq!(repo.view().heads(), &hashset! {commit3.id().clone()}); @@ -298,13 +298,13 @@ fn test_add_head_not_immediate_child() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let initial = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); // Create some commits outside of the repo by using a temporary transaction. // Then add one of them as a head. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let rewritten = create_random_commit(tx.mut_repo(), &settings) .set_change_id(initial.change_id().clone()) .set_predecessors(vec![initial.id().clone()]) @@ -317,7 +317,7 @@ fn test_add_head_not_immediate_child() { drop(tx); assert_eq!(repo.view().heads(), &hashset! {initial.id().clone()}); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); mut_repo.add_head(&child); assert_eq!( @@ -338,14 +338,14 @@ fn test_remove_head() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); let commit3 = graph_builder.commit_with_parents(&[&commit2]); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); assert!(mut_repo.view().heads().contains(commit3.id())); mut_repo.remove_head(commit3.id()); @@ -356,7 +356,7 @@ fn test_remove_head() { assert!(mut_repo.index().has_id(commit1.id())); assert!(mut_repo.index().has_id(commit2.id())); assert!(mut_repo.index().has_id(commit3.id())); - let repo = tx.commit(); + let repo = tx.commit("test"); let heads = repo.view().heads().clone(); assert!(!heads.contains(commit3.id())); assert!(!heads.contains(commit2.id())); @@ -374,16 +374,16 @@ fn test_add_public_head() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit1 = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); assert!(!mut_repo.view().public_heads().contains(commit1.id())); mut_repo.add_public_head(&commit1); assert!(mut_repo.view().public_heads().contains(commit1.id())); - let repo = tx.commit(); + let repo = tx.commit("test"); assert!(repo.view().public_heads().contains(commit1.id())); } @@ -395,19 +395,19 @@ fn test_add_public_head_ancestor() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); tx.mut_repo().add_public_head(&commit2); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); assert!(!mut_repo.view().public_heads().contains(commit1.id())); mut_repo.add_public_head(&commit1); assert!(!mut_repo.view().public_heads().contains(commit1.id())); - let repo = tx.commit(); + let repo = tx.commit("test"); assert!(!repo.view().public_heads().contains(commit1.id())); } @@ -419,18 +419,18 @@ fn test_remove_public_head() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); mut_repo.add_public_head(&commit1); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); assert!(mut_repo.view().public_heads().contains(commit1.id())); mut_repo.remove_public_head(commit1.id()); assert!(!mut_repo.view().public_heads().contains(commit1.id())); - let repo = tx.commit(); + let repo = tx.commit("test"); assert!(!repo.view().public_heads().contains(commit1.id())); } @@ -447,7 +447,7 @@ fn test_has_changed() { state: RemoteRefState::Tracking, // doesn't matter }; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); let commit2 = write_random_commit(mut_repo, &settings); @@ -459,12 +459,12 @@ fn test_has_changed() { .unwrap(); mut_repo.set_local_branch_target("main", RefTarget::normal(commit1.id().clone())); mut_repo.set_remote_branch("main", "origin", normal_remote_ref(commit1.id())); - let repo = tx.commit(); + let repo = tx.commit("test"); // Test the setup assert_eq!(repo.view().heads(), &hashset! {commit1.id().clone()}); assert_eq!(repo.view().public_heads(), &hashset! {commit1.id().clone()}); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); mut_repo.add_public_head(&commit1); @@ -524,16 +524,16 @@ fn test_rebase_descendants_simple() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); let commit3 = graph_builder.commit_with_parents(&[&commit2]); let commit4 = graph_builder.commit_with_parents(&[&commit1]); let commit5 = graph_builder.commit_with_parents(&[&commit4]); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit6 = graph_builder.commit_with_parents(&[&commit1]); @@ -561,14 +561,14 @@ fn test_rebase_descendants_conflicting_rewrite() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); let _commit3 = graph_builder.commit_with_parents(&[&commit2]); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit4 = graph_builder.commit_with_parents(&[&commit1]); @@ -592,7 +592,7 @@ fn test_rename_remote() { let settings = testutils::user_settings(); let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit = write_random_commit(mut_repo, &settings); let remote_ref = RemoteRef { diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index 74c570708..3e41b0a81 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -36,9 +36,9 @@ fn test_unpublished_operation() { let op_id0 = repo.op_id().clone(); assert_eq!(list_dir(&op_heads_dir), vec![repo.op_id().hex()]); - let mut tx1 = repo.start_transaction(&settings, "transaction 1"); + let mut tx1 = repo.start_transaction(&settings); write_random_commit(tx1.mut_repo(), &settings); - let unpublished_op = tx1.write(); + let unpublished_op = tx1.write("transaction 1"); let op_id1 = unpublished_op.operation().id().clone(); assert_ne!(op_id1, op_id0); assert_eq!(list_dir(&op_heads_dir), vec![op_id0.hex()]); @@ -58,16 +58,16 @@ fn test_consecutive_operations() { let op_id0 = repo.op_id().clone(); assert_eq!(list_dir(&op_heads_dir), vec![repo.op_id().hex()]); - let mut tx1 = repo.start_transaction(&settings, "transaction 1"); + let mut tx1 = repo.start_transaction(&settings); write_random_commit(tx1.mut_repo(), &settings); - let op_id1 = tx1.commit().operation().id().clone(); + let op_id1 = tx1.commit("transaction 1").operation().id().clone(); assert_ne!(op_id1, op_id0); assert_eq!(list_dir(&op_heads_dir), vec![op_id1.hex()]); let repo = repo.reload_at_head(&settings).unwrap(); - let mut tx2 = repo.start_transaction(&settings, "transaction 2"); + let mut tx2 = repo.start_transaction(&settings); write_random_commit(tx2.mut_repo(), &settings); - let op_id2 = tx2.commit().operation().id().clone(); + let op_id2 = tx2.commit("transaction 2").operation().id().clone(); assert_ne!(op_id2, op_id0); assert_ne!(op_id2, op_id1); assert_eq!(list_dir(&op_heads_dir), vec![op_id2.hex()]); @@ -90,17 +90,17 @@ fn test_concurrent_operations() { let op_id0 = repo.op_id().clone(); assert_eq!(list_dir(&op_heads_dir), vec![repo.op_id().hex()]); - let mut tx1 = repo.start_transaction(&settings, "transaction 1"); + let mut tx1 = repo.start_transaction(&settings); write_random_commit(tx1.mut_repo(), &settings); - let op_id1 = tx1.commit().operation().id().clone(); + let op_id1 = tx1.commit("transaction 1").operation().id().clone(); assert_ne!(op_id1, op_id0); assert_eq!(list_dir(&op_heads_dir), vec![op_id1.hex()]); // After both transactions have committed, we should have two op-heads on disk, // since they were run in parallel. - let mut tx2 = repo.start_transaction(&settings, "transaction 2"); + let mut tx2 = repo.start_transaction(&settings); write_random_commit(tx2.mut_repo(), &settings); - let op_id2 = tx2.commit().operation().id().clone(); + let op_id2 = tx2.commit("transaction 2").operation().id().clone(); assert_ne!(op_id2, op_id0); assert_ne!(op_id2, op_id1); let mut actual_heads_on_disk = list_dir(&op_heads_dir); @@ -130,16 +130,16 @@ fn test_isolation() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let initial = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![repo.store().root_commit_id().clone()]) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "transaction 1"); + let mut tx1 = repo.start_transaction(&settings); let mut_repo1 = tx1.mut_repo(); - let mut tx2 = repo.start_transaction(&settings, "transaction 2"); + let mut tx2 = repo.start_transaction(&settings); let mut_repo2 = tx2.mut_repo(); assert_heads(repo.as_ref(), vec![initial.id()]); @@ -166,12 +166,12 @@ fn test_isolation() { assert_heads(mut_repo2, vec![rewrite2.id()]); // The base repo and tx2 don't see the commits from tx1. - tx1.commit(); + tx1.commit("transaction 1"); assert_heads(repo.as_ref(), vec![initial.id()]); assert_heads(mut_repo2, vec![rewrite2.id()]); // The base repo still doesn't see the commits after both transactions commit. - tx2.commit(); + tx2.commit("transaction 2"); assert_heads(repo.as_ref(), vec![initial.id()]); // After reload, the base repo sees both rewrites. let repo = repo.reload_at_head(&settings).unwrap(); diff --git a/lib/tests/test_refs.rs b/lib/tests/test_refs.rs index ca6dbe3c2..d56d1fb65 100644 --- a/lib/tests/test_refs.rs +++ b/lib/tests/test_refs.rs @@ -32,7 +32,7 @@ fn test_merge_ref_targets() { // | 2 // |/ // 1 - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit1 = graph_builder.initial_commit(); let commit2 = graph_builder.commit_with_parents(&[&commit1]); @@ -41,7 +41,7 @@ fn test_merge_ref_targets() { let commit5 = graph_builder.commit_with_parents(&[&commit1]); let commit6 = graph_builder.commit_with_parents(&[&commit5]); let commit7 = graph_builder.commit_with_parents(&[&commit5]); - let repo = tx.commit(); + let repo = tx.commit("test"); let target1 = RefTarget::normal(commit1.id().clone()); let target2 = RefTarget::normal(commit2.id().clone()); diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index dc8b8564a..451846439 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -88,7 +88,7 @@ fn test_resolve_symbol_commit_id() { let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let signature = Signature { name: "test".to_string(), @@ -114,7 +114,7 @@ fn test_resolve_symbol_commit_id() { .unwrap(); commits.push(commit); } - let repo = tx.commit(); + let repo = tx.commit("test"); // Test the test setup assert_eq!( @@ -233,7 +233,7 @@ fn test_resolve_symbol_change_id(readonly: bool) { git_commit_ids.push(git_commit_id); } - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); git::import_refs(tx.mut_repo(), &git_settings).unwrap(); // Test the test setup @@ -260,7 +260,7 @@ fn test_resolve_symbol_change_id(readonly: bool) { let _readonly_repo; let repo: &dyn Repo = if readonly { - _readonly_repo = tx.commit(); + _readonly_repo = tx.commit("test"); _readonly_repo.as_ref() } else { tx.mut_repo() @@ -339,7 +339,7 @@ fn test_resolve_working_copy() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -392,7 +392,7 @@ fn test_resolve_symbol_branches() { let normal_tracking_remote_ref = |id: &CommitId| tracking_remote_ref(RefTarget::normal(id.clone())); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -616,7 +616,7 @@ fn test_resolve_symbol_tags() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -664,7 +664,7 @@ fn test_resolve_symbol_git_head() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -708,7 +708,7 @@ fn test_resolve_symbol_git_refs() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); // Create some commits and refs to work with and so the repo is not empty @@ -839,7 +839,7 @@ fn test_evaluate_expression_root_and_checkout() { let test_workspace = TestWorkspace::init(&settings); let repo = &test_workspace.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let root_commit = repo.store().root_commit(); @@ -868,7 +868,7 @@ fn test_evaluate_expression_heads() { let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -933,7 +933,7 @@ fn test_evaluate_expression_roots() { let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -988,7 +988,7 @@ fn test_evaluate_expression_parents() { let repo = &test_workspace.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -1069,7 +1069,7 @@ fn test_evaluate_expression_children() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -1156,7 +1156,7 @@ fn test_evaluate_expression_ancestors() { let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -1242,7 +1242,7 @@ fn test_evaluate_expression_range() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -1324,7 +1324,7 @@ fn test_evaluate_expression_dag_range() { let repo = &test_repo.repo; let root_commit_id = repo.store().root_commit_id().clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -1434,7 +1434,7 @@ fn test_evaluate_expression_connected() { let repo = &test_repo.repo; let root_commit_id = repo.store().root_commit_id().clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -1509,7 +1509,7 @@ fn test_evaluate_expression_descendants() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let root_commit_id = repo.store().root_commit_id().clone(); @@ -1619,7 +1619,7 @@ fn test_evaluate_expression_all() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let root_commit_id = repo.store().root_commit_id().clone(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); @@ -1646,7 +1646,7 @@ fn test_evaluate_expression_visible_heads() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -1665,7 +1665,7 @@ fn test_evaluate_expression_git_refs() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -1724,7 +1724,7 @@ fn test_evaluate_expression_git_head() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -1744,7 +1744,7 @@ fn test_evaluate_expression_branches() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -1828,7 +1828,7 @@ fn test_evaluate_expression_remote_branches() { }; let normal_remote_ref = |id: &CommitId| remote_ref(RefTarget::normal(id.clone())); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = write_random_commit(mut_repo, &settings); @@ -1959,7 +1959,7 @@ fn test_evaluate_expression_latest() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut write_commit_with_committer_timestamp = |sec: i64| { @@ -2042,7 +2042,7 @@ fn test_evaluate_expression_merges() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -2069,7 +2069,7 @@ fn test_evaluate_expression_description() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit1 = create_random_commit(mut_repo, &settings) @@ -2114,7 +2114,7 @@ fn test_evaluate_expression_author() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let timestamp = Timestamp { @@ -2187,7 +2187,7 @@ fn test_evaluate_expression_mine() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let timestamp = Timestamp { @@ -2255,7 +2255,7 @@ fn test_evaluate_expression_committer() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let timestamp = Timestamp { @@ -2321,7 +2321,7 @@ fn test_evaluate_expression_union() { let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -2393,7 +2393,7 @@ fn test_evaluate_expression_intersection() { let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -2432,7 +2432,7 @@ fn test_evaluate_expression_difference() { let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); let commit1 = graph_builder.initial_commit(); @@ -2517,7 +2517,7 @@ fn test_evaluate_expression_filter_combinator() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let root_commit_id = repo.store().root_commit_id(); @@ -2580,7 +2580,7 @@ fn test_evaluate_expression_file() { let test_workspace = TestWorkspace::init(&settings); let repo = &test_workspace.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let added_clean_clean = RepoPath::from_internal_string("added_clean_clean"); @@ -2688,7 +2688,7 @@ fn test_evaluate_expression_conflict() { let test_workspace = TestWorkspace::init(&settings); let repo = &test_workspace.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); // Create a few trees, including one with a conflict in `file1` @@ -2739,7 +2739,7 @@ fn test_reverse_graph_iterator() { // A // | // root - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -2747,7 +2747,7 @@ fn test_reverse_graph_iterator() { let commit_d = graph_builder.commit_with_parents(&[&commit_c]); let commit_e = graph_builder.commit_with_parents(&[&commit_c]); let commit_f = graph_builder.commit_with_parents(&[&commit_d, &commit_e]); - let repo = tx.commit(); + let repo = tx.commit("test"); let revset = revset_for_commits( repo.as_ref(), @@ -2788,7 +2788,7 @@ fn test_change_id_index() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let root_commit = repo.store().root_commit(); let mut commit_number = 0; @@ -2894,7 +2894,7 @@ fn test_no_such_revision_suggestion() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let commit = write_random_commit(mut_repo, &settings); diff --git a/lib/tests/test_rewrite.rs b/lib/tests/test_rewrite.rs index d4c362bab..17dd66f4e 100644 --- a/lib/tests/test_rewrite.rs +++ b/lib/tests/test_rewrite.rs @@ -78,7 +78,7 @@ fn test_rebase_descendants_sideways() { // | B // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -133,7 +133,7 @@ fn test_rebase_descendants_forward() { // |/ // B // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -186,7 +186,7 @@ fn test_rebase_descendants_reorder() { // |/ // B // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -232,7 +232,7 @@ fn test_rebase_descendants_backward() { // C // B // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -273,7 +273,7 @@ fn test_rebase_descendants_chain_becomes_branchy() { // B E // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -320,7 +320,7 @@ fn test_rebase_descendants_internal_merge() { // | B // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -370,7 +370,7 @@ fn test_rebase_descendants_external_merge() { // | B // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -416,7 +416,7 @@ fn test_rebase_descendants_abandon() { // |/ // B // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -457,7 +457,7 @@ fn test_rebase_descendants_abandon_no_descendants() { // C // B // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -494,7 +494,7 @@ fn test_rebase_descendants_abandon_and_replace() { // E B // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -532,7 +532,7 @@ fn test_rebase_descendants_abandon_degenerate_merge() { // B C // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -571,7 +571,7 @@ fn test_rebase_descendants_abandon_widen_merge() { // B C D // \|/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -614,7 +614,7 @@ fn test_rebase_descendants_multiple_sideways() { // | |/ // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -660,7 +660,7 @@ fn test_rebase_descendants_multiple_swap() { // B D // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -691,7 +691,7 @@ fn test_rebase_descendants_multiple_no_descendants() { // B C // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -744,7 +744,7 @@ fn test_rebase_descendants_divergent_rewrite() { // | B2 // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -802,7 +802,7 @@ fn test_rebase_descendants_repeated() { // | B2 // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -866,7 +866,7 @@ fn test_rebase_descendants_contents() { // | B // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let path1 = RepoPath::from_internal_string("file1"); let tree1 = create_tree(repo, &[(path1, "content")]); let commit_a = tx @@ -937,15 +937,15 @@ fn test_rebase_descendants_basic_branch_update() { // B main B2 main // | => | // A A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); tx.mut_repo() .set_local_branch_target("main", RefTarget::normal(commit_b.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_b2 = tx .mut_repo() .rewrite_commit(&settings, &commit_b) @@ -979,16 +979,16 @@ fn test_rebase_descendants_branch_move_two_steps() { // B B2 B2 // |/ | // A A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); let commit_c = graph_builder.commit_with_parents(&[&commit_b]); tx.mut_repo() .set_local_branch_target("main", RefTarget::normal(commit_c.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_b2 = tx .mut_repo() .rewrite_commit(&settings, &commit_b) @@ -1026,7 +1026,7 @@ fn test_rebase_descendants_basic_branch_update_with_non_local_branch() { // B main main@origin v1 | B main@origin v1 // | => |/ // A A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -1040,9 +1040,9 @@ fn test_rebase_descendants_basic_branch_update_with_non_local_branch() { .set_remote_branch("main", "origin", commit_b_remote_ref.clone()); tx.mut_repo() .set_tag_target("v1", RefTarget::normal(commit_b.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_b2 = tx .mut_repo() .rewrite_commit(&settings, &commit_b) @@ -1083,15 +1083,15 @@ fn test_rebase_descendants_update_branch_after_abandon() { // B main // | => A main // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); tx.mut_repo() .set_local_branch_target("main", RefTarget::normal(commit_b.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo().record_abandoned_commit(commit_b.id().clone()); tx.mut_repo().rebase_descendants(&settings).unwrap(); assert_eq!( @@ -1119,15 +1119,15 @@ fn test_rebase_descendants_update_branches_after_divergent_rewrite() { // B main |/B2 main? // | => |/ // A A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); tx.mut_repo() .set_local_branch_target("main", RefTarget::normal(commit_b.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_b2 = tx .mut_repo() .rewrite_commit(&settings, &commit_b) @@ -1183,7 +1183,7 @@ fn test_rebase_descendants_rewrite_updates_branch_conflict() { // Branch "main" is a conflict removing commit A and adding commits B and C. // A gets rewritten as A2 and A3. B gets rewritten as B2 and B2. The branch // should become a conflict removing A and B, and adding B2, B3, C. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.initial_commit(); @@ -1195,9 +1195,9 @@ fn test_rebase_descendants_rewrite_updates_branch_conflict() { [commit_b.id().clone(), commit_c.id().clone()], ), ); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a2 = tx .mut_repo() .rewrite_commit(&settings, &commit_a) @@ -1264,7 +1264,7 @@ fn test_rebase_descendants_rewrite_resolves_branch_conflict() { // would result in a conflict removing A and adding B2 and C. However, since C // is a descendant of A, and B2 is a descendant of C, the conflict gets // resolved to B2. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -1276,9 +1276,9 @@ fn test_rebase_descendants_rewrite_resolves_branch_conflict() { [commit_b.id().clone(), commit_c.id().clone()], ), ); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_b2 = tx .mut_repo() .rewrite_commit(&settings, &commit_b) @@ -1308,7 +1308,7 @@ fn test_rebase_descendants_branch_delete_modify_abandon() { // leaves the branch pointing to "-A+B". We now abandon B. That should // result in the branch pointing to "-A+A=0", so the branch should // be deleted. - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let commit_a = graph_builder.initial_commit(); let commit_b = graph_builder.commit_with_parents(&[&commit_a]); @@ -1316,9 +1316,9 @@ fn test_rebase_descendants_branch_delete_modify_abandon() { "main", RefTarget::from_legacy_form([commit_a.id().clone()], [commit_b.id().clone()]), ); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo().record_abandoned_commit(commit_b.id().clone()); tx.mut_repo().rebase_descendants(&settings).unwrap(); assert_eq!(tx.mut_repo().get_local_branch("main"), RefTarget::absent()); @@ -1336,7 +1336,7 @@ fn test_rebase_descendants_update_checkout() { // C B // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a = write_random_commit(tx.mut_repo(), &settings); let commit_b = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![commit_a.id().clone()]) @@ -1354,9 +1354,9 @@ fn test_rebase_descendants_update_checkout() { tx.mut_repo() .set_wc_commit(ws3_id.clone(), commit_a.id().clone()) .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_c = tx .mut_repo() .rewrite_commit(&settings, &commit_b) @@ -1364,7 +1364,7 @@ fn test_rebase_descendants_update_checkout() { .write() .unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // Workspaces 1 and 2 had B checked out, so they get updated to C. Workspace 3 // had A checked out, so it doesn't get updated. @@ -1385,7 +1385,7 @@ fn test_rebase_descendants_update_checkout_abandoned() { // B // | // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a = write_random_commit(tx.mut_repo(), &settings); let commit_b = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![commit_a.id().clone()]) @@ -1403,12 +1403,12 @@ fn test_rebase_descendants_update_checkout_abandoned() { tx.mut_repo() .set_wc_commit(ws3_id.clone(), commit_a.id().clone()) .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo().record_abandoned_commit(commit_b.id().clone()); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); // Workspaces 1 and 2 had B checked out, so they get updated to the same new // commit on top of C. Workspace 3 had A checked out, so it doesn't get updated. @@ -1438,7 +1438,7 @@ fn test_rebase_descendants_update_checkout_abandoned_merge() { // B C // |/ // A - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit_a = write_random_commit(tx.mut_repo(), &settings); let commit_b = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![commit_a.id().clone()]) @@ -1456,12 +1456,12 @@ fn test_rebase_descendants_update_checkout_abandoned_merge() { tx.mut_repo() .set_wc_commit(workspace_id.clone(), commit_d.id().clone()) .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); tx.mut_repo().record_abandoned_commit(commit_d.id().clone()); tx.mut_repo().rebase_descendants(&settings).unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); let new_checkout_id = repo.view().get_wc_commit_id(&workspace_id).unwrap(); let checkout = repo.store().get_commit(new_checkout_id).unwrap(); @@ -1510,7 +1510,7 @@ fn test_empty_commit_option(empty: EmptyBehaviour) { // | \|/ // | B // A__/ - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let create_fixed_tree = |paths: &[&str]| { let content_map = paths diff --git a/lib/tests/test_signing.rs b/lib/tests/test_signing.rs index 1a4a165e2..0c79a0e80 100644 --- a/lib/tests/test_signing.rs +++ b/lib/tests/test_signing.rs @@ -53,7 +53,7 @@ fn manual(backend: TestRepoBackend) { let settings = settings.clone(); let repo = repo.clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit1 = create_random_commit(tx.mut_repo(), &settings) .set_sign_behavior(SignBehavior::Own) .write() @@ -63,7 +63,7 @@ fn manual(backend: TestRepoBackend) { .set_author(someone_else()) .write() .unwrap(); - tx.commit(); + tx.commit("test"); let commit1 = repo.store().get_commit(commit1.id()).unwrap(); assert_eq!(commit1.verification().unwrap(), good_verification()); @@ -83,14 +83,14 @@ fn keep_on_rewrite(backend: TestRepoBackend) { let settings = settings.clone(); let repo = repo.clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit = create_random_commit(tx.mut_repo(), &settings) .set_sign_behavior(SignBehavior::Own) .write() .unwrap(); - tx.commit(); + tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let rewritten = mut_repo.rewrite_commit(&settings, &commit).write().unwrap(); @@ -109,14 +109,14 @@ fn manual_drop_on_rewrite(backend: TestRepoBackend) { let settings = settings.clone(); let repo = repo.clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit = create_random_commit(tx.mut_repo(), &settings) .set_sign_behavior(SignBehavior::Own) .write() .unwrap(); - tx.commit(); + tx.commit("test"); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let rewritten = mut_repo .rewrite_commit(&settings, &commit) @@ -139,13 +139,13 @@ fn forced(backend: TestRepoBackend) { let settings = settings.clone(); let repo = repo.clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit = create_random_commit(tx.mut_repo(), &settings) .set_sign_behavior(SignBehavior::Force) .set_author(someone_else()) .write() .unwrap(); - tx.commit(); + tx.commit("test"); let commit = repo.store().get_commit(commit.id()).unwrap(); assert_eq!(commit.verification().unwrap(), good_verification()); @@ -162,9 +162,9 @@ fn configured(backend: TestRepoBackend) { let settings = settings.clone(); let repo = repo.clone(); - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let commit = write_random_commit(tx.mut_repo(), &settings); - tx.commit(); + tx.commit("test"); let commit = repo.store().get_commit(commit.id()).unwrap(); assert_eq!(commit.verification().unwrap(), good_verification()); diff --git a/lib/tests/test_view.rs b/lib/tests/test_view.rs index ff720efc7..870f2b22c 100644 --- a/lib/tests/test_view.rs +++ b/lib/tests/test_view.rs @@ -42,13 +42,13 @@ fn test_heads_fork() { let settings = testutils::user_settings(); let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let initial = graph_builder.initial_commit(); let child1 = graph_builder.commit_with_parents(&[&initial]); let child2 = graph_builder.commit_with_parents(&[&initial]); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!( *repo.view().heads(), @@ -64,14 +64,14 @@ fn test_heads_merge() { let settings = testutils::user_settings(); let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo()); let initial = graph_builder.initial_commit(); let child1 = graph_builder.commit_with_parents(&[&initial]); let child2 = graph_builder.commit_with_parents(&[&initial]); let merge = graph_builder.commit_with_parents(&[&child1, &child2]); - let repo = tx.commit(); + let repo = tx.commit("test"); assert_eq!(*repo.view().heads(), hashset! {merge.id().clone()}); } @@ -83,7 +83,7 @@ fn test_merge_views_heads() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let head_unchanged = write_random_commit(mut_repo, &settings); let head_remove_tx1 = write_random_commit(mut_repo, &settings); @@ -94,9 +94,9 @@ fn test_merge_views_heads() { mut_repo.add_public_head(&public_head_remove_tx1); let public_head_remove_tx2 = write_random_commit(mut_repo, &settings); mut_repo.add_public_head(&public_head_remove_tx2); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); tx1.mut_repo().remove_head(head_remove_tx1.id()); tx1.mut_repo() .remove_public_head(public_head_remove_tx1.id()); @@ -104,7 +104,7 @@ fn test_merge_views_heads() { let public_head_add_tx1 = write_random_commit(tx1.mut_repo(), &settings); tx1.mut_repo().add_public_head(&public_head_add_tx1); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); tx2.mut_repo().remove_head(head_remove_tx2.id()); tx2.mut_repo() .remove_public_head(public_head_remove_tx2.id()); @@ -148,7 +148,7 @@ fn test_merge_views_checkout() { // Workspace 5 gets deleted in tx2 and modified in tx1. // Workspace 6 gets added in tx1. // Workspace 7 gets added in tx2. - let mut initial_tx = repo.start_transaction(&settings, "test"); + let mut initial_tx = repo.start_transaction(&settings); let commit1 = write_random_commit(initial_tx.mut_repo(), &settings); let commit2 = write_random_commit(initial_tx.mut_repo(), &settings); let commit3 = write_random_commit(initial_tx.mut_repo(), &settings); @@ -179,9 +179,9 @@ fn test_merge_views_checkout() { .mut_repo() .set_wc_commit(ws5_id.clone(), commit1.id().clone()) .unwrap(); - let repo = initial_tx.commit(); + let repo = initial_tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); tx1.mut_repo() .set_wc_commit(ws1_id.clone(), commit2.id().clone()) .unwrap(); @@ -196,7 +196,7 @@ fn test_merge_views_checkout() { .set_wc_commit(ws6_id.clone(), commit2.id().clone()) .unwrap(); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); tx2.mut_repo() .set_wc_commit(ws1_id.clone(), commit3.id().clone()) .unwrap(); @@ -232,7 +232,7 @@ fn test_merge_views_branches() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let main_branch_local_tx0 = write_random_commit(mut_repo, &settings); let main_branch_origin_tx0 = write_random_commit(mut_repo, &settings); @@ -260,9 +260,9 @@ fn test_merge_views_branches() { "feature", RefTarget::normal(feature_branch_local_tx0.id().clone()), ); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let main_branch_local_tx1 = write_random_commit(tx1.mut_repo(), &settings); tx1.mut_repo().set_local_branch_target( "main", @@ -274,7 +274,7 @@ fn test_merge_views_branches() { RefTarget::normal(feature_branch_tx1.id().clone()), ); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let main_branch_local_tx2 = write_random_commit(tx2.mut_repo(), &settings); let main_branch_origin_tx2 = write_random_commit(tx2.mut_repo(), &settings); let main_branch_origin_tx2_remote_ref = RemoteRef { @@ -324,15 +324,15 @@ fn test_merge_views_tags() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let v1_tx0 = write_random_commit(mut_repo, &settings); mut_repo.set_tag_target("v1.0", RefTarget::normal(v1_tx0.id().clone())); let v2_tx0 = write_random_commit(mut_repo, &settings); mut_repo.set_tag_target("v2.0", RefTarget::normal(v2_tx0.id().clone())); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let v1_tx1 = write_random_commit(tx1.mut_repo(), &settings); tx1.mut_repo() .set_tag_target("v1.0", RefTarget::normal(v1_tx1.id().clone())); @@ -340,7 +340,7 @@ fn test_merge_views_tags() { tx1.mut_repo() .set_tag_target("v2.0", RefTarget::normal(v2_tx1.id().clone())); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let v1_tx2 = write_random_commit(tx2.mut_repo(), &settings); tx2.mut_repo() .set_tag_target("v1.0", RefTarget::normal(v1_tx2.id().clone())); @@ -368,7 +368,7 @@ fn test_merge_views_git_refs() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx = repo.start_transaction(&settings, "test"); + let mut tx = repo.start_transaction(&settings); let mut_repo = tx.mut_repo(); let main_branch_tx0 = write_random_commit(mut_repo, &settings); mut_repo.set_git_ref_target( @@ -380,9 +380,9 @@ fn test_merge_views_git_refs() { "refs/heads/feature", RefTarget::normal(feature_branch_tx0.id().clone()), ); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let main_branch_tx1 = write_random_commit(tx1.mut_repo(), &settings); tx1.mut_repo().set_git_ref_target( "refs/heads/main", @@ -394,7 +394,7 @@ fn test_merge_views_git_refs() { RefTarget::normal(feature_branch_tx1.id().clone()), ); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let main_branch_tx2 = write_random_commit(tx2.mut_repo(), &settings); tx2.mut_repo().set_git_ref_target( "refs/heads/main", @@ -424,18 +424,18 @@ fn test_merge_views_git_heads() { let test_repo = TestRepo::init(); let repo = &test_repo.repo; - let mut tx0 = repo.start_transaction(&settings, "test"); + let mut tx0 = repo.start_transaction(&settings); let tx0_head = write_random_commit(tx0.mut_repo(), &settings); tx0.mut_repo() .set_git_head_target(RefTarget::normal(tx0_head.id().clone())); - let repo = tx0.commit(); + let repo = tx0.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let tx1_head = write_random_commit(tx1.mut_repo(), &settings); tx1.mut_repo() .set_git_head_target(RefTarget::normal(tx1_head.id().clone())); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let tx2_head = write_random_commit(tx2.mut_repo(), &settings); tx2.mut_repo() .set_git_head_target(RefTarget::normal(tx2_head.id().clone())); @@ -455,11 +455,11 @@ fn test_merge_views_divergent() { let settings = testutils::user_settings(); let test_repo = TestRepo::init(); - let mut tx = test_repo.repo.start_transaction(&settings, "test"); + let mut tx = test_repo.repo.start_transaction(&settings); let commit_a = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let commit_a2 = tx1 .mut_repo() .rewrite_commit(&settings, &commit_a) @@ -468,7 +468,7 @@ fn test_merge_views_divergent() { .unwrap(); tx1.mut_repo().rebase_descendants(&settings).unwrap(); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let commit_a3 = tx2 .mut_repo() .rewrite_commit(&settings, &commit_a) @@ -494,17 +494,17 @@ fn test_merge_views_child_on_rewritten(child_first: bool) { let settings = testutils::user_settings(); let test_repo = TestRepo::init(); - let mut tx = test_repo.repo.start_transaction(&settings, "test"); + let mut tx = test_repo.repo.start_transaction(&settings); let commit_a = write_random_commit(tx.mut_repo(), &settings); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let commit_b = create_random_commit(tx1.mut_repo(), &settings) .set_parents(vec![commit_a.id().clone()]) .write() .unwrap(); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let commit_a2 = tx2 .mut_repo() .rewrite_commit(&settings, &commit_a) @@ -540,22 +540,22 @@ fn test_merge_views_child_on_rewritten_divergent(on_rewritten: bool, child_first let settings = testutils::user_settings(); let test_repo = TestRepo::init(); - let mut tx = test_repo.repo.start_transaction(&settings, "test"); + let mut tx = test_repo.repo.start_transaction(&settings); let commit_a2 = write_random_commit(tx.mut_repo(), &settings); let commit_a3 = create_random_commit(tx.mut_repo(), &settings) .set_change_id(commit_a2.change_id().clone()) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let parent = if on_rewritten { &commit_a2 } else { &commit_a3 }; let commit_b = create_random_commit(tx1.mut_repo(), &settings) .set_parents(vec![parent.id().clone()]) .write() .unwrap(); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); let commit_a4 = tx2 .mut_repo() .rewrite_commit(&settings, &commit_a2) @@ -596,21 +596,21 @@ fn test_merge_views_child_on_abandoned(child_first: bool) { let settings = testutils::user_settings(); let test_repo = TestRepo::init(); - let mut tx = test_repo.repo.start_transaction(&settings, "test"); + let mut tx = test_repo.repo.start_transaction(&settings); let commit_a = write_random_commit(tx.mut_repo(), &settings); let commit_b = create_random_commit(tx.mut_repo(), &settings) .set_parents(vec![commit_a.id().clone()]) .write() .unwrap(); - let repo = tx.commit(); + let repo = tx.commit("test"); - let mut tx1 = repo.start_transaction(&settings, "test"); + let mut tx1 = repo.start_transaction(&settings); let commit_c = create_random_commit(tx1.mut_repo(), &settings) .set_parents(vec![commit_b.id().clone()]) .write() .unwrap(); - let mut tx2 = repo.start_transaction(&settings, "test"); + let mut tx2 = repo.start_transaction(&settings); tx2.mut_repo() .record_abandoned_commit(commit_b.id().clone()); tx2.mut_repo().rebase_descendants(&settings).unwrap(); diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index d4e0a9a42..2995ec2aa 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -241,7 +241,7 @@ pub fn commit_transactions(settings: &UserSettings, txs: Vec) -> Ar let repo_loader = txs[0].base_repo().loader(); let mut op_ids = vec![]; for tx in txs { - op_ids.push(tx.commit().op_id().clone()); + op_ids.push(tx.commit("test").op_id().clone()); std::thread::sleep(std::time::Duration::from_millis(1)); } let repo = repo_loader.load_at_head(settings).unwrap();