mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-31 00:12:06 +00:00
repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
nix / flake check (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with latest Python and uv (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
nix / flake check (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with latest Python and uv (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This commit is contained in:
parent
14b52205fb
commit
cff73841ed
55 changed files with 720 additions and 1186 deletions
|
@ -45,7 +45,7 @@ fn run_custom_command(
|
|||
let mut tx = workspace_command.start_transaction();
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command_helper.settings(), &commit)
|
||||
.rewrite_commit(&commit)
|
||||
.set_description("Frobnicated!")
|
||||
.write()?;
|
||||
tx.finish(ui, "frobnicate")?;
|
||||
|
|
|
@ -581,7 +581,7 @@ impl CommandHelper {
|
|||
let mut tx = start_repo_transaction(&base_repo, &self.data.string_args);
|
||||
for other_op_head in op_heads.into_iter().skip(1) {
|
||||
tx.merge_operation(other_op_head)?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants(&self.data.settings)?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants()?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
ui.status(),
|
||||
|
@ -1070,13 +1070,13 @@ impl WorkspaceCommandHelper {
|
|||
let workspace_id = self.workspace_id().to_owned();
|
||||
let new_git_head_commit = tx.repo().store().get_commit(new_git_head_id)?;
|
||||
tx.repo_mut()
|
||||
.check_out(workspace_id, self.env.settings(), &new_git_head_commit)?;
|
||||
.check_out(workspace_id, &new_git_head_commit)?;
|
||||
let mut locked_ws = self.workspace.start_working_copy_mutation()?;
|
||||
// The working copy was presumably updated by the git command that updated
|
||||
// HEAD, so we just need to reset our working copy
|
||||
// state to it without updating working copy files.
|
||||
locked_ws.locked_wc().reset(&new_git_head_commit)?;
|
||||
tx.repo_mut().rebase_descendants(self.env.settings())?;
|
||||
tx.repo_mut().rebase_descendants()?;
|
||||
self.user_repo = ReadonlyUserRepo::new(tx.commit("import git head")?);
|
||||
locked_ws.finish(self.user_repo.repo.op_id().clone())?;
|
||||
if old_git_head.is_present() {
|
||||
|
@ -1117,7 +1117,7 @@ impl WorkspaceCommandHelper {
|
|||
print_git_import_stats(ui, tx.repo(), &stats, false)?;
|
||||
let mut tx = tx.into_inner();
|
||||
// Rebase here to show slightly different status message.
|
||||
let num_rebased = tx.repo_mut().rebase_descendants(self.settings())?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants()?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
ui.status(),
|
||||
|
@ -1192,7 +1192,6 @@ impl WorkspaceCommandHelper {
|
|||
locked_ws.locked_wc(),
|
||||
&self.user_repo.repo,
|
||||
workspace_id,
|
||||
self.env.settings(),
|
||||
"RECOVERY COMMIT FROM `jj workspace update-stale`
|
||||
|
||||
This commit contains changes that were written to the working copy by an
|
||||
|
@ -1842,7 +1841,7 @@ See https://jj-vcs.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
tx.set_is_snapshot(true);
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit = mut_repo
|
||||
.rewrite_commit(self.env.settings(), &wc_commit)
|
||||
.rewrite_commit(&wc_commit)
|
||||
.set_tree_id(new_tree_id)
|
||||
.write()
|
||||
.map_err(snapshot_command_error)?;
|
||||
|
@ -1852,7 +1851,7 @@ See https://jj-vcs.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
|
||||
// Rebase descendants
|
||||
let num_rebased = mut_repo
|
||||
.rebase_descendants(self.env.settings())
|
||||
.rebase_descendants()
|
||||
.map_err(snapshot_command_error)?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(
|
||||
|
@ -1945,7 +1944,7 @@ See https://jj-vcs.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
writeln!(ui.status(), "Nothing changed.")?;
|
||||
return Ok(());
|
||||
}
|
||||
let num_rebased = tx.repo_mut().rebase_descendants(self.settings())?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants()?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
|
@ -1959,8 +1958,7 @@ See https://jj-vcs.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
.is_some()
|
||||
{
|
||||
let wc_commit = tx.repo().store().get_commit(wc_commit_id)?;
|
||||
tx.repo_mut()
|
||||
.check_out(workspace_id.clone(), self.settings(), &wc_commit)?;
|
||||
tx.repo_mut().check_out(workspace_id.clone(), &wc_commit)?;
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
"The working-copy commit in workspace '{}' became immutable, so a new commit \
|
||||
|
@ -2280,9 +2278,8 @@ impl WorkspaceCommandTransaction<'_> {
|
|||
|
||||
pub fn check_out(&mut self, commit: &Commit) -> Result<Commit, CheckOutCommitError> {
|
||||
let workspace_id = self.helper.workspace_id().to_owned();
|
||||
let settings = self.helper.settings();
|
||||
self.id_prefix_context.take(); // invalidate
|
||||
self.tx.repo_mut().check_out(workspace_id, settings, commit)
|
||||
self.tx.repo_mut().check_out(workspace_id, commit)
|
||||
}
|
||||
|
||||
pub fn edit(&mut self, commit: &Commit) -> Result<(), EditCommitError> {
|
||||
|
|
|
@ -79,11 +79,11 @@ pub(crate) fn cmd_abandon(
|
|||
}
|
||||
let (num_rebased, extra_msg) = if args.restore_descendants {
|
||||
(
|
||||
tx.repo_mut().reparent_descendants(command.settings())?,
|
||||
tx.repo_mut().reparent_descendants()?,
|
||||
" (while preserving their content)",
|
||||
)
|
||||
} else {
|
||||
(tx.repo_mut().rebase_descendants(command.settings())?, "")
|
||||
(tx.repo_mut().rebase_descendants()?, "")
|
||||
};
|
||||
|
||||
if let Some(mut formatter) = ui.status_formatter() {
|
||||
|
|
|
@ -91,12 +91,8 @@ pub(crate) fn cmd_absorb(
|
|||
workspace_command.check_rewritable(selected_trees.target_commits.keys())?;
|
||||
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
let (rewritten_commits, num_rebased) = absorb_hunks(
|
||||
tx.repo_mut(),
|
||||
&source,
|
||||
selected_trees.target_commits,
|
||||
command.settings(),
|
||||
)?;
|
||||
let (rewritten_commits, num_rebased) =
|
||||
absorb_hunks(tx.repo_mut(), &source, selected_trees.target_commits)?;
|
||||
|
||||
if let Some(mut formatter) = ui.status_formatter() {
|
||||
if !rewritten_commits.is_empty() {
|
||||
|
|
|
@ -95,7 +95,7 @@ pub(crate) fn cmd_backout(
|
|||
let new_parent_ids = parents.iter().map(|commit| commit.id().clone()).collect();
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(command.settings(), new_parent_ids, new_tree.id())
|
||||
.new_commit(new_parent_ids, new_tree.id())
|
||||
.set_description(new_commit_description)
|
||||
.write()?;
|
||||
parents = vec![new_commit];
|
||||
|
|
|
@ -115,10 +115,7 @@ new working-copy commit.
|
|||
)?;
|
||||
}
|
||||
|
||||
let mut commit_builder = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.detach();
|
||||
let mut commit_builder = tx.repo_mut().rewrite_commit(&commit).detach();
|
||||
commit_builder.set_tree_id(tree_id);
|
||||
if args.reset_author {
|
||||
commit_builder.set_author(commit_builder.committer().clone());
|
||||
|
@ -154,11 +151,7 @@ new working-copy commit.
|
|||
if !workspace_ids.is_empty() {
|
||||
let new_wc_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
command.settings(),
|
||||
vec![new_commit.id().clone()],
|
||||
commit.tree_id().clone(),
|
||||
)
|
||||
.new_commit(vec![new_commit.id().clone()], commit.tree_id().clone())
|
||||
.write()?;
|
||||
|
||||
// Does nothing if there's no bookmarks to advance.
|
||||
|
|
|
@ -148,10 +148,7 @@ pub(crate) fn cmd_describe(
|
|||
// Edit descriptions in topological order
|
||||
.rev()
|
||||
.map(|commit| -> Result<_, CommandError> {
|
||||
let mut commit_builder = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), commit)
|
||||
.detach();
|
||||
let mut commit_builder = tx.repo_mut().rewrite_commit(commit).detach();
|
||||
if commit_builder.description().is_empty() {
|
||||
commit_builder
|
||||
.set_description(command.settings().get_string("ui.default-description")?);
|
||||
|
@ -244,14 +241,13 @@ pub(crate) fn cmd_describe(
|
|||
// rewriting the same commit multiple times, and adding additional entries
|
||||
// in the predecessor chain.
|
||||
tx.repo_mut().transform_descendants(
|
||||
command.settings(),
|
||||
commit_descriptions
|
||||
.keys()
|
||||
.map(|&id| id.clone())
|
||||
.collect_vec(),
|
||||
|rewriter| {
|
||||
let old_commit_id = rewriter.old_commit().id().clone();
|
||||
let mut commit_builder = rewriter.rebase(command.settings())?;
|
||||
let mut commit_builder = rewriter.rebase()?;
|
||||
if let Some(description) = commit_descriptions.get(&old_commit_id) {
|
||||
commit_builder = commit_builder.set_description(description);
|
||||
if args.reset_author {
|
||||
|
|
|
@ -138,18 +138,18 @@ don't make any changes, then the operation will be aborted.",
|
|||
} else {
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &target_commit)
|
||||
.rewrite_commit(&target_commit)
|
||||
.set_tree_id(tree_id)
|
||||
.write()?;
|
||||
// rebase_descendants early; otherwise `new_commit` would always have
|
||||
// a conflicted change id at this point.
|
||||
let (num_rebased, extra_msg) = if args.restore_descendants {
|
||||
(
|
||||
tx.repo_mut().reparent_descendants(command.settings())?,
|
||||
tx.repo_mut().reparent_descendants()?,
|
||||
" (while preserving their content)",
|
||||
)
|
||||
} else {
|
||||
(tx.repo_mut().rebase_descendants(command.settings())?, "")
|
||||
(tx.repo_mut().rebase_descendants()?, "")
|
||||
};
|
||||
if let Some(mut formatter) = ui.status_formatter() {
|
||||
write!(formatter, "Created ")?;
|
||||
|
|
|
@ -229,10 +229,9 @@ pub(crate) fn cmd_duplicate(
|
|||
&& args.insert_after.is_empty()
|
||||
&& args.insert_before.is_empty()
|
||||
{
|
||||
duplicate_commits_onto_parents(command.settings(), tx.repo_mut(), &to_duplicate)?
|
||||
duplicate_commits_onto_parents(tx.repo_mut(), &to_duplicate)?
|
||||
} else {
|
||||
duplicate_commits(
|
||||
command.settings(),
|
||||
tx.repo_mut(),
|
||||
&to_duplicate,
|
||||
&parent_commit_ids,
|
||||
|
|
|
@ -122,7 +122,7 @@ pub(crate) fn cmd_file_chmod(
|
|||
|
||||
let new_tree_id = tree_builder.write_tree(store)?;
|
||||
tx.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.rewrite_commit(&commit)
|
||||
.set_tree_id(new_tree_id)
|
||||
.write()?;
|
||||
tx.finish(
|
||||
|
|
|
@ -52,7 +52,7 @@ pub(crate) fn cmd_file_track(
|
|||
let mut tx = workspace_command.start_transaction().into_inner();
|
||||
let (mut locked_ws, _wc_commit) = workspace_command.start_working_copy_mutation()?;
|
||||
let (_tree_id, stats) = locked_ws.locked_wc().snapshot(&options)?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants(command.settings())?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants()?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub(crate) fn cmd_file_untrack(
|
|||
let new_tree_id = tree_builder.write_tree(&store)?;
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &wc_commit)
|
||||
.rewrite_commit(&wc_commit)
|
||||
.set_tree_id(new_tree_id)
|
||||
.write()?;
|
||||
// Reset the working copy to the new commit
|
||||
|
@ -105,7 +105,7 @@ Make sure they're ignored, then try again.",
|
|||
locked_ws.locked_wc().reset(&new_commit)?;
|
||||
}
|
||||
}
|
||||
let num_rebased = tx.repo_mut().rebase_descendants(command.settings())?;
|
||||
let num_rebased = tx.repo_mut().rebase_descendants()?;
|
||||
if num_rebased > 0 {
|
||||
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
|
|
|
@ -252,7 +252,6 @@ pub(crate) fn cmd_fix(
|
|||
let mut num_checked_commits = 0;
|
||||
let mut num_fixed_commits = 0;
|
||||
tx.repo_mut().transform_descendants(
|
||||
command.settings(),
|
||||
root_commits.iter().cloned().collect_vec(),
|
||||
|mut rewriter| {
|
||||
// TODO: Build the trees in parallel before `transform_descendants()` and only
|
||||
|
@ -287,7 +286,7 @@ pub(crate) fn cmd_fix(
|
|||
if changes > 0 {
|
||||
num_fixed_commits += 1;
|
||||
let new_tree = tree_builder.write_tree(rewriter.mut_repo().store())?;
|
||||
let builder = rewriter.reparent(command.settings());
|
||||
let builder = rewriter.reparent();
|
||||
builder.set_tree_id(new_tree).write()?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -195,7 +195,7 @@ pub(crate) fn cmd_new(
|
|||
let merged_tree = merge_commit_trees(tx.repo(), &parent_commits)?;
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(command.settings(), parent_commit_ids, merged_tree.id())
|
||||
.new_commit(parent_commit_ids, merged_tree.id())
|
||||
.set_description(join_message_paragraphs(&args.message_paragraphs))
|
||||
.write()?;
|
||||
|
||||
|
@ -208,15 +208,10 @@ pub(crate) fn cmd_new(
|
|||
.cloned()
|
||||
.chain(std::iter::once(new_commit.id().clone()))
|
||||
.collect_vec();
|
||||
rebase_commit(
|
||||
command.settings(),
|
||||
tx.repo_mut(),
|
||||
child_commit,
|
||||
new_parent_ids,
|
||||
)?;
|
||||
rebase_commit(tx.repo_mut(), child_commit, new_parent_ids)?;
|
||||
num_rebased += 1;
|
||||
}
|
||||
num_rebased += tx.repo_mut().rebase_descendants(command.settings())?;
|
||||
num_rebased += tx.repo_mut().rebase_descendants()?;
|
||||
|
||||
if args.no_edit {
|
||||
if let Some(mut formatter) = ui.status_formatter() {
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn cmd_op_diff(
|
|||
} else {
|
||||
to_op = workspace_command.resolve_single_op(args.operation.as_deref().unwrap_or("@"))?;
|
||||
let to_op_parents: Vec<_> = to_op.parents().try_collect()?;
|
||||
from_op = repo_loader.merge_operations(command.settings(), to_op_parents, None)?;
|
||||
from_op = repo_loader.merge_operations(to_op_parents, None)?;
|
||||
}
|
||||
let graph_style = GraphStyle::from_settings(command.settings())?;
|
||||
let with_content_format = LogContentFormat::new(ui, command.settings())?;
|
||||
|
|
|
@ -151,7 +151,7 @@ fn do_op_log(
|
|||
op: &Operation,
|
||||
with_content_format: &LogContentFormat| {
|
||||
let parents: Vec<_> = op.parents().try_collect()?;
|
||||
let parent_op = repo_loader.merge_operations(settings, parents, None)?;
|
||||
let parent_op = repo_loader.merge_operations(parents, None)?;
|
||||
let parent_repo = repo_loader.load_at(&parent_op)?;
|
||||
let repo = repo_loader.load_at(op)?;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn cmd_op_show(
|
|||
let repo_loader = workspace_command.workspace().repo_loader();
|
||||
let op = workspace_command.resolve_single_op(&args.operation)?;
|
||||
let parents: Vec<_> = op.parents().try_collect()?;
|
||||
let parent_op = repo_loader.merge_operations(command.settings(), parents, None)?;
|
||||
let parent_op = repo_loader.merge_operations(parents, None)?;
|
||||
let parent_repo = repo_loader.load_at(&parent_op)?;
|
||||
let repo = repo_loader.load_at(&op)?;
|
||||
|
||||
|
|
|
@ -113,7 +113,6 @@ pub(crate) fn cmd_parallelize(
|
|||
}
|
||||
|
||||
tx.repo_mut().transform_descendants(
|
||||
command.settings(),
|
||||
target_commits.iter().ids().cloned().collect_vec(),
|
||||
|mut rewriter| {
|
||||
// Commits in the target set do not depend on each other but they still depend
|
||||
|
@ -137,7 +136,7 @@ pub(crate) fn cmd_parallelize(
|
|||
rewriter.set_new_rewritten_parents(&new_parents);
|
||||
}
|
||||
if rewriter.parents_changed() {
|
||||
let builder = rewriter.rebase(command.settings())?;
|
||||
let builder = rewriter.rebase()?;
|
||||
builder.write()?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -33,7 +33,6 @@ use jj_lib::rewrite::EmptyBehaviour;
|
|||
use jj_lib::rewrite::MoveCommitsStats;
|
||||
use jj_lib::rewrite::MoveCommitsTarget;
|
||||
use jj_lib::rewrite::RebaseOptions;
|
||||
use jj_lib::settings::UserSettings;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::cli_util::short_commit_hash;
|
||||
|
@ -254,7 +253,6 @@ pub(crate) fn cmd_rebase(
|
|||
if !args.revisions.is_empty() {
|
||||
rebase_revisions(
|
||||
ui,
|
||||
command.settings(),
|
||||
&mut workspace_command,
|
||||
&args.revisions,
|
||||
&args.destination,
|
||||
|
@ -263,7 +261,6 @@ pub(crate) fn cmd_rebase(
|
|||
} else if !args.source.is_empty() {
|
||||
rebase_source(
|
||||
ui,
|
||||
command.settings(),
|
||||
&mut workspace_command,
|
||||
&args.source,
|
||||
&args.destination,
|
||||
|
@ -272,7 +269,6 @@ pub(crate) fn cmd_rebase(
|
|||
} else {
|
||||
rebase_branch(
|
||||
ui,
|
||||
command.settings(),
|
||||
&mut workspace_command,
|
||||
&args.branch,
|
||||
&args.destination,
|
||||
|
@ -284,7 +280,6 @@ pub(crate) fn cmd_rebase(
|
|||
|
||||
fn rebase_revisions(
|
||||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
workspace_command: &mut WorkspaceCommandHelper,
|
||||
revisions: &[RevisionArg],
|
||||
rebase_destination: &RebaseDestinationArgs,
|
||||
|
@ -310,7 +305,6 @@ fn rebase_revisions(
|
|||
}
|
||||
rebase_revisions_transaction(
|
||||
ui,
|
||||
settings,
|
||||
workspace_command,
|
||||
&new_parents.iter().ids().cloned().collect_vec(),
|
||||
&new_children,
|
||||
|
@ -321,7 +315,6 @@ fn rebase_revisions(
|
|||
|
||||
fn rebase_source(
|
||||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
workspace_command: &mut WorkspaceCommandHelper,
|
||||
source: &[RevisionArg],
|
||||
rebase_destination: &RebaseDestinationArgs,
|
||||
|
@ -343,7 +336,6 @@ fn rebase_source(
|
|||
|
||||
rebase_descendants_transaction(
|
||||
ui,
|
||||
settings,
|
||||
workspace_command,
|
||||
&new_parents.iter().ids().cloned().collect_vec(),
|
||||
&new_children,
|
||||
|
@ -354,7 +346,6 @@ fn rebase_source(
|
|||
|
||||
fn rebase_branch(
|
||||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
workspace_command: &mut WorkspaceCommandHelper,
|
||||
branch: &[RevisionArg],
|
||||
rebase_destination: &RebaseDestinationArgs,
|
||||
|
@ -392,7 +383,6 @@ fn rebase_branch(
|
|||
|
||||
rebase_descendants_transaction(
|
||||
ui,
|
||||
settings,
|
||||
workspace_command,
|
||||
&new_parent_ids,
|
||||
&new_children,
|
||||
|
@ -403,7 +393,6 @@ fn rebase_branch(
|
|||
|
||||
fn rebase_descendants_transaction(
|
||||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
workspace_command: &mut WorkspaceCommandHelper,
|
||||
new_parent_ids: &[CommitId],
|
||||
new_children: &[Commit],
|
||||
|
@ -429,7 +418,6 @@ fn rebase_descendants_transaction(
|
|||
};
|
||||
|
||||
let stats = move_commits(
|
||||
settings,
|
||||
tx.repo_mut(),
|
||||
new_parent_ids,
|
||||
new_children,
|
||||
|
@ -511,7 +499,6 @@ fn compute_rebase_destination(
|
|||
/// Creates a transaction for rebasing revisions.
|
||||
fn rebase_revisions_transaction(
|
||||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
workspace_command: &mut WorkspaceCommandHelper,
|
||||
new_parent_ids: &[CommitId],
|
||||
new_children: &[Commit],
|
||||
|
@ -535,7 +522,6 @@ fn rebase_revisions_transaction(
|
|||
};
|
||||
|
||||
let stats = move_commits(
|
||||
settings,
|
||||
tx.repo_mut(),
|
||||
new_parent_ids,
|
||||
new_children,
|
||||
|
|
|
@ -115,7 +115,7 @@ pub(crate) fn cmd_resolve(
|
|||
let new_tree_id = merge_editor.edit_file(&tree, repo_path)?;
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.rewrite_commit(&commit)
|
||||
.set_tree_id(new_tree_id)
|
||||
.write()?;
|
||||
tx.finish(
|
||||
|
|
|
@ -136,18 +136,18 @@ pub(crate) fn cmd_restore(
|
|||
let mut tx = workspace_command.start_transaction();
|
||||
let new_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &to_commit)
|
||||
.rewrite_commit(&to_commit)
|
||||
.set_tree_id(new_tree_id)
|
||||
.write()?;
|
||||
// rebase_descendants early; otherwise `new_commit` would always have
|
||||
// a conflicted change id at this point.
|
||||
let (num_rebased, extra_msg) = if args.restore_descendants {
|
||||
(
|
||||
tx.repo_mut().reparent_descendants(command.settings())?,
|
||||
tx.repo_mut().reparent_descendants()?,
|
||||
" (while preserving their content)",
|
||||
)
|
||||
} else {
|
||||
(tx.repo_mut().rebase_descendants(command.settings())?, "")
|
||||
(tx.repo_mut().rebase_descendants()?, "")
|
||||
};
|
||||
if let Some(mut formatter) = ui.status_formatter() {
|
||||
write!(formatter, "Created ")?;
|
||||
|
|
|
@ -82,7 +82,7 @@ pub(crate) fn cmd_simplify_parents(
|
|||
let mut reparented_descendants = 0;
|
||||
|
||||
tx.repo_mut()
|
||||
.transform_descendants(command.settings(), commit_ids, |mut rewriter| {
|
||||
.transform_descendants(commit_ids, |mut rewriter| {
|
||||
let num_old_heads = rewriter.new_parents().len();
|
||||
if commit_ids_set.contains(rewriter.old_commit().id()) && num_old_heads > 1 {
|
||||
rewriter.simplify_ancestor_merge();
|
||||
|
@ -90,7 +90,7 @@ pub(crate) fn cmd_simplify_parents(
|
|||
let num_new_heads = rewriter.new_parents().len();
|
||||
|
||||
if rewriter.parents_changed() {
|
||||
rewriter.reparent(command.settings()).write()?;
|
||||
rewriter.reparent().write()?;
|
||||
|
||||
if num_new_heads < num_old_heads {
|
||||
simplified_commits += 1;
|
||||
|
|
|
@ -138,10 +138,7 @@ The remainder will be in the second commit.
|
|||
// Create the first commit, which includes the changes selected by the user.
|
||||
let selected_tree = tx.repo().store().get_root_tree(&selected_tree_id)?;
|
||||
let first_commit = {
|
||||
let mut commit_builder = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.detach();
|
||||
let mut commit_builder = tx.repo_mut().rewrite_commit(&commit).detach();
|
||||
commit_builder.set_tree_id(selected_tree_id);
|
||||
if commit_builder.description().is_empty() {
|
||||
commit_builder
|
||||
|
@ -179,10 +176,7 @@ The remainder will be in the second commit.
|
|||
} else {
|
||||
vec![first_commit.id().clone()]
|
||||
};
|
||||
let mut commit_builder = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.detach();
|
||||
let mut commit_builder = tx.repo_mut().rewrite_commit(&commit).detach();
|
||||
commit_builder
|
||||
.set_parents(parents)
|
||||
.set_tree_id(new_tree.id())
|
||||
|
@ -219,10 +213,8 @@ The remainder will be in the second commit.
|
|||
tx.repo_mut()
|
||||
.set_rewritten_commit(commit.id().clone(), second_commit.id().clone());
|
||||
let mut num_rebased = 0;
|
||||
tx.repo_mut().transform_descendants(
|
||||
command.settings(),
|
||||
vec![commit.id().clone()],
|
||||
|mut rewriter| {
|
||||
tx.repo_mut()
|
||||
.transform_descendants(vec![commit.id().clone()], |mut rewriter| {
|
||||
num_rebased += 1;
|
||||
if args.parallel {
|
||||
rewriter
|
||||
|
@ -230,10 +222,9 @@ The remainder will be in the second commit.
|
|||
}
|
||||
// We don't need to do anything special for the non-parallel case
|
||||
// since we already marked the original commit as rewritten.
|
||||
rewriter.rebase(command.settings())?.write()?;
|
||||
rewriter.rebase()?.write()?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
})?;
|
||||
|
||||
if let Some(mut formatter) = ui.status_formatter() {
|
||||
if num_rebased > 0 {
|
||||
|
|
|
@ -253,7 +253,6 @@ from the source will be moved into the destination.
|
|||
|
||||
let repo_path = tx.base_workspace_helper().repo_path().to_owned();
|
||||
match rewrite::squash_commits(
|
||||
settings,
|
||||
tx.repo_mut(),
|
||||
&source_commits,
|
||||
destination,
|
||||
|
|
|
@ -124,20 +124,20 @@ aborted.
|
|||
)?;
|
||||
// Commit the new child on top of the parent's parents.
|
||||
tx.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.rewrite_commit(&commit)
|
||||
.set_parents(parent.parent_ids().to_vec())
|
||||
.set_description(description)
|
||||
.write()?;
|
||||
} else {
|
||||
let new_parent = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(command.settings(), &parent)
|
||||
.rewrite_commit(&parent)
|
||||
.set_tree_id(new_parent_tree_id)
|
||||
.set_predecessors(vec![parent.id().clone(), commit.id().clone()])
|
||||
.write()?;
|
||||
// Commit the new child on top of the new parent.
|
||||
tx.repo_mut()
|
||||
.rewrite_commit(command.settings(), &commit)
|
||||
.rewrite_commit(&commit)
|
||||
.set_parents(vec![new_parent.id().clone()])
|
||||
.write()?;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,6 @@ pub fn cmd_workspace_add(
|
|||
let working_copy_factory = command.get_working_copy_factory()?;
|
||||
let repo_path = old_workspace_command.repo_path();
|
||||
let (new_workspace, repo) = Workspace::init_workspace_with_existing_repo(
|
||||
command.settings(),
|
||||
&destination_path,
|
||||
repo_path,
|
||||
repo,
|
||||
|
@ -185,10 +184,7 @@ pub fn cmd_workspace_add(
|
|||
|
||||
let tree = merge_commit_trees(tx.repo(), &parents)?;
|
||||
let parent_ids = parents.iter().ids().cloned().collect_vec();
|
||||
let new_wc_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(command.settings(), parent_ids, tree.id())
|
||||
.write()?;
|
||||
let new_wc_commit = tx.repo_mut().new_commit(parent_ids, tree.id()).write()?;
|
||||
|
||||
tx.edit(&new_wc_commit)?;
|
||||
tx.finish(
|
||||
|
|
|
@ -48,7 +48,6 @@ use crate::repo_path::RepoPath;
|
|||
use crate::repo_path::RepoPathBuf;
|
||||
use crate::revset::ResolvedRevsetExpression;
|
||||
use crate::revset::RevsetEvaluationError;
|
||||
use crate::settings::UserSettings;
|
||||
|
||||
/// The source commit to absorb into its ancestry.
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -266,49 +265,44 @@ pub fn absorb_hunks(
|
|||
repo: &mut MutableRepo,
|
||||
source: &AbsorbSource,
|
||||
mut selected_trees: HashMap<CommitId, MergedTreeBuilder>,
|
||||
settings: &UserSettings,
|
||||
) -> BackendResult<(Vec<Commit>, usize)> {
|
||||
let store = repo.store().clone();
|
||||
let mut rewritten_commits = Vec::new();
|
||||
let mut num_rebased = 0;
|
||||
// Rewrite commits in topological order so that descendant commits wouldn't
|
||||
// be rewritten multiple times.
|
||||
repo.transform_descendants(
|
||||
settings,
|
||||
selected_trees.keys().cloned().collect(),
|
||||
|rewriter| {
|
||||
// Remove selected hunks from the source commit by reparent()
|
||||
if rewriter.old_commit().id() == source.commit.id() {
|
||||
let commit_builder = rewriter.reparent(settings);
|
||||
if commit_builder.is_discardable()? {
|
||||
commit_builder.abandon();
|
||||
} else {
|
||||
commit_builder.write()?;
|
||||
num_rebased += 1;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let Some(tree_builder) = selected_trees.remove(rewriter.old_commit().id()) else {
|
||||
rewriter.rebase(settings)?.write()?;
|
||||
repo.transform_descendants(selected_trees.keys().cloned().collect(), |rewriter| {
|
||||
// Remove selected hunks from the source commit by reparent()
|
||||
if rewriter.old_commit().id() == source.commit.id() {
|
||||
let commit_builder = rewriter.reparent();
|
||||
if commit_builder.is_discardable()? {
|
||||
commit_builder.abandon();
|
||||
} else {
|
||||
commit_builder.write()?;
|
||||
num_rebased += 1;
|
||||
return Ok(());
|
||||
};
|
||||
// Merge hunks between source parent tree and selected tree
|
||||
let selected_tree_id = tree_builder.write_tree(&store)?;
|
||||
let commit_builder = rewriter.rebase(settings)?;
|
||||
let destination_tree = store.get_root_tree(commit_builder.tree_id())?;
|
||||
let selected_tree = store.get_root_tree(&selected_tree_id)?;
|
||||
let new_tree = destination_tree.merge(&source.parent_tree, &selected_tree)?;
|
||||
let mut predecessors = commit_builder.predecessors().to_vec();
|
||||
predecessors.push(source.commit.id().clone());
|
||||
let new_commit = commit_builder
|
||||
.set_tree_id(new_tree.id())
|
||||
.set_predecessors(predecessors)
|
||||
.write()?;
|
||||
rewritten_commits.push(new_commit);
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let Some(tree_builder) = selected_trees.remove(rewriter.old_commit().id()) else {
|
||||
rewriter.rebase()?.write()?;
|
||||
num_rebased += 1;
|
||||
return Ok(());
|
||||
};
|
||||
// Merge hunks between source parent tree and selected tree
|
||||
let selected_tree_id = tree_builder.write_tree(&store)?;
|
||||
let commit_builder = rewriter.rebase()?;
|
||||
let destination_tree = store.get_root_tree(commit_builder.tree_id())?;
|
||||
let selected_tree = store.get_root_tree(&selected_tree_id)?;
|
||||
let new_tree = destination_tree.merge(&source.parent_tree, &selected_tree)?;
|
||||
let mut predecessors = commit_builder.predecessors().to_vec();
|
||||
predecessors.push(source.commit.id().clone());
|
||||
let new_commit = commit_builder
|
||||
.set_tree_id(new_tree.id())
|
||||
.set_predecessors(predecessors)
|
||||
.write()?;
|
||||
rewritten_commits.push(new_commit);
|
||||
Ok(())
|
||||
})?;
|
||||
Ok((rewritten_commits, num_rebased))
|
||||
}
|
||||
|
||||
|
|
|
@ -300,11 +300,8 @@ impl ReadonlyRepo {
|
|||
Transaction::new(mut_repo, self.settings())
|
||||
}
|
||||
|
||||
pub fn reload_at_head(
|
||||
&self,
|
||||
user_settings: &UserSettings,
|
||||
) -> Result<Arc<ReadonlyRepo>, RepoLoaderError> {
|
||||
self.loader().load_at_head(user_settings)
|
||||
pub fn reload_at_head(&self) -> Result<Arc<ReadonlyRepo>, RepoLoaderError> {
|
||||
self.loader().load_at_head()
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
|
@ -711,14 +708,11 @@ impl RepoLoader {
|
|||
&self.submodule_store
|
||||
}
|
||||
|
||||
pub fn load_at_head(
|
||||
&self,
|
||||
user_settings: &UserSettings,
|
||||
) -> Result<Arc<ReadonlyRepo>, RepoLoaderError> {
|
||||
pub fn load_at_head(&self) -> Result<Arc<ReadonlyRepo>, RepoLoaderError> {
|
||||
let op = op_heads_store::resolve_op_heads(
|
||||
self.op_heads_store.as_ref(),
|
||||
&self.op_store,
|
||||
|op_heads| self._resolve_op_heads(op_heads, user_settings),
|
||||
|op_heads| self._resolve_op_heads(op_heads),
|
||||
)?;
|
||||
let view = op.view()?;
|
||||
self._finish_load(op, view)
|
||||
|
@ -765,7 +759,6 @@ impl RepoLoader {
|
|||
/// operation if the `operations` is empty.
|
||||
pub fn merge_operations(
|
||||
&self,
|
||||
settings: &UserSettings,
|
||||
operations: Vec<Operation>,
|
||||
tx_description: Option<&str>,
|
||||
) -> Result<Operation, RepoLoaderError> {
|
||||
|
@ -779,7 +772,7 @@ impl RepoLoader {
|
|||
let mut tx = base_repo.start_transaction();
|
||||
for other_op in operations {
|
||||
tx.merge_operation(other_op)?;
|
||||
tx.repo_mut().rebase_descendants(settings)?;
|
||||
tx.repo_mut().rebase_descendants()?;
|
||||
}
|
||||
let tx_description = tx_description.map_or_else(
|
||||
|| format!("merge {num_operations} operations"),
|
||||
|
@ -794,17 +787,9 @@ impl RepoLoader {
|
|||
Ok(final_op)
|
||||
}
|
||||
|
||||
fn _resolve_op_heads(
|
||||
&self,
|
||||
op_heads: Vec<Operation>,
|
||||
user_settings: &UserSettings,
|
||||
) -> Result<Operation, RepoLoaderError> {
|
||||
fn _resolve_op_heads(&self, op_heads: Vec<Operation>) -> Result<Operation, RepoLoaderError> {
|
||||
assert!(!op_heads.is_empty());
|
||||
self.merge_operations(
|
||||
user_settings,
|
||||
op_heads,
|
||||
Some("reconcile divergent operations"),
|
||||
)
|
||||
self.merge_operations(op_heads, Some("reconcile divergent operations"))
|
||||
}
|
||||
|
||||
fn _finish_load(
|
||||
|
@ -900,21 +885,14 @@ impl MutableRepo {
|
|||
}
|
||||
|
||||
/// Returns a [`CommitBuilder`] to write new commit to the repo.
|
||||
pub fn new_commit(
|
||||
&mut self,
|
||||
settings: &UserSettings,
|
||||
parents: Vec<CommitId>,
|
||||
tree_id: MergedTreeId,
|
||||
) -> CommitBuilder {
|
||||
pub fn new_commit(&mut self, parents: Vec<CommitId>, tree_id: MergedTreeId) -> CommitBuilder {
|
||||
let settings = self.base_repo.settings();
|
||||
DetachedCommitBuilder::for_new_commit(self, settings, parents, tree_id).attach(self)
|
||||
}
|
||||
|
||||
/// Returns a [`CommitBuilder`] to rewrite an existing commit in the repo.
|
||||
pub fn rewrite_commit(
|
||||
&mut self,
|
||||
settings: &UserSettings,
|
||||
predecessor: &Commit,
|
||||
) -> CommitBuilder {
|
||||
pub fn rewrite_commit(&mut self, predecessor: &Commit) -> CommitBuilder {
|
||||
let settings = self.base_repo.settings();
|
||||
DetachedCommitBuilder::for_rewrite_from(self, settings, predecessor).attach(self)
|
||||
// CommitBuilder::write will record the rewrite in
|
||||
// `self.rewritten_commits`
|
||||
|
@ -1074,16 +1052,16 @@ impl MutableRepo {
|
|||
|
||||
/// Updates bookmarks, working copies, and anonymous heads after rewriting
|
||||
/// and/or abandoning commits.
|
||||
pub fn update_rewritten_references(&mut self, settings: &UserSettings) -> BackendResult<()> {
|
||||
self.update_all_references(settings)?;
|
||||
pub fn update_rewritten_references(&mut self) -> BackendResult<()> {
|
||||
self.update_all_references()?;
|
||||
self.update_heads();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_all_references(&mut self, settings: &UserSettings) -> BackendResult<()> {
|
||||
fn update_all_references(&mut self) -> BackendResult<()> {
|
||||
let rewrite_mapping = self.resolve_rewrite_mapping_with(|_| true);
|
||||
self.update_local_bookmarks(&rewrite_mapping);
|
||||
self.update_wc_commits(settings, &rewrite_mapping)?;
|
||||
self.update_wc_commits(&rewrite_mapping)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1092,6 @@ impl MutableRepo {
|
|||
|
||||
fn update_wc_commits(
|
||||
&mut self,
|
||||
settings: &UserSettings,
|
||||
rewrite_mapping: &HashMap<CommitId, Vec<CommitId>>,
|
||||
) -> BackendResult<()> {
|
||||
let changed_wc_commits = self
|
||||
|
@ -1144,11 +1121,7 @@ impl MutableRepo {
|
|||
.try_collect()?;
|
||||
let merged_parents_tree = merge_commit_trees(self, &new_commits)?;
|
||||
let commit = self
|
||||
.new_commit(
|
||||
settings,
|
||||
new_commit_ids.clone(),
|
||||
merged_parents_tree.id().clone(),
|
||||
)
|
||||
.new_commit(new_commit_ids.clone(), merged_parents_tree.id().clone())
|
||||
.write()?;
|
||||
recreated_wc_commits.insert(old_commit_id, commit.clone());
|
||||
commit
|
||||
|
@ -1245,7 +1218,6 @@ impl MutableRepo {
|
|||
/// will not be called for descendants of those commits.
|
||||
pub fn transform_descendants(
|
||||
&mut self,
|
||||
settings: &UserSettings,
|
||||
roots: Vec<CommitId>,
|
||||
mut callback: impl FnMut(CommitRewriter) -> BackendResult<()>,
|
||||
) -> BackendResult<()> {
|
||||
|
@ -1255,7 +1227,7 @@ impl MutableRepo {
|
|||
let rewriter = CommitRewriter::new(self, old_commit, new_parent_ids);
|
||||
callback(rewriter)?;
|
||||
}
|
||||
self.update_rewritten_references(settings)?;
|
||||
self.update_rewritten_references()?;
|
||||
// Since we didn't necessarily visit all descendants of rewritten commits (e.g.
|
||||
// if they were rewritten in the callback), there can still be commits left to
|
||||
// rebase, so we don't clear `parent_mapping` here.
|
||||
|
@ -1288,16 +1260,14 @@ impl MutableRepo {
|
|||
/// bookmarks of the abandoned commit.
|
||||
pub fn rebase_descendants_with_options_return_map(
|
||||
&mut self,
|
||||
settings: &UserSettings,
|
||||
options: RebaseOptions,
|
||||
) -> BackendResult<HashMap<CommitId, CommitId>> {
|
||||
let mut rebased: HashMap<CommitId, CommitId> = HashMap::new();
|
||||
let roots = self.parent_mapping.keys().cloned().collect_vec();
|
||||
self.transform_descendants(settings, roots, |rewriter| {
|
||||
self.transform_descendants(roots, |rewriter| {
|
||||
if rewriter.parents_changed() {
|
||||
let old_commit_id = rewriter.old_commit().id().clone();
|
||||
let rebased_commit: RebasedCommit =
|
||||
rebase_commit_with_options(settings, rewriter, &options)?;
|
||||
let rebased_commit: RebasedCommit = rebase_commit_with_options(rewriter, &options)?;
|
||||
let new_commit_id = match rebased_commit {
|
||||
RebasedCommit::Rewritten(new_commit) => new_commit.id().clone(),
|
||||
RebasedCommit::Abandoned { parent_id } => parent_id,
|
||||
|
@ -1320,12 +1290,12 @@ impl MutableRepo {
|
|||
/// emptied following the rebase operation. To customize the rebase
|
||||
/// behavior, use
|
||||
/// [`MutableRepo::rebase_descendants_with_options_return_map`].
|
||||
pub fn rebase_descendants(&mut self, settings: &UserSettings) -> BackendResult<usize> {
|
||||
pub fn rebase_descendants(&mut self) -> BackendResult<usize> {
|
||||
let roots = self.parent_mapping.keys().cloned().collect_vec();
|
||||
let mut num_rebased = 0;
|
||||
self.transform_descendants(settings, roots, |rewriter| {
|
||||
self.transform_descendants(roots, |rewriter| {
|
||||
if rewriter.parents_changed() {
|
||||
let builder = rewriter.rebase(settings)?;
|
||||
let builder = rewriter.rebase()?;
|
||||
builder.write()?;
|
||||
num_rebased += 1;
|
||||
}
|
||||
|
@ -1341,12 +1311,12 @@ impl MutableRepo {
|
|||
/// be recursively reparented onto the new version of their parents.
|
||||
/// The content of those descendants will remain untouched.
|
||||
/// Returns the number of reparented descendants.
|
||||
pub fn reparent_descendants(&mut self, settings: &UserSettings) -> BackendResult<usize> {
|
||||
pub fn reparent_descendants(&mut self) -> BackendResult<usize> {
|
||||
let roots = self.parent_mapping.keys().cloned().collect_vec();
|
||||
let mut num_reparented = 0;
|
||||
self.transform_descendants(settings, roots, |rewriter| {
|
||||
self.transform_descendants(roots, |rewriter| {
|
||||
if rewriter.parents_changed() {
|
||||
let builder = rewriter.reparent(settings);
|
||||
let builder = rewriter.reparent();
|
||||
builder.write()?;
|
||||
num_reparented += 1;
|
||||
}
|
||||
|
@ -1386,15 +1356,10 @@ impl MutableRepo {
|
|||
pub fn check_out(
|
||||
&mut self,
|
||||
workspace_id: WorkspaceId,
|
||||
settings: &UserSettings,
|
||||
commit: &Commit,
|
||||
) -> Result<Commit, CheckOutCommitError> {
|
||||
let wc_commit = self
|
||||
.new_commit(
|
||||
settings,
|
||||
vec![commit.id().clone()],
|
||||
commit.tree_id().clone(),
|
||||
)
|
||||
.new_commit(vec![commit.id().clone()], commit.tree_id().clone())
|
||||
.write()?;
|
||||
self.edit(workspace_id, &wc_commit)?;
|
||||
Ok(wc_commit)
|
||||
|
|
|
@ -44,7 +44,6 @@ use crate::repo::Repo;
|
|||
use crate::repo_path::RepoPath;
|
||||
use crate::revset::RevsetExpression;
|
||||
use crate::revset::RevsetIteratorExt;
|
||||
use crate::settings::UserSettings;
|
||||
use crate::store::Store;
|
||||
|
||||
/// Merges `commits` and tries to resolve any conflicts recursively.
|
||||
|
@ -119,13 +118,12 @@ pub fn restore_tree(
|
|||
}
|
||||
|
||||
pub fn rebase_commit(
|
||||
settings: &UserSettings,
|
||||
mut_repo: &mut MutableRepo,
|
||||
old_commit: Commit,
|
||||
new_parents: Vec<CommitId>,
|
||||
) -> BackendResult<Commit> {
|
||||
let rewriter = CommitRewriter::new(mut_repo, old_commit, new_parents);
|
||||
let builder = rewriter.rebase(settings)?;
|
||||
let builder = rewriter.rebase()?;
|
||||
builder.write()
|
||||
}
|
||||
|
||||
|
@ -223,7 +221,6 @@ impl<'repo> CommitRewriter<'repo> {
|
|||
/// for the new commit. Returns `None` if the commit was abandoned.
|
||||
pub fn rebase_with_empty_behavior(
|
||||
self,
|
||||
settings: &UserSettings,
|
||||
empty: EmptyBehaviour,
|
||||
) -> BackendResult<Option<CommitBuilder<'repo>>> {
|
||||
let old_parents: Vec<_> = self.old_commit.parents().try_collect()?;
|
||||
|
@ -282,7 +279,7 @@ impl<'repo> CommitRewriter<'repo> {
|
|||
|
||||
let builder = self
|
||||
.mut_repo
|
||||
.rewrite_commit(settings, &self.old_commit)
|
||||
.rewrite_commit(&self.old_commit)
|
||||
.set_parents(self.new_parents)
|
||||
.set_tree_id(new_tree_id);
|
||||
Ok(Some(builder))
|
||||
|
@ -290,16 +287,16 @@ impl<'repo> CommitRewriter<'repo> {
|
|||
|
||||
/// Rebase the old commit onto the new parents. Returns a `CommitBuilder`
|
||||
/// for the new commit.
|
||||
pub fn rebase(self, settings: &UserSettings) -> BackendResult<CommitBuilder<'repo>> {
|
||||
let builder = self.rebase_with_empty_behavior(settings, EmptyBehaviour::Keep)?;
|
||||
pub fn rebase(self) -> BackendResult<CommitBuilder<'repo>> {
|
||||
let builder = self.rebase_with_empty_behavior(EmptyBehaviour::Keep)?;
|
||||
Ok(builder.unwrap())
|
||||
}
|
||||
|
||||
/// Rewrite the old commit onto the new parents without changing its
|
||||
/// contents. Returns a `CommitBuilder` for the new commit.
|
||||
pub fn reparent(self, settings: &UserSettings) -> CommitBuilder<'repo> {
|
||||
pub fn reparent(self) -> CommitBuilder<'repo> {
|
||||
self.mut_repo
|
||||
.rewrite_commit(settings, &self.old_commit)
|
||||
.rewrite_commit(&self.old_commit)
|
||||
.set_parents(self.new_parents)
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +307,6 @@ pub enum RebasedCommit {
|
|||
}
|
||||
|
||||
pub fn rebase_commit_with_options(
|
||||
settings: &UserSettings,
|
||||
mut rewriter: CommitRewriter<'_>,
|
||||
options: &RebaseOptions,
|
||||
) -> BackendResult<RebasedCommit> {
|
||||
|
@ -324,7 +320,7 @@ pub fn rebase_commit_with_options(
|
|||
_ => None,
|
||||
};
|
||||
let new_parents_len = rewriter.new_parents.len();
|
||||
if let Some(builder) = rewriter.rebase_with_empty_behavior(settings, options.empty)? {
|
||||
if let Some(builder) = rewriter.rebase_with_empty_behavior(options.empty)? {
|
||||
let new_commit = builder.write()?;
|
||||
Ok(RebasedCommit::Rewritten(new_commit))
|
||||
} else {
|
||||
|
@ -415,7 +411,6 @@ pub enum MoveCommitsTarget {
|
|||
/// `new_children` can be rewritten, and there will be no cycles in the
|
||||
/// resulting graph. Commits in `target` should be in reverse topological order.
|
||||
pub fn move_commits(
|
||||
settings: &UserSettings,
|
||||
mut_repo: &mut MutableRepo,
|
||||
new_parent_ids: &[CommitId],
|
||||
new_children: &[Commit],
|
||||
|
@ -754,7 +749,6 @@ pub fn move_commits(
|
|||
if rewriter.parents_changed() {
|
||||
let is_target_commit = target_commit_ids.contains(&old_commit_id);
|
||||
let rebased_commit = rebase_commit_with_options(
|
||||
settings,
|
||||
rewriter,
|
||||
if is_target_commit {
|
||||
options
|
||||
|
@ -773,7 +767,7 @@ pub fn move_commits(
|
|||
num_skipped_rebases += 1;
|
||||
}
|
||||
}
|
||||
mut_repo.update_rewritten_references(settings)?;
|
||||
mut_repo.update_rewritten_references()?;
|
||||
|
||||
Ok(MoveCommitsStats {
|
||||
num_rebased_targets,
|
||||
|
@ -805,7 +799,6 @@ pub struct DuplicateCommitsStats {
|
|||
/// should not be ancestors of `parent_commit_ids`. Commits in `target_commits`
|
||||
/// should be in reverse topological order (children before parents).
|
||||
pub fn duplicate_commits(
|
||||
settings: &UserSettings,
|
||||
mut_repo: &mut MutableRepo,
|
||||
target_commits: &[CommitId],
|
||||
parent_commit_ids: &[CommitId],
|
||||
|
@ -880,7 +873,7 @@ pub fn duplicate_commits(
|
|||
.collect()
|
||||
};
|
||||
let new_commit = CommitRewriter::new(mut_repo, original_commit, new_parent_ids)
|
||||
.rebase(settings)?
|
||||
.rebase()?
|
||||
.generate_new_change_id()
|
||||
.write()?;
|
||||
duplicated_old_to_new.insert(original_commit_id.clone(), new_commit);
|
||||
|
@ -899,7 +892,7 @@ pub fn duplicate_commits(
|
|||
|
||||
// Rebase new children onto the target heads.
|
||||
let children_commit_ids_set: HashSet<CommitId> = children_commit_ids.iter().cloned().collect();
|
||||
mut_repo.transform_descendants(settings, children_commit_ids.to_vec(), |mut rewriter| {
|
||||
mut_repo.transform_descendants(children_commit_ids.to_vec(), |mut rewriter| {
|
||||
if children_commit_ids_set.contains(rewriter.old_commit().id()) {
|
||||
let mut child_new_parent_ids = IndexSet::new();
|
||||
for old_parent_id in rewriter.old_commit().parent_ids() {
|
||||
|
@ -919,7 +912,7 @@ pub fn duplicate_commits(
|
|||
rewriter.set_new_parents(child_new_parent_ids.into_iter().collect());
|
||||
}
|
||||
num_rebased += 1;
|
||||
rewriter.rebase(settings)?.write()?;
|
||||
rewriter.rebase()?.write()?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
|
@ -935,7 +928,6 @@ pub fn duplicate_commits(
|
|||
/// Commits in `target_commits` should be in reverse topological order (children
|
||||
/// before parents).
|
||||
pub fn duplicate_commits_onto_parents(
|
||||
settings: &UserSettings,
|
||||
mut_repo: &mut MutableRepo,
|
||||
target_commits: &[CommitId],
|
||||
) -> BackendResult<DuplicateCommitsStats> {
|
||||
|
@ -960,7 +952,7 @@ pub fn duplicate_commits_onto_parents(
|
|||
})
|
||||
.collect();
|
||||
let new_commit = mut_repo
|
||||
.rewrite_commit(settings, &original_commit)
|
||||
.rewrite_commit(&original_commit)
|
||||
.generate_new_change_id()
|
||||
.set_parents(new_parent_ids)
|
||||
.write()?;
|
||||
|
@ -1061,7 +1053,6 @@ pub enum SquashResult {
|
|||
/// resulting commit. Caller is responsible for setting the description and
|
||||
/// finishing the commit.
|
||||
pub fn squash_commits<E>(
|
||||
settings: &UserSettings,
|
||||
repo: &mut MutableRepo,
|
||||
sources: &[CommitToSquash],
|
||||
destination: &Commit,
|
||||
|
@ -1107,7 +1098,7 @@ where
|
|||
// Apply the reverse of the selected changes onto the source
|
||||
let new_source_tree =
|
||||
source_tree.merge(&source.commit.selected_tree, &source.commit.parent_tree)?;
|
||||
repo.rewrite_commit(settings, &source.commit.commit)
|
||||
repo.rewrite_commit(&source.commit.commit)
|
||||
.set_tree_id(new_source_tree.id().clone())
|
||||
.write()?;
|
||||
}
|
||||
|
@ -1122,8 +1113,7 @@ where
|
|||
// rewritten sources. Otherwise it will likely already have the content
|
||||
// changes we're moving, so applying them will have no effect and the
|
||||
// changes will disappear.
|
||||
let rebase_map =
|
||||
repo.rebase_descendants_with_options_return_map(settings, Default::default())?;
|
||||
let rebase_map = repo.rebase_descendants_with_options_return_map(Default::default())?;
|
||||
let rebased_destination_id = rebase_map.get(destination.id()).unwrap().clone();
|
||||
rewritten_destination = repo.store().get_commit(&rebased_destination_id)?;
|
||||
}
|
||||
|
@ -1141,7 +1131,7 @@ where
|
|||
);
|
||||
|
||||
let destination = repo
|
||||
.rewrite_commit(settings, &rewritten_destination)
|
||||
.rewrite_commit(&rewritten_destination)
|
||||
.set_tree_id(destination_tree.id().clone())
|
||||
.set_predecessors(predecessors)
|
||||
.set_description(description_fn(&abandoned_commits)?)
|
||||
|
|
|
@ -46,7 +46,6 @@ use crate::repo::RewriteRootCommit;
|
|||
use crate::repo_path::InvalidRepoPathError;
|
||||
use crate::repo_path::RepoPath;
|
||||
use crate::repo_path::RepoPathBuf;
|
||||
use crate::settings::UserSettings;
|
||||
use crate::store::Store;
|
||||
|
||||
/// The trait all working-copy implementations must implement.
|
||||
|
@ -434,7 +433,6 @@ pub fn create_and_check_out_recovery_commit(
|
|||
locked_wc: &mut dyn LockedWorkingCopy,
|
||||
repo: &Arc<ReadonlyRepo>,
|
||||
workspace_id: WorkspaceId,
|
||||
user_settings: &UserSettings,
|
||||
description: &str,
|
||||
) -> Result<(Arc<ReadonlyRepo>, Commit), RecoverWorkspaceError> {
|
||||
let mut tx = repo.start_transaction();
|
||||
|
@ -446,11 +444,7 @@ pub fn create_and_check_out_recovery_commit(
|
|||
.ok_or_else(|| RecoverWorkspaceError::WorkspaceMissingWorkingCopy(workspace_id.clone()))?;
|
||||
let commit = repo.store().get_commit(commit_id)?;
|
||||
let new_commit = repo_mut
|
||||
.new_commit(
|
||||
user_settings,
|
||||
vec![commit_id.clone()],
|
||||
commit.tree_id().clone(),
|
||||
)
|
||||
.new_commit(vec![commit_id.clone()], commit.tree_id().clone())
|
||||
.set_description(description)
|
||||
.write()?;
|
||||
repo_mut.set_wc_commit(workspace_id, new_commit.id().clone())?;
|
||||
|
|
|
@ -124,7 +124,6 @@ fn create_jj_dir(workspace_root: &Path) -> Result<PathBuf, WorkspaceInitError> {
|
|||
}
|
||||
|
||||
fn init_working_copy(
|
||||
user_settings: &UserSettings,
|
||||
repo: &Arc<ReadonlyRepo>,
|
||||
workspace_root: &Path,
|
||||
jj_dir: &Path,
|
||||
|
@ -135,11 +134,8 @@ fn init_working_copy(
|
|||
std::fs::create_dir(&working_copy_state_path).context(&working_copy_state_path)?;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut().check_out(
|
||||
workspace_id.clone(),
|
||||
user_settings,
|
||||
&repo.store().root_commit(),
|
||||
)?;
|
||||
tx.repo_mut()
|
||||
.check_out(workspace_id.clone(), &repo.store().root_commit())?;
|
||||
let repo = tx.commit(format!("add workspace '{}'", workspace_id.as_str()))?;
|
||||
|
||||
let working_copy = working_copy_factory.init_working_copy(
|
||||
|
@ -313,7 +309,6 @@ impl Workspace {
|
|||
RepoInitError::Path(err) => WorkspaceInitError::Path(err),
|
||||
})?;
|
||||
let (working_copy, repo) = init_working_copy(
|
||||
user_settings,
|
||||
&repo,
|
||||
workspace_root,
|
||||
&jj_dir,
|
||||
|
@ -350,7 +345,6 @@ impl Workspace {
|
|||
}
|
||||
|
||||
pub fn init_workspace_with_existing_repo(
|
||||
user_settings: &UserSettings,
|
||||
workspace_root: &Path,
|
||||
repo_path: &Path,
|
||||
repo: &Arc<ReadonlyRepo>,
|
||||
|
@ -372,7 +366,6 @@ impl Workspace {
|
|||
.context(&repo_file_path)?;
|
||||
|
||||
let (working_copy, repo) = init_working_copy(
|
||||
user_settings,
|
||||
repo,
|
||||
workspace_root,
|
||||
&jj_dir,
|
||||
|
|
|
@ -30,14 +30,12 @@ use jj_lib::repo::Repo;
|
|||
use jj_lib::repo_path::RepoPath;
|
||||
use jj_lib::revset::ResolvedRevsetExpression;
|
||||
use jj_lib::revset::RevsetExpression;
|
||||
use jj_lib::settings::UserSettings;
|
||||
use testutils::create_tree;
|
||||
use testutils::TestRepo;
|
||||
|
||||
fn create_commit_fn<'a>(
|
||||
mut_repo: &'a mut MutableRepo,
|
||||
settings: &'a UserSettings,
|
||||
) -> impl FnMut(&str, &[&CommitId], MergedTreeId) -> Commit + 'a {
|
||||
fn create_commit_fn(
|
||||
mut_repo: &mut MutableRepo,
|
||||
) -> impl FnMut(&str, &[&CommitId], MergedTreeId) -> Commit + '_ {
|
||||
// stabilize commit IDs for ease of debugging
|
||||
let signature = Signature {
|
||||
name: "Some One".to_owned(),
|
||||
|
@ -50,7 +48,7 @@ fn create_commit_fn<'a>(
|
|||
move |description, parent_ids, tree_id| {
|
||||
let parent_ids = parent_ids.iter().map(|&id| id.clone()).collect();
|
||||
mut_repo
|
||||
.new_commit(settings, parent_ids, tree_id)
|
||||
.new_commit(parent_ids, tree_id)
|
||||
.set_author(signature.clone())
|
||||
.set_committer(signature.clone())
|
||||
.set_description(description)
|
||||
|
@ -105,7 +103,6 @@ fn format_annotation(repo: &dyn Repo, annotation: &FileAnnotation) -> String {
|
|||
|
||||
#[test]
|
||||
fn test_annotate_linear() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -113,7 +110,7 @@ fn test_annotate_linear() {
|
|||
let file_path = RepoPath::from_internal_string("file");
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut(), &settings);
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut());
|
||||
let content1 = "";
|
||||
let content2 = "2a\n2b\n";
|
||||
let content3 = "2b\n3\n";
|
||||
|
@ -143,7 +140,6 @@ fn test_annotate_linear() {
|
|||
|
||||
#[test]
|
||||
fn test_annotate_merge_simple() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -158,7 +154,7 @@ fn test_annotate_merge_simple() {
|
|||
// |/
|
||||
// 1 "1"
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut(), &settings);
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut());
|
||||
let content1 = "1\n";
|
||||
let content2 = "2\n1\n";
|
||||
let content3 = "1\n3\n";
|
||||
|
@ -218,7 +214,6 @@ fn test_annotate_merge_simple() {
|
|||
|
||||
#[test]
|
||||
fn test_annotate_merge_split() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -233,7 +228,7 @@ fn test_annotate_merge_split() {
|
|||
// |/
|
||||
// 1 "1a 1b"
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut(), &settings);
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut());
|
||||
let content1 = "1a\n1b\n";
|
||||
let content2 = "2\n1a\n";
|
||||
let content3 = "1b\n3\n";
|
||||
|
@ -259,7 +254,6 @@ fn test_annotate_merge_split() {
|
|||
|
||||
#[test]
|
||||
fn test_annotate_merge_split_interleaved() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -278,7 +272,7 @@ fn test_annotate_merge_split_interleaved() {
|
|||
// |
|
||||
// 1 "1a 1b"
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut(), &settings);
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut());
|
||||
let content1 = "1a\n1b\n";
|
||||
let content2 = "2a\n2b\n";
|
||||
let content3 = "1a\n1b\n2a\n2b\n";
|
||||
|
@ -312,7 +306,6 @@ fn test_annotate_merge_split_interleaved() {
|
|||
|
||||
#[test]
|
||||
fn test_annotate_merge_dup() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -327,7 +320,7 @@ fn test_annotate_merge_dup() {
|
|||
// |/
|
||||
// 1 "1"
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut(), &settings);
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut());
|
||||
let content1 = "1\n";
|
||||
let content2 = "2\n1\n";
|
||||
let content3 = "1\n3\n";
|
||||
|
@ -365,7 +358,6 @@ fn test_annotate_merge_dup() {
|
|||
|
||||
#[test]
|
||||
fn test_annotate_file_directory_transition() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -374,7 +366,7 @@ fn test_annotate_file_directory_transition() {
|
|||
let file_path2 = RepoPath::from_internal_string("file");
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut(), &settings);
|
||||
let mut create_commit = create_commit_fn(tx.repo_mut());
|
||||
let tree1 = create_tree(repo, &[(file_path1, "1\n")]);
|
||||
let tree2 = create_tree(repo, &[(file_path2, "2\n")]);
|
||||
let commit1 = create_commit("commit1", &[root_commit_id], tree1.id());
|
||||
|
|
|
@ -110,7 +110,7 @@ fn test_bad_locking_children(backend: TestRepoBackend) {
|
|||
let workspace_root = test_workspace.workspace.workspace_root();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let initial = create_random_commit(tx.repo_mut(), &settings)
|
||||
let initial = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![repo.store().root_commit_id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -126,12 +126,9 @@ fn test_bad_locking_children(backend: TestRepoBackend) {
|
|||
&default_working_copy_factories(),
|
||||
)
|
||||
.unwrap();
|
||||
let machine1_repo = machine1_workspace
|
||||
.repo_loader()
|
||||
.load_at_head(&settings)
|
||||
.unwrap();
|
||||
let machine1_repo = machine1_workspace.repo_loader().load_at_head().unwrap();
|
||||
let mut machine1_tx = machine1_repo.start_transaction();
|
||||
let child1 = create_random_commit(machine1_tx.repo_mut(), &settings)
|
||||
let child1 = create_random_commit(machine1_tx.repo_mut())
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -147,12 +144,9 @@ fn test_bad_locking_children(backend: TestRepoBackend) {
|
|||
&default_working_copy_factories(),
|
||||
)
|
||||
.unwrap();
|
||||
let machine2_repo = machine2_workspace
|
||||
.repo_loader()
|
||||
.load_at_head(&settings)
|
||||
.unwrap();
|
||||
let machine2_repo = machine2_workspace.repo_loader().load_at_head().unwrap();
|
||||
let mut machine2_tx = machine2_repo.start_transaction();
|
||||
let child2 = create_random_commit(machine2_tx.repo_mut(), &settings)
|
||||
let child2 = create_random_commit(machine2_tx.repo_mut())
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -169,10 +163,7 @@ fn test_bad_locking_children(backend: TestRepoBackend) {
|
|||
&default_working_copy_factories(),
|
||||
)
|
||||
.unwrap();
|
||||
let merged_repo = merged_workspace
|
||||
.repo_loader()
|
||||
.load_at_head(&settings)
|
||||
.unwrap();
|
||||
let merged_repo = merged_workspace.repo_loader().load_at_head().unwrap();
|
||||
assert!(merged_repo.view().heads().contains(child1.id()));
|
||||
assert!(merged_repo.view().heads().contains(child2.id()));
|
||||
let op_id = merged_repo.op_id().clone();
|
||||
|
@ -192,7 +183,7 @@ fn test_bad_locking_interrupted(backend: TestRepoBackend) {
|
|||
let repo = &test_workspace.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let initial = create_random_commit(tx.repo_mut(), &settings)
|
||||
let initial = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![repo.store().root_commit_id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -206,7 +197,7 @@ fn test_bad_locking_interrupted(backend: TestRepoBackend) {
|
|||
let backup_path = test_workspace.root_dir().join("backup");
|
||||
copy_directory(&op_heads_dir, &backup_path);
|
||||
let mut tx = repo.start_transaction();
|
||||
create_random_commit(tx.repo_mut(), &settings)
|
||||
create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
|
|
@ -64,7 +64,6 @@ fn to_owned_path_vec(paths: &[&RepoPath]) -> Vec<RepoPathBuf> {
|
|||
#[test_case(TestRepoBackend::Local ; "local backend")]
|
||||
#[test_case(TestRepoBackend::Git ; "git backend")]
|
||||
fn test_initial(backend: TestRepoBackend) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(backend);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
@ -99,7 +98,7 @@ fn test_initial(backend: TestRepoBackend) {
|
|||
let change_id = ChangeId::new(vec![100u8; 16]);
|
||||
let builder = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![store.root_commit_id().clone()], tree.id())
|
||||
.new_commit(vec![store.root_commit_id().clone()], tree.id())
|
||||
.set_change_id(change_id.clone())
|
||||
.set_description("description")
|
||||
.set_author(author_signature.clone())
|
||||
|
@ -150,11 +149,7 @@ fn test_rewrite(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
let initial_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![store.root_commit_id().clone()],
|
||||
initial_tree.id(),
|
||||
)
|
||||
.new_commit(vec![store.root_commit_id().clone()], initial_tree.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
@ -185,11 +180,11 @@ fn test_rewrite(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
let rewritten_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&rewrite_settings, &initial_commit)
|
||||
.rewrite_commit(&initial_commit)
|
||||
.set_tree_id(rewritten_tree.id().clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
tx.commit("test").unwrap();
|
||||
let parents: Vec<_> = rewritten_commit.parents().try_collect().unwrap();
|
||||
assert_eq!(parents, vec![store.root_commit()]);
|
||||
|
@ -234,7 +229,6 @@ fn test_rewrite_update_missing_user(backend: TestRepoBackend) {
|
|||
let initial_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&missing_user_settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -263,7 +257,7 @@ fn test_rewrite_update_missing_user(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
let rewritten_commit = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &initial_commit)
|
||||
.rewrite_commit(&initial_commit)
|
||||
.write()
|
||||
.unwrap();
|
||||
|
||||
|
@ -294,7 +288,6 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) {
|
|||
let initial_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -316,11 +309,11 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
let rewritten_commit_1 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &initial_commit)
|
||||
.rewrite_commit(&initial_commit)
|
||||
.set_description("No longer discardable")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
tx.commit("test").unwrap();
|
||||
|
||||
let new_timestamp_1 =
|
||||
|
@ -340,11 +333,11 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
let rewritten_commit_2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &rewritten_commit_1)
|
||||
.rewrite_commit(&rewritten_commit_1)
|
||||
.set_description("New description")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
tx.commit("test").unwrap();
|
||||
|
||||
let new_timestamp_2 =
|
||||
|
@ -358,13 +351,12 @@ fn test_rewrite_resets_author_timestamp(backend: TestRepoBackend) {
|
|||
#[test_case(TestRepoBackend::Local ; "local backend")]
|
||||
// #[test_case(TestRepoBackend::Git ; "git backend")]
|
||||
fn test_commit_builder_descendants(backend: TestRepoBackend) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(backend);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store().clone();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
@ -374,7 +366,6 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![store.root_commit_id().clone()],
|
||||
store.empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -382,20 +373,16 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) {
|
|||
.unwrap();
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 0);
|
||||
|
||||
// Test with for_rewrite_from()
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit4 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit2)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit4 = tx.repo_mut().rewrite_commit(&commit2).write().unwrap();
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit3, &[commit4.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -403,13 +390,13 @@ fn test_commit_builder_descendants(backend: TestRepoBackend) {
|
|||
// Test with for_rewrite_from() but new change id
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut()
|
||||
.rewrite_commit(&settings, &commit2)
|
||||
.rewrite_commit(&commit2)
|
||||
.generate_new_change_id()
|
||||
.write()
|
||||
.unwrap();
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert!(rebase_map.is_empty());
|
||||
}
|
||||
|
|
|
@ -54,16 +54,15 @@ fn test_commit_parallel(backend: TestRepoBackend) {
|
|||
let num_threads = max(num_cpus::get(), 4);
|
||||
thread::scope(|s| {
|
||||
for _ in 0..num_threads {
|
||||
let settings = settings.clone();
|
||||
let repo = repo.clone();
|
||||
s.spawn(move || {
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
tx.commit("test").unwrap();
|
||||
});
|
||||
}
|
||||
});
|
||||
let repo = repo.reload_at_head(&settings).unwrap();
|
||||
let repo = repo.reload_at_head().unwrap();
|
||||
// One commit per thread plus the commit from the initial working-copy on top of
|
||||
// the root commit
|
||||
assert_eq!(repo.view().heads().len(), num_threads + 1);
|
||||
|
@ -89,7 +88,7 @@ fn test_commit_parallel_instances(backend: TestRepoBackend) {
|
|||
let repo = test_env.load_repo_at_head(&settings, test_workspace.repo_path());
|
||||
s.spawn(move || {
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
tx.commit("test").unwrap();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ fn missing(commit: &Commit) -> GraphEdge<CommitId> {
|
|||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_linearized(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -68,7 +67,7 @@ fn test_graph_iterator_linearized(skip_transitive_edges: bool) {
|
|||
// |
|
||||
// root
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -91,7 +90,6 @@ fn test_graph_iterator_linearized(skip_transitive_edges: bool) {
|
|||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -106,7 +104,7 @@ fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) {
|
|||
// \|/ ~ ~ ~
|
||||
// root
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.initial_commit();
|
||||
let commit_c = graph_builder.initial_commit();
|
||||
|
@ -142,7 +140,6 @@ fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) {
|
|||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -158,7 +155,7 @@ fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) {
|
|||
// |
|
||||
// root
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -184,7 +181,6 @@ fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) {
|
|||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -198,7 +194,7 @@ fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) {
|
|||
// \|/
|
||||
// root
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.initial_commit();
|
||||
let commit_c = graph_builder.initial_commit();
|
||||
|
@ -226,7 +222,6 @@ fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) {
|
|||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -243,7 +238,7 @@ fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) {
|
|||
// |
|
||||
// root
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.initial_commit();
|
||||
let commit_c = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
|
@ -273,7 +268,6 @@ fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) {
|
|||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -294,7 +288,7 @@ fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) {
|
|||
// |
|
||||
// root
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
|
|
@ -112,7 +112,6 @@ fn get_git_repo(repo: &Arc<ReadonlyRepo>) -> git2::Repository {
|
|||
|
||||
#[test]
|
||||
fn test_import_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: true,
|
||||
..Default::default()
|
||||
|
@ -137,7 +136,7 @@ fn test_import_refs() {
|
|||
let mut tx = repo.start_transaction();
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
let stats = git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -238,7 +237,6 @@ fn test_import_refs() {
|
|||
|
||||
#[test]
|
||||
fn test_import_refs_reimport() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: true,
|
||||
..Default::default()
|
||||
|
@ -259,7 +257,7 @@ fn test_import_refs_reimport() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let stats = git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
assert!(stats.abandoned_commits.is_empty());
|
||||
|
@ -277,7 +275,7 @@ fn test_import_refs_reimport() {
|
|||
|
||||
// Also modify feature2 on the jj side
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit6 = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit6 = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![jj_id(&commit2)])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -287,7 +285,7 @@ fn test_import_refs_reimport() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let stats = git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
|
@ -354,7 +352,6 @@ fn test_import_refs_reimport() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport_head_removed() {
|
||||
// Test that re-importing refs doesn't cause a deleted head to come back
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -363,7 +360,7 @@ fn test_import_refs_reimport_head_removed() {
|
|||
let commit = empty_git_commit(&git_repo, "refs/heads/main", &[]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let commit_id = jj_id(&commit);
|
||||
// Test the setup
|
||||
assert!(tx.repo_mut().view().heads().contains(&commit_id));
|
||||
|
@ -371,7 +368,7 @@ fn test_import_refs_reimport_head_removed() {
|
|||
// Remove the head and re-import
|
||||
tx.repo_mut().remove_head(&commit_id);
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(!tx.repo_mut().view().heads().contains(&commit_id));
|
||||
}
|
||||
|
||||
|
@ -379,7 +376,6 @@ fn test_import_refs_reimport_head_removed() {
|
|||
fn test_import_refs_reimport_git_head_does_not_count() {
|
||||
// Test that if a bookmark is removed, the corresponding commit is abandoned
|
||||
// no matter if the Git HEAD points to the commit (or a descendant of it.)
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -391,7 +387,7 @@ fn test_import_refs_reimport_git_head_does_not_count() {
|
|||
let mut tx = repo.start_transaction();
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
// Delete the bookmark and re-import. The commit should still be there since
|
||||
// HEAD points to it
|
||||
|
@ -402,14 +398,13 @@ fn test_import_refs_reimport_git_head_does_not_count() {
|
|||
.unwrap();
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(!tx.repo_mut().view().heads().contains(&jj_id(&commit)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_git_head_without_ref() {
|
||||
// Simulate external `git checkout` in colocated repo, from anonymous bookmark.
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -417,14 +412,14 @@ fn test_import_refs_reimport_git_head_without_ref() {
|
|||
|
||||
// First, HEAD points to commit1.
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit1 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit2 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit1 = write_random_commit(tx.repo_mut());
|
||||
let commit2 = write_random_commit(tx.repo_mut());
|
||||
git_repo.set_head_detached(git_id(&commit1)).unwrap();
|
||||
|
||||
// Import HEAD.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
|
||||
|
@ -437,7 +432,7 @@ fn test_import_refs_reimport_git_head_without_ref() {
|
|||
// but it should be safer than abandoning old checkout branch.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
}
|
||||
|
@ -445,7 +440,6 @@ fn test_import_refs_reimport_git_head_without_ref() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport_git_head_with_moved_ref() {
|
||||
// Simulate external history rewriting in colocated repo.
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -453,8 +447,8 @@ fn test_import_refs_reimport_git_head_with_moved_ref() {
|
|||
|
||||
// First, both HEAD and main point to commit1.
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit1 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit2 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit1 = write_random_commit(tx.repo_mut());
|
||||
let commit2 = write_random_commit(tx.repo_mut());
|
||||
git_repo
|
||||
.reference("refs/heads/main", git_id(&commit1), true, "test")
|
||||
.unwrap();
|
||||
|
@ -463,7 +457,7 @@ fn test_import_refs_reimport_git_head_with_moved_ref() {
|
|||
// Import HEAD and main.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
|
||||
|
@ -476,20 +470,19 @@ fn test_import_refs_reimport_git_head_with_moved_ref() {
|
|||
// Reimport HEAD and main, which abandons the old main branch.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(!tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
// Reimport HEAD and main, which abandons the old main bookmark.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(!tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_with_deleted_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: true,
|
||||
..Default::default()
|
||||
|
@ -518,7 +511,7 @@ fn test_import_refs_reimport_with_deleted_remote_ref() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let expected_heads = hashset! {
|
||||
|
@ -574,7 +567,7 @@ fn test_import_refs_reimport_with_deleted_remote_ref() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let view = repo.view();
|
||||
|
@ -611,7 +604,6 @@ fn test_import_refs_reimport_with_deleted_remote_ref() {
|
|||
/// moved sideways instead of being deleted.
|
||||
#[test]
|
||||
fn test_import_refs_reimport_with_moved_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: true,
|
||||
..Default::default()
|
||||
|
@ -640,7 +632,7 @@ fn test_import_refs_reimport_with_moved_remote_ref() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let expected_heads = hashset! {
|
||||
|
@ -706,7 +698,7 @@ fn test_import_refs_reimport_with_moved_remote_ref() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let view = repo.view();
|
||||
|
@ -758,7 +750,6 @@ fn test_import_refs_reimport_with_moved_remote_ref() {
|
|||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_with_moved_untracked_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: false,
|
||||
..Default::default()
|
||||
|
@ -773,7 +764,7 @@ fn test_import_refs_reimport_with_moved_untracked_remote_ref() {
|
|||
let commit_remote_t0 = empty_git_commit(&git_repo, remote_ref_name, &[&commit_base]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -793,7 +784,7 @@ fn test_import_refs_reimport_with_moved_untracked_remote_ref() {
|
|||
let commit_remote_t1 = empty_git_commit(&git_repo, remote_ref_name, &[&commit_base]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -813,7 +804,6 @@ fn test_import_refs_reimport_with_moved_untracked_remote_ref() {
|
|||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_with_deleted_untracked_intermediate_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: false,
|
||||
..Default::default()
|
||||
|
@ -831,7 +821,7 @@ fn test_import_refs_reimport_with_deleted_untracked_intermediate_remote_ref() {
|
|||
let commit_remote_b = empty_git_commit(&git_repo, remote_ref_name_b, &[&commit_remote_a]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -857,7 +847,7 @@ fn test_import_refs_reimport_with_deleted_untracked_intermediate_remote_ref() {
|
|||
delete_git_ref(&git_repo, remote_ref_name_a);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -878,7 +868,6 @@ fn test_import_refs_reimport_with_deleted_untracked_intermediate_remote_ref() {
|
|||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_with_deleted_abandoned_untracked_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: false,
|
||||
..Default::default()
|
||||
|
@ -896,7 +885,7 @@ fn test_import_refs_reimport_with_deleted_abandoned_untracked_remote_ref() {
|
|||
let commit_remote_b = empty_git_commit(&git_repo, remote_ref_name_b, &[&commit_remote_a]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -924,7 +913,7 @@ fn test_import_refs_reimport_with_deleted_abandoned_untracked_remote_ref() {
|
|||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut()
|
||||
.record_abandoned_commit(jj_id(&commit_remote_b));
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
assert_eq!(*view.heads(), hashset! { jj_id(&commit_remote_a) });
|
||||
|
@ -935,7 +924,7 @@ fn test_import_refs_reimport_with_deleted_abandoned_untracked_remote_ref() {
|
|||
delete_git_ref(&git_repo, remote_ref_name_a);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let view = repo.view();
|
||||
|
||||
|
@ -959,7 +948,6 @@ fn test_import_refs_reimport_with_deleted_abandoned_untracked_remote_ref() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport_git_head_with_fixed_ref() {
|
||||
// Simulate external `git checkout` in colocated repo, from named bookmark.
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -967,8 +955,8 @@ fn test_import_refs_reimport_git_head_with_fixed_ref() {
|
|||
|
||||
// First, both HEAD and main point to commit1.
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit1 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit2 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit1 = write_random_commit(tx.repo_mut());
|
||||
let commit2 = write_random_commit(tx.repo_mut());
|
||||
git_repo
|
||||
.reference("refs/heads/main", git_id(&commit1), true, "test")
|
||||
.unwrap();
|
||||
|
@ -977,7 +965,7 @@ fn test_import_refs_reimport_git_head_with_fixed_ref() {
|
|||
// Import HEAD and main.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
|
||||
|
@ -987,7 +975,7 @@ fn test_import_refs_reimport_git_head_with_fixed_ref() {
|
|||
// Reimport HEAD, which shouldn't abandon the old HEAD branch.
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(tx.repo_mut().view().heads().contains(commit1.id()));
|
||||
assert!(tx.repo_mut().view().heads().contains(commit2.id()));
|
||||
}
|
||||
|
@ -996,7 +984,6 @@ fn test_import_refs_reimport_git_head_with_fixed_ref() {
|
|||
fn test_import_refs_reimport_all_from_root_removed() {
|
||||
// Test that if a chain of commits all the way from the root gets unreferenced,
|
||||
// we abandon the whole stack, but not including the root commit.
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -1005,7 +992,7 @@ fn test_import_refs_reimport_all_from_root_removed() {
|
|||
let commit = empty_git_commit(&git_repo, "refs/heads/main", &[]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
// Test the setup
|
||||
assert!(tx.repo_mut().view().heads().contains(&jj_id(&commit)));
|
||||
|
||||
|
@ -1016,14 +1003,13 @@ fn test_import_refs_reimport_all_from_root_removed() {
|
|||
.delete()
|
||||
.unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(!tx.repo_mut().view().heads().contains(&jj_id(&commit)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_abandoning_disabled() {
|
||||
// Test that we don't abandoned unreachable commits if configured not to
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
abandon_unreachable_commits: false,
|
||||
..Default::default()
|
||||
|
@ -1036,7 +1022,7 @@ fn test_import_refs_reimport_abandoning_disabled() {
|
|||
let commit2 = empty_git_commit(&git_repo, "refs/heads/delete-me", &[&commit1]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
// Test the setup
|
||||
assert!(tx.repo_mut().view().heads().contains(&jj_id(&commit2)));
|
||||
|
||||
|
@ -1047,13 +1033,12 @@ fn test_import_refs_reimport_abandoning_disabled() {
|
|||
.delete()
|
||||
.unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert!(tx.repo_mut().view().heads().contains(&jj_id(&commit2)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_import_refs_reimport_conflicted_remote_bookmark() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: true,
|
||||
..Default::default()
|
||||
|
@ -1073,7 +1058,7 @@ fn test_import_refs_reimport_conflicted_remote_bookmark() {
|
|||
git::import_refs(tx2.repo_mut(), &git_settings).unwrap();
|
||||
|
||||
// Remote bookmark can diverge by divergent operations (like `jj git fetch`)
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
assert_eq!(
|
||||
repo.view().get_git_ref("refs/remotes/origin/main"),
|
||||
&RefTarget::from_legacy_form([], [jj_id(&commit1), jj_id(&commit2)]),
|
||||
|
@ -1119,7 +1104,6 @@ fn test_import_refs_reserved_remote_name() {
|
|||
|
||||
#[test]
|
||||
fn test_import_some_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_bookmark: true,
|
||||
..Default::default()
|
||||
|
@ -1155,7 +1139,7 @@ fn test_import_some_refs() {
|
|||
.unwrap_or(false)
|
||||
})
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// There are two heads, feature2 and feature4.
|
||||
|
@ -1236,7 +1220,7 @@ fn test_import_some_refs() {
|
|||
get_remote_bookmark(ref_name) == Some("feature2")
|
||||
})
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// feature2 and feature4 will still be heads, and all four bookmarks should be
|
||||
|
@ -1253,7 +1237,7 @@ fn test_import_some_refs() {
|
|||
})
|
||||
.unwrap();
|
||||
// No descendant should be rewritten.
|
||||
assert_eq!(tx.repo_mut().rebase_descendants(&settings).unwrap(), 0);
|
||||
assert_eq!(tx.repo_mut().rebase_descendants().unwrap(), 0);
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// feature2 and feature4 should still be the heads, and all three bookmarks
|
||||
|
@ -1270,7 +1254,7 @@ fn test_import_some_refs() {
|
|||
})
|
||||
.unwrap();
|
||||
// No descendant should be rewritten
|
||||
assert_eq!(tx.repo_mut().rebase_descendants(&settings).unwrap(), 0);
|
||||
assert_eq!(tx.repo_mut().rebase_descendants().unwrap(), 0);
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// feature2 and feature4 should still be the heads, and both bookmarks
|
||||
|
@ -1286,7 +1270,7 @@ fn test_import_some_refs() {
|
|||
})
|
||||
.unwrap();
|
||||
// No descendant should be rewritten
|
||||
assert_eq!(tx.repo_mut().rebase_descendants(&settings).unwrap(), 0);
|
||||
assert_eq!(tx.repo_mut().rebase_descendants().unwrap(), 0);
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// feature2 should now be the only head and only bookmark.
|
||||
|
@ -1307,7 +1291,6 @@ fn delete_git_ref(git_repo: &git2::Repository, name: &str) {
|
|||
}
|
||||
|
||||
struct GitRepoData {
|
||||
settings: UserSettings,
|
||||
_temp_dir: TempDir,
|
||||
origin_repo: git2::Repository,
|
||||
git_repo: git2::Repository,
|
||||
|
@ -1343,7 +1326,6 @@ impl GitRepoData {
|
|||
)
|
||||
.unwrap();
|
||||
Self {
|
||||
settings,
|
||||
_temp_dir: temp_dir,
|
||||
origin_repo,
|
||||
git_repo,
|
||||
|
@ -1359,9 +1341,7 @@ fn test_import_refs_empty_git_repo() {
|
|||
let heads_before = test_data.repo.view().heads().clone();
|
||||
let mut tx = test_data.repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut()
|
||||
.rebase_descendants(&test_data.settings)
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
assert_eq!(*repo.view().heads(), heads_before);
|
||||
assert_eq!(repo.view().bookmarks().count(), 0);
|
||||
|
@ -1461,9 +1441,7 @@ fn test_import_refs_detached_head() {
|
|||
let mut tx = test_data.repo.start_transaction();
|
||||
git::import_head(tx.repo_mut()).unwrap();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut()
|
||||
.rebase_descendants(&test_data.settings)
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let expected_heads = hashset! { jj_id(&commit1) };
|
||||
|
@ -1485,7 +1463,7 @@ fn test_export_refs_no_detach() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
git::import_head(mut_repo).unwrap();
|
||||
git::import_refs(mut_repo, &git_settings).unwrap();
|
||||
mut_repo.rebase_descendants(&test_data.settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
|
||||
// Do an initial export to make sure `main` is considered
|
||||
assert!(git::export_refs(mut_repo).unwrap().is_empty());
|
||||
|
@ -1516,10 +1494,10 @@ fn test_export_refs_bookmark_changed() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
git::import_head(mut_repo).unwrap();
|
||||
git::import_refs(mut_repo, &git_settings).unwrap();
|
||||
mut_repo.rebase_descendants(&test_data.settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(git::export_refs(mut_repo).unwrap().is_empty());
|
||||
|
||||
let new_commit = create_random_commit(mut_repo, &test_data.settings)
|
||||
let new_commit = create_random_commit(mut_repo)
|
||||
.set_parents(vec![jj_id(&commit)])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1555,10 +1533,10 @@ fn test_export_refs_current_bookmark_changed() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
git::import_head(mut_repo).unwrap();
|
||||
git::import_refs(mut_repo, &git_settings).unwrap();
|
||||
mut_repo.rebase_descendants(&test_data.settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(git::export_refs(mut_repo).unwrap().is_empty());
|
||||
|
||||
let new_commit = create_random_commit(mut_repo, &test_data.settings)
|
||||
let new_commit = create_random_commit(mut_repo)
|
||||
.set_parents(vec![jj_id(&commit1)])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1592,11 +1570,11 @@ fn test_export_refs_unborn_git_bookmark(move_placeholder_ref: bool) {
|
|||
let mut_repo = tx.repo_mut();
|
||||
git::import_head(mut_repo).unwrap();
|
||||
git::import_refs(mut_repo, &git_settings).unwrap();
|
||||
mut_repo.rebase_descendants(&test_data.settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(git::export_refs(mut_repo).unwrap().is_empty());
|
||||
assert!(git_repo.head().is_err(), "HEAD is unborn");
|
||||
|
||||
let new_commit = write_random_commit(mut_repo, &test_data.settings);
|
||||
let new_commit = write_random_commit(mut_repo);
|
||||
mut_repo.set_local_bookmark_target("main", RefTarget::normal(new_commit.id().clone()));
|
||||
if move_placeholder_ref {
|
||||
git_repo
|
||||
|
@ -1633,9 +1611,9 @@ fn test_export_import_sequence() {
|
|||
let git_repo = test_data.git_repo;
|
||||
let mut tx = test_data.repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit_a = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_b = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_c = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_a = write_random_commit(mut_repo);
|
||||
let commit_b = write_random_commit(mut_repo);
|
||||
let commit_c = write_random_commit(mut_repo);
|
||||
|
||||
// Import the bookmark pointing to A
|
||||
git_repo
|
||||
|
@ -1770,9 +1748,9 @@ fn test_export_conflicts() {
|
|||
let git_repo = test_data.git_repo;
|
||||
let mut tx = test_data.repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit_a = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_b = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_c = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_a = write_random_commit(mut_repo);
|
||||
let commit_b = write_random_commit(mut_repo);
|
||||
let commit_c = write_random_commit(mut_repo);
|
||||
mut_repo.set_local_bookmark_target("main", RefTarget::normal(commit_a.id().clone()));
|
||||
mut_repo.set_local_bookmark_target("feature", RefTarget::normal(commit_a.id().clone()));
|
||||
assert!(git::export_refs(mut_repo).unwrap().is_empty());
|
||||
|
@ -1845,7 +1823,7 @@ fn test_export_partial_failure() {
|
|||
let git_repo = test_data.git_repo;
|
||||
let mut tx = test_data.repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit_a = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_a = write_random_commit(mut_repo);
|
||||
let target = RefTarget::normal(commit_a.id().clone());
|
||||
// Empty string is disallowed by Git
|
||||
mut_repo.set_local_bookmark_target("", target.clone());
|
||||
|
@ -1930,9 +1908,9 @@ fn test_export_reexport_transitions() {
|
|||
let git_repo = test_data.git_repo;
|
||||
let mut tx = test_data.repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit_a = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_b = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_c = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_a = write_random_commit(mut_repo);
|
||||
let commit_b = write_random_commit(mut_repo);
|
||||
let commit_c = write_random_commit(mut_repo);
|
||||
// Create a few bookmarks whose names indicate how they change in jj in git. The
|
||||
// first letter represents the bookmark's target in the last export. The second
|
||||
// letter represents the bookmark's target in jj. The third letter represents
|
||||
|
@ -2085,7 +2063,7 @@ fn test_export_undo_reexport() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
|
||||
// Initial export
|
||||
let commit_a = write_random_commit(mut_repo, &test_data.settings);
|
||||
let commit_a = write_random_commit(mut_repo);
|
||||
let target_a = RefTarget::normal(commit_a.id().clone());
|
||||
mut_repo.set_local_bookmark_target("main", target_a.clone());
|
||||
assert!(git::export_refs(mut_repo).unwrap().is_empty());
|
||||
|
@ -2138,11 +2116,11 @@ fn test_reset_head_to_root() {
|
|||
let root_commit_id = repo.store().root_commit_id();
|
||||
let tree_id = repo.store().empty_merged_tree_id();
|
||||
let commit1 = mut_repo
|
||||
.new_commit(&settings, vec![root_commit_id.clone()], tree_id.clone())
|
||||
.new_commit(vec![root_commit_id.clone()], tree_id.clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit2 = mut_repo
|
||||
.new_commit(&settings, vec![commit1.id().clone()], tree_id.clone())
|
||||
.new_commit(vec![commit1.id().clone()], tree_id.clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
|
||||
|
@ -2196,11 +2174,11 @@ fn test_reset_head_with_index() {
|
|||
let root_commit_id = repo.store().root_commit_id();
|
||||
let tree_id = repo.store().empty_merged_tree_id();
|
||||
let commit1 = mut_repo
|
||||
.new_commit(&settings, vec![root_commit_id.clone()], tree_id.clone())
|
||||
.new_commit(vec![root_commit_id.clone()], tree_id.clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit2 = mut_repo
|
||||
.new_commit(&settings, vec![commit1.id().clone()], tree_id.clone())
|
||||
.new_commit(vec![commit1.id().clone()], tree_id.clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
|
||||
|
@ -2655,8 +2633,8 @@ fn set_up_push_repos(settings: &UserSettings, temp_dir: &TempDir) -> PushTestSet
|
|||
.get_commit(&jj_id(&parent_of_initial_git_commit))
|
||||
.unwrap();
|
||||
let mut tx = jj_repo.start_transaction();
|
||||
let sideways_commit = write_random_commit(tx.repo_mut(), settings);
|
||||
let child_of_main_commit = create_random_commit(tx.repo_mut(), settings)
|
||||
let sideways_commit = write_random_commit(tx.repo_mut());
|
||||
let child_of_main_commit = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![main_commit.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -3156,7 +3134,6 @@ fn test_push_updates_invalid_remote() {
|
|||
|
||||
#[test]
|
||||
fn test_bulk_update_extra_on_import_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -3173,7 +3150,7 @@ fn test_bulk_update_extra_on_import_refs() {
|
|||
let import_refs = |repo: &Arc<ReadonlyRepo>| {
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
tx.commit("test").unwrap()
|
||||
};
|
||||
|
||||
|
@ -3202,7 +3179,6 @@ fn test_bulk_update_extra_on_import_refs() {
|
|||
|
||||
#[test]
|
||||
fn test_rewrite_imported_commit() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
@ -3212,7 +3188,7 @@ fn test_rewrite_imported_commit() {
|
|||
let git_commit = empty_git_commit(&git_repo, "refs/heads/main", &[]);
|
||||
let mut tx = repo.start_transaction();
|
||||
git::import_refs(tx.repo_mut(), &git_settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let imported_commit = repo.store().get_commit(&jj_id(&git_commit)).unwrap();
|
||||
|
||||
|
@ -3221,7 +3197,6 @@ fn test_rewrite_imported_commit() {
|
|||
let authored_commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
imported_commit.parent_ids().to_vec(),
|
||||
imported_commit.tree_id().clone(),
|
||||
)
|
||||
|
@ -3271,7 +3246,7 @@ fn test_concurrent_write_commit() {
|
|||
s.spawn(move || {
|
||||
barrier.wait();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = create_rooted_commit(tx.repo_mut(), settings)
|
||||
let commit = create_rooted_commit(tx.repo_mut())
|
||||
.set_description("racy commit")
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -3296,7 +3271,7 @@ fn test_concurrent_write_commit() {
|
|||
assert_eq!(commit_change_ids.len(), num_thread);
|
||||
|
||||
// All unique commits should be preserved.
|
||||
let repo = repo.reload_at_head(settings).unwrap();
|
||||
let repo = repo.reload_at_head().unwrap();
|
||||
for (commit_id, change_ids) in &commit_change_ids {
|
||||
let commit = repo.store().get_commit(commit_id).unwrap();
|
||||
assert_eq!(commit.id(), commit_id);
|
||||
|
@ -3357,7 +3332,7 @@ fn test_concurrent_read_write_commit() {
|
|||
s.spawn(move || {
|
||||
barrier.wait();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = create_rooted_commit(tx.repo_mut(), settings)
|
||||
let commit = create_rooted_commit(tx.repo_mut())
|
||||
.set_description(format!("commit {i}"))
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -3380,7 +3355,7 @@ fn test_concurrent_read_write_commit() {
|
|||
if pending_commit_ids.is_empty() {
|
||||
break;
|
||||
}
|
||||
repo = repo.reload_at_head(settings).unwrap();
|
||||
repo = repo.reload_at_head().unwrap();
|
||||
let git_backend = get_git_backend(&repo);
|
||||
let mut tx = repo.start_transaction();
|
||||
pending_commit_ids = pending_commit_ids
|
||||
|
@ -3427,7 +3402,7 @@ fn test_concurrent_read_write_commit() {
|
|||
});
|
||||
|
||||
// The index should be consistent with the store.
|
||||
let repo = repo.reload_at_head(settings).unwrap();
|
||||
let repo = repo.reload_at_head().unwrap();
|
||||
for commit_id in &commit_ids {
|
||||
assert!(repo.index().has_id(commit_id));
|
||||
let commit = repo.store().get_commit(commit_id).unwrap();
|
||||
|
@ -3438,10 +3413,7 @@ fn test_concurrent_read_write_commit() {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_rooted_commit<'repo>(
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
settings: &UserSettings,
|
||||
) -> CommitBuilder<'repo> {
|
||||
fn create_rooted_commit(mut_repo: &mut MutableRepo) -> CommitBuilder<'_> {
|
||||
let signature = Signature {
|
||||
name: "Test User".to_owned(),
|
||||
email: "test.user@example.com".to_owned(),
|
||||
|
@ -3453,7 +3425,6 @@ fn create_rooted_commit<'repo>(
|
|||
};
|
||||
mut_repo
|
||||
.new_commit(
|
||||
settings,
|
||||
vec![mut_repo.store().root_commit_id().clone()],
|
||||
mut_repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
|
|
@ -29,7 +29,6 @@ use jj_lib::repo::ReadonlyRepo;
|
|||
use jj_lib::repo::Repo;
|
||||
use jj_lib::repo_path::RepoPath;
|
||||
use jj_lib::repo_path::RepoPathBuf;
|
||||
use jj_lib::settings::UserSettings;
|
||||
use jj_lib::store::Store;
|
||||
use jj_lib::transaction::Transaction;
|
||||
use maplit::hashset;
|
||||
|
@ -77,13 +76,12 @@ fn get_copy_records(
|
|||
|
||||
fn make_commit(
|
||||
tx: &mut Transaction,
|
||||
settings: &UserSettings,
|
||||
parents: Vec<CommitId>,
|
||||
content: &[(&RepoPath, &str)],
|
||||
) -> Commit {
|
||||
let tree = create_tree(tx.base_repo(), content);
|
||||
tx.repo_mut()
|
||||
.new_commit(settings, parents, tree.id())
|
||||
.new_commit(parents, tree.id())
|
||||
.write()
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -96,7 +94,6 @@ fn test_gc() {
|
|||
return;
|
||||
}
|
||||
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = test_repo.repo;
|
||||
let git_repo_path = get_git_backend(&repo).git_repo_path();
|
||||
|
@ -115,7 +112,7 @@ fn test_gc() {
|
|||
// B
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -123,7 +120,7 @@ fn test_gc() {
|
|||
let commit_e = graph_builder.commit_with_parents(&[&commit_b]);
|
||||
let commit_f = graph_builder.commit_with_parents(&[&commit_b]);
|
||||
let commit_g = graph_builder.commit_with_parents(&[&commit_e, &commit_f]);
|
||||
let commit_h = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_h = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_f.id().clone()])
|
||||
.set_predecessors(vec![commit_d.id().clone()])
|
||||
.write()
|
||||
|
@ -239,7 +236,6 @@ fn test_gc() {
|
|||
|
||||
#[test]
|
||||
fn test_copy_detection() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -252,19 +248,16 @@ fn test_copy_detection() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let commit_a = make_commit(
|
||||
&mut tx,
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
&[(&paths[0], "content")],
|
||||
);
|
||||
let commit_b = make_commit(
|
||||
&mut tx,
|
||||
&settings,
|
||||
vec![commit_a.id().clone()],
|
||||
&[(&paths[1], "content")],
|
||||
);
|
||||
let commit_c = make_commit(
|
||||
&mut tx,
|
||||
&settings,
|
||||
vec![commit_b.id().clone()],
|
||||
&[(&paths[2], "content")],
|
||||
);
|
||||
|
|
|
@ -31,7 +31,6 @@ use testutils::TestRepoBackend;
|
|||
|
||||
#[test]
|
||||
fn test_id_prefix() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
let root_commit_id = repo.store().root_commit_id();
|
||||
|
@ -48,11 +47,7 @@ fn test_id_prefix() {
|
|||
},
|
||||
};
|
||||
tx.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![parent_id.clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
.new_commit(vec![parent_id.clone()], repo.store().empty_merged_tree_id())
|
||||
.set_author(signature.clone())
|
||||
.set_committer(signature)
|
||||
.write()
|
||||
|
@ -259,7 +254,6 @@ fn test_id_prefix() {
|
|||
|
||||
#[test]
|
||||
fn test_id_prefix_divergent() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
let root_commit_id = repo.store().root_commit_id();
|
||||
|
@ -276,11 +270,7 @@ fn test_id_prefix_divergent() {
|
|||
},
|
||||
};
|
||||
tx.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![parent_id.clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
.new_commit(vec![parent_id.clone()], repo.store().empty_merged_tree_id())
|
||||
.set_description(description)
|
||||
.set_author(signature.clone())
|
||||
.set_committer(signature)
|
||||
|
@ -398,7 +388,6 @@ fn test_id_prefix_divergent() {
|
|||
|
||||
#[test]
|
||||
fn test_id_prefix_hidden() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
let root_commit_id = repo.store().root_commit_id();
|
||||
|
@ -417,7 +406,6 @@ fn test_id_prefix_hidden() {
|
|||
let commit = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![root_commit_id.clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -469,7 +457,7 @@ fn test_id_prefix_hidden() {
|
|||
let hidden_commit = &commits[8];
|
||||
tx.repo_mut()
|
||||
.record_abandoned_commit(hidden_commit.id().clone());
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let prefix = |x: &str| HexPrefix::new(x).unwrap();
|
||||
|
|
|
@ -38,7 +38,6 @@ use jj_lib::repo::ReadonlyRepo;
|
|||
use jj_lib::repo::Repo;
|
||||
use jj_lib::revset::ResolvedExpression;
|
||||
use jj_lib::revset::GENERATION_RANGE_FULL;
|
||||
use jj_lib::settings::UserSettings;
|
||||
use maplit::hashset;
|
||||
use testutils::commit_transactions;
|
||||
use testutils::create_random_commit;
|
||||
|
@ -47,12 +46,8 @@ use testutils::write_random_commit;
|
|||
use testutils::CommitGraphBuilder;
|
||||
use testutils::TestRepo;
|
||||
|
||||
fn child_commit<'repo>(
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
settings: &UserSettings,
|
||||
commit: &Commit,
|
||||
) -> CommitBuilder<'repo> {
|
||||
create_random_commit(mut_repo, settings).set_parents(vec![commit.id().clone()])
|
||||
fn child_commit<'repo>(mut_repo: &'repo mut MutableRepo, commit: &Commit) -> CommitBuilder<'repo> {
|
||||
create_random_commit(mut_repo).set_parents(vec![commit.id().clone()])
|
||||
}
|
||||
|
||||
// Helper just to reduce line wrapping
|
||||
|
@ -75,7 +70,6 @@ fn test_index_commits_empty_repo() {
|
|||
|
||||
#[test]
|
||||
fn test_index_commits_standard_cases() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -95,7 +89,7 @@ fn test_index_commits_standard_cases() {
|
|||
|
||||
let root_commit_id = repo.store().root_commit_id();
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -142,7 +136,6 @@ fn test_index_commits_standard_cases() {
|
|||
|
||||
#[test]
|
||||
fn test_index_commits_criss_cross() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -152,7 +145,7 @@ fn test_index_commits_criss_cross() {
|
|||
// 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();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let mut left_commits = vec![graph_builder.initial_commit()];
|
||||
let mut right_commits = vec![graph_builder.initial_commit()];
|
||||
for gen in 1..num_generations {
|
||||
|
@ -307,7 +300,7 @@ fn test_index_commits_previous_operations() {
|
|||
// o root
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -350,9 +343,9 @@ fn test_index_commits_hidden_but_referenced() {
|
|||
// This can also happen if imported remote bookmarks get immediately
|
||||
// abandoned because the other bookmark has moved.
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_b = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_c = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let commit_b = write_random_commit(tx.repo_mut());
|
||||
let commit_c = write_random_commit(tx.repo_mut());
|
||||
tx.repo_mut().remove_head(commit_a.id());
|
||||
tx.repo_mut().remove_head(commit_b.id());
|
||||
tx.repo_mut().remove_head(commit_c.id());
|
||||
|
@ -404,9 +397,7 @@ fn test_index_commits_incremental() {
|
|||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = child_commit(tx.repo_mut(), &settings, &root_commit)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_a = child_commit(tx.repo_mut(), &root_commit).write().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let index = as_readonly_composite(&repo);
|
||||
|
@ -414,12 +405,8 @@ fn test_index_commits_incremental() {
|
|||
assert_eq!(index.num_commits(), 1 + 1);
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_b = child_commit(tx.repo_mut(), &settings, &commit_a)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c = child_commit(tx.repo_mut(), &settings, &commit_b)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b = child_commit(tx.repo_mut(), &commit_a).write().unwrap();
|
||||
let commit_c = child_commit(tx.repo_mut(), &commit_b).write().unwrap();
|
||||
tx.commit("test").unwrap();
|
||||
|
||||
let repo = test_env.load_repo_at_head(&settings, test_repo.repo_path());
|
||||
|
@ -456,9 +443,7 @@ fn test_index_commits_incremental_empty_transaction() {
|
|||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = child_commit(tx.repo_mut(), &settings, &root_commit)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_a = child_commit(tx.repo_mut(), &root_commit).write().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let index = as_readonly_composite(&repo);
|
||||
|
@ -486,7 +471,6 @@ fn test_index_commits_incremental_empty_transaction() {
|
|||
#[test]
|
||||
fn test_index_commits_incremental_already_indexed() {
|
||||
// Tests that trying to add a commit that's already been added is a no-op.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -498,9 +482,7 @@ fn test_index_commits_incremental_already_indexed() {
|
|||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = child_commit(tx.repo_mut(), &settings, &root_commit)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_a = child_commit(tx.repo_mut(), &root_commit).write().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
assert!(repo.index().has_id(commit_a.id()));
|
||||
|
@ -512,14 +494,10 @@ fn test_index_commits_incremental_already_indexed() {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
fn create_n_commits(
|
||||
settings: &UserSettings,
|
||||
repo: &Arc<ReadonlyRepo>,
|
||||
num_commits: i32,
|
||||
) -> Arc<ReadonlyRepo> {
|
||||
fn create_n_commits(repo: &Arc<ReadonlyRepo>, num_commits: i32) -> Arc<ReadonlyRepo> {
|
||||
let mut tx = repo.start_transaction();
|
||||
for _ in 0..num_commits {
|
||||
write_random_commit(tx.repo_mut(), settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
}
|
||||
tx.commit("test").unwrap()
|
||||
}
|
||||
|
@ -551,64 +529,62 @@ fn commits_by_level(repo: &Arc<ReadonlyRepo>) -> Vec<u32> {
|
|||
|
||||
#[test]
|
||||
fn test_index_commits_incremental_squashed() {
|
||||
let settings = testutils::user_settings();
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 1);
|
||||
let repo = create_n_commits(repo, 1);
|
||||
assert_eq!(commits_by_level(&repo), vec![2]);
|
||||
let repo = create_n_commits(&settings, &repo, 1);
|
||||
let repo = create_n_commits(&repo, 1);
|
||||
assert_eq!(commits_by_level(&repo), vec![3]);
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 2);
|
||||
let repo = create_n_commits(repo, 2);
|
||||
assert_eq!(commits_by_level(&repo), vec![3]);
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 100);
|
||||
let repo = create_n_commits(repo, 100);
|
||||
assert_eq!(commits_by_level(&repo), vec![101]);
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 1);
|
||||
let repo = create_n_commits(&settings, &repo, 2);
|
||||
let repo = create_n_commits(&settings, &repo, 4);
|
||||
let repo = create_n_commits(&settings, &repo, 8);
|
||||
let repo = create_n_commits(&settings, &repo, 16);
|
||||
let repo = create_n_commits(&settings, &repo, 32);
|
||||
let repo = create_n_commits(repo, 1);
|
||||
let repo = create_n_commits(&repo, 2);
|
||||
let repo = create_n_commits(&repo, 4);
|
||||
let repo = create_n_commits(&repo, 8);
|
||||
let repo = create_n_commits(&repo, 16);
|
||||
let repo = create_n_commits(&repo, 32);
|
||||
assert_eq!(commits_by_level(&repo), vec![64]);
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 32);
|
||||
let repo = create_n_commits(&settings, &repo, 16);
|
||||
let repo = create_n_commits(&settings, &repo, 8);
|
||||
let repo = create_n_commits(&settings, &repo, 4);
|
||||
let repo = create_n_commits(&settings, &repo, 2);
|
||||
let repo = create_n_commits(repo, 32);
|
||||
let repo = create_n_commits(&repo, 16);
|
||||
let repo = create_n_commits(&repo, 8);
|
||||
let repo = create_n_commits(&repo, 4);
|
||||
let repo = create_n_commits(&repo, 2);
|
||||
assert_eq!(commits_by_level(&repo), vec![57, 6]);
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 30);
|
||||
let repo = create_n_commits(&settings, &repo, 15);
|
||||
let repo = create_n_commits(&settings, &repo, 7);
|
||||
let repo = create_n_commits(&settings, &repo, 3);
|
||||
let repo = create_n_commits(&settings, &repo, 1);
|
||||
let repo = create_n_commits(repo, 30);
|
||||
let repo = create_n_commits(&repo, 15);
|
||||
let repo = create_n_commits(&repo, 7);
|
||||
let repo = create_n_commits(&repo, 3);
|
||||
let repo = create_n_commits(&repo, 1);
|
||||
assert_eq!(commits_by_level(&repo), vec![31, 15, 7, 3, 1]);
|
||||
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
let repo = create_n_commits(repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
let repo = create_n_commits(&repo, 10);
|
||||
assert_eq!(commits_by_level(&repo), vec![71, 20]);
|
||||
}
|
||||
|
||||
|
@ -620,7 +596,7 @@ fn test_reindex_no_segments_dir() {
|
|||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
assert!(repo.index().has_id(commit_a.id()));
|
||||
|
||||
|
@ -641,7 +617,7 @@ fn test_reindex_corrupt_segment_files() {
|
|||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
assert!(repo.index().has_id(commit_a.id()));
|
||||
|
||||
|
@ -664,7 +640,6 @@ fn test_reindex_corrupt_segment_files() {
|
|||
|
||||
#[test]
|
||||
fn test_reindex_from_merged_operation() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -679,17 +654,17 @@ fn test_reindex_from_merged_operation() {
|
|||
let mut txs = Vec::new();
|
||||
for _ in 0..2 {
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut().remove_head(commit.id());
|
||||
txs.push(tx);
|
||||
}
|
||||
let repo = commit_transactions(&settings, txs);
|
||||
let repo = commit_transactions(txs);
|
||||
let mut op_ids_to_delete = Vec::new();
|
||||
op_ids_to_delete.push(repo.op_id());
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
op_ids_to_delete.push(repo.op_id());
|
||||
let operation_to_reload = repo.operation();
|
||||
|
@ -719,7 +694,7 @@ fn test_reindex_missing_commit() {
|
|||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let missing_commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let missing_commit = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
let bad_op_id = repo.op_id();
|
||||
|
||||
|
@ -760,7 +735,6 @@ fn test_index_store_type() {
|
|||
|
||||
#[test]
|
||||
fn test_change_id_index() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -772,7 +746,6 @@ fn test_change_id_index() {
|
|||
commit_number += 1;
|
||||
tx.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![root_commit.id().clone()],
|
||||
root_commit.tree_id().clone(),
|
||||
)
|
||||
|
|
|
@ -47,7 +47,7 @@ fn test_init_local() {
|
|||
|
||||
// Just test that we can write a commit to the store
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -75,7 +75,7 @@ fn test_init_internal_git() {
|
|||
|
||||
// Just test that we can write a commit to the store
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -100,7 +100,7 @@ fn test_init_colocated_git() {
|
|||
|
||||
// Just test that we can write a commit to the store
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -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();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
}
|
||||
|
||||
#[test_case(TestRepoBackend::Local ; "local backend")]
|
||||
|
|
|
@ -23,7 +23,7 @@ fn test_load_at_operation() {
|
|||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("add commit").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
|
@ -38,7 +38,7 @@ fn test_load_at_operation() {
|
|||
&test_repo.env.default_store_factories(),
|
||||
)
|
||||
.unwrap();
|
||||
let head_repo = loader.load_at_head(&settings).unwrap();
|
||||
let head_repo = loader.load_at_head().unwrap();
|
||||
assert!(!head_repo.view().heads().contains(commit.id()));
|
||||
|
||||
// If we load the repo at the previous operation, we should see the commit since
|
||||
|
|
|
@ -42,7 +42,6 @@ use jj_lib::repo_path::RepoPath;
|
|||
use jj_lib::repo_path::RepoPathBuf;
|
||||
use jj_lib::repo_path::RepoPathComponent;
|
||||
use jj_lib::secret_backend::SecretBackend;
|
||||
use jj_lib::settings::UserSettings;
|
||||
use jj_lib::working_copy::CheckoutError;
|
||||
use jj_lib::working_copy::CheckoutOptions;
|
||||
use jj_lib::working_copy::CheckoutStats;
|
||||
|
@ -151,7 +150,6 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) {
|
|||
}
|
||||
|
||||
fn write_path(
|
||||
settings: &UserSettings,
|
||||
repo: &Arc<ReadonlyRepo>,
|
||||
tree_builder: &mut MergedTreeBuilder,
|
||||
kind: Kind,
|
||||
|
@ -242,7 +240,7 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) {
|
|||
}
|
||||
Kind::GitSubmodule => {
|
||||
let mut tx = repo.start_transaction();
|
||||
let id = write_random_commit(tx.repo_mut(), settings).id().clone();
|
||||
let id = write_random_commit(tx.repo_mut()).id().clone();
|
||||
tx.commit("test").unwrap();
|
||||
Merge::normal(TreeValue::GitSubmodule(id))
|
||||
}
|
||||
|
@ -269,8 +267,8 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) {
|
|||
for left_kind in &kinds {
|
||||
for right_kind in &kinds {
|
||||
let path = RepoPathBuf::from_internal_string(format!("{left_kind:?}_{right_kind:?}"));
|
||||
write_path(&settings, repo, &mut left_tree_builder, *left_kind, &path);
|
||||
write_path(&settings, repo, &mut right_tree_builder, *right_kind, &path);
|
||||
write_path(repo, &mut left_tree_builder, *left_kind, &path);
|
||||
write_path(repo, &mut right_tree_builder, *right_kind, &path);
|
||||
files.push((*left_kind, *right_kind, path.clone()));
|
||||
}
|
||||
}
|
||||
|
@ -1321,7 +1319,7 @@ fn test_git_submodule() {
|
|||
}),
|
||||
);
|
||||
|
||||
let submodule_id1 = write_random_commit(tx.repo_mut(), &settings).id().clone();
|
||||
let submodule_id1 = write_random_commit(tx.repo_mut()).id().clone();
|
||||
|
||||
tree_builder.set_or_remove(
|
||||
submodule_path.to_owned(),
|
||||
|
@ -1332,7 +1330,7 @@ fn test_git_submodule() {
|
|||
let commit1 = commit_with_tree(repo.store(), tree_id1.clone());
|
||||
|
||||
let mut tree_builder = MergedTreeBuilder::new(tree_id1.clone());
|
||||
let submodule_id2 = write_random_commit(tx.repo_mut(), &settings).id().clone();
|
||||
let submodule_id2 = write_random_commit(tx.repo_mut()).id().clone();
|
||||
tree_builder.set_or_remove(
|
||||
submodule_path.to_owned(),
|
||||
Merge::normal(TreeValue::GitSubmodule(submodule_id2)),
|
||||
|
|
|
@ -542,7 +542,6 @@ fn test_simplify_conflict() {
|
|||
|
||||
#[test]
|
||||
fn test_simplify_conflict_after_resolving_parent() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -563,46 +562,30 @@ fn test_simplify_conflict_after_resolving_parent() {
|
|||
let tree_a = create_tree(repo, &[(path, "abc\ndef\nghi\n")]);
|
||||
let commit_a = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
tree_a.id(),
|
||||
)
|
||||
.new_commit(vec![repo.store().root_commit_id().clone()], tree_a.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let tree_b = create_tree(repo, &[(path, "Abc\ndef\nghi\n")]);
|
||||
let commit_b = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree_b.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree_b.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let tree_c = create_tree(repo, &[(path, "Abc\ndef\nGhi\n")]);
|
||||
let commit_c = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_b.id().clone()], tree_c.id())
|
||||
.new_commit(vec![commit_b.id().clone()], tree_c.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let tree_d = create_tree(repo, &[(path, "abC\ndef\nghi\n")]);
|
||||
let commit_d = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree_d.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree_d.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
|
||||
let commit_b2 = rebase_commit(
|
||||
&settings,
|
||||
tx.repo_mut(),
|
||||
commit_b,
|
||||
vec![commit_d.id().clone()],
|
||||
)
|
||||
.unwrap();
|
||||
let commit_c2 = rebase_commit(
|
||||
&settings,
|
||||
tx.repo_mut(),
|
||||
commit_c,
|
||||
vec![commit_b2.id().clone()],
|
||||
)
|
||||
.unwrap();
|
||||
let commit_b2 = rebase_commit(tx.repo_mut(), commit_b, vec![commit_d.id().clone()]).unwrap();
|
||||
let commit_c2 = rebase_commit(tx.repo_mut(), commit_c, vec![commit_b2.id().clone()]).unwrap();
|
||||
|
||||
// Test the setup: Both B and C should have conflicts.
|
||||
let tree_b2 = commit_b2.tree().unwrap();
|
||||
|
@ -614,18 +597,12 @@ fn test_simplify_conflict_after_resolving_parent() {
|
|||
let tree_b3 = create_tree(repo, &[(path, "AbC\ndef\nghi\n")]);
|
||||
let commit_b3 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b2)
|
||||
.rewrite_commit(&commit_b2)
|
||||
.set_tree_id(tree_b3.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c3 = rebase_commit(
|
||||
&settings,
|
||||
tx.repo_mut(),
|
||||
commit_c2,
|
||||
vec![commit_b3.id().clone()],
|
||||
)
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
let commit_c3 = rebase_commit(tx.repo_mut(), commit_c2, vec![commit_b3.id().clone()]).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// The conflict should now be resolved.
|
||||
|
@ -652,7 +629,6 @@ fn test_simplify_conflict_after_resolving_parent() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_on_lossy_merge() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -678,24 +654,19 @@ fn test_rebase_on_lossy_merge() {
|
|||
let tree_2 = create_tree(repo, &[(path, "2")]);
|
||||
let tree_3 = create_tree(repo, &[(path, "3")]);
|
||||
let commit_a = repo_mut
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
tree_1.id(),
|
||||
)
|
||||
.new_commit(vec![repo.store().root_commit_id().clone()], tree_1.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b = repo_mut
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree_2.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree_2.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c = repo_mut
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree_2.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree_2.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_d = repo_mut
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![commit_b.id().clone(), commit_c.id().clone()],
|
||||
tree_2.id(),
|
||||
)
|
||||
|
@ -703,11 +674,10 @@ fn test_rebase_on_lossy_merge() {
|
|||
.unwrap();
|
||||
|
||||
let commit_c2 = repo_mut
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree_3.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree_3.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_d2 = rebase_commit(
|
||||
&settings,
|
||||
repo_mut,
|
||||
commit_d,
|
||||
vec![commit_b.id().clone(), commit_c2.id().clone()],
|
||||
|
|
|
@ -29,12 +29,11 @@ use testutils::TestRepo;
|
|||
#[test]
|
||||
fn test_edit() {
|
||||
// Test that MutableRepo::edit() uses the requested commit (not a new child)
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let wc_commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let wc_commit = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
|
@ -47,19 +46,18 @@ fn test_edit() {
|
|||
#[test]
|
||||
fn test_checkout() {
|
||||
// Test that MutableRepo::check_out() creates a child
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let wc_commit_parent = write_random_commit(tx.repo_mut(), &settings);
|
||||
let wc_commit_parent = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let ws_id = WorkspaceId::default();
|
||||
let wc_commit = tx
|
||||
.repo_mut()
|
||||
.check_out(ws_id.clone(), &settings, &wc_commit_parent)
|
||||
.check_out(ws_id.clone(), &wc_commit_parent)
|
||||
.unwrap();
|
||||
assert_eq!(wc_commit.tree_id(), wc_commit_parent.tree_id());
|
||||
assert_eq!(wc_commit.parent_ids().len(), 1);
|
||||
|
@ -72,22 +70,21 @@ fn test_checkout() {
|
|||
fn test_edit_previous_not_empty() {
|
||||
// Test that MutableRepo::edit() does not usually abandon the previous
|
||||
// commit.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let old_wc_commit = write_random_commit(mut_repo);
|
||||
let ws_id = WorkspaceId::default();
|
||||
mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -95,7 +92,6 @@ fn test_edit_previous_not_empty() {
|
|||
fn test_edit_previous_empty() {
|
||||
// Test that MutableRepo::edit() abandons the previous commit if it was
|
||||
// empty.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -103,7 +99,6 @@ fn test_edit_previous_empty() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -115,9 +110,9 @@ fn test_edit_previous_empty() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(!mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -125,14 +120,13 @@ fn test_edit_previous_empty() {
|
|||
fn test_edit_previous_empty_merge() {
|
||||
// Test that MutableRepo::edit() abandons the previous commit if it was
|
||||
// an empty merge commit.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let old_parent1 = write_random_commit(mut_repo, &settings);
|
||||
let old_parent2 = write_random_commit(mut_repo, &settings);
|
||||
let old_parent1 = write_random_commit(mut_repo);
|
||||
let old_parent2 = write_random_commit(mut_repo);
|
||||
let empty_tree = repo.store().root_commit().tree().unwrap();
|
||||
let old_parent_tree = old_parent1
|
||||
.tree()
|
||||
|
@ -141,7 +135,6 @@ fn test_edit_previous_empty_merge() {
|
|||
.unwrap();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![old_parent1.id().clone(), old_parent2.id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -154,9 +147,9 @@ fn test_edit_previous_empty_merge() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(!mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -164,7 +157,6 @@ fn test_edit_previous_empty_merge() {
|
|||
fn test_edit_previous_empty_with_description() {
|
||||
// Test that MutableRepo::edit() does not abandon the previous commit if it
|
||||
// has a non-empty description.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -172,7 +164,6 @@ fn test_edit_previous_empty_with_description() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -185,9 +176,9 @@ fn test_edit_previous_empty_with_description() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -195,7 +186,6 @@ fn test_edit_previous_empty_with_description() {
|
|||
fn test_edit_previous_empty_with_local_bookmark() {
|
||||
// Test that MutableRepo::edit() does not abandon the previous commit if it
|
||||
// is pointed by local bookmark.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -203,7 +193,6 @@ fn test_edit_previous_empty_with_local_bookmark() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -216,9 +205,9 @@ fn test_edit_previous_empty_with_local_bookmark() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -226,7 +215,6 @@ fn test_edit_previous_empty_with_local_bookmark() {
|
|||
fn test_edit_previous_empty_with_other_workspace() {
|
||||
// Test that MutableRepo::edit() does not abandon the previous commit if it
|
||||
// is pointed by another workspace
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -234,7 +222,6 @@ fn test_edit_previous_empty_with_other_workspace() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -248,9 +235,9 @@ fn test_edit_previous_empty_with_other_workspace() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -258,7 +245,6 @@ fn test_edit_previous_empty_with_other_workspace() {
|
|||
fn test_edit_previous_empty_non_head() {
|
||||
// Test that MutableRepo::edit() does not abandon the previous commit if it
|
||||
// was empty and is not a head
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -266,7 +252,6 @@ fn test_edit_previous_empty_non_head() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -274,7 +259,6 @@ fn test_edit_previous_empty_non_head() {
|
|||
.unwrap();
|
||||
let old_child = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![old_wc_commit.id().clone()],
|
||||
old_wc_commit.tree_id().clone(),
|
||||
)
|
||||
|
@ -286,9 +270,9 @@ fn test_edit_previous_empty_non_head() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let new_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let new_wc_commit = write_random_commit(mut_repo);
|
||||
mut_repo.edit(ws_id, &new_wc_commit).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert_eq!(
|
||||
*mut_repo.view().heads(),
|
||||
hashset! {old_child.id().clone(), new_wc_commit.id().clone()}
|
||||
|
@ -299,12 +283,11 @@ fn test_edit_previous_empty_non_head() {
|
|||
fn test_edit_initial() {
|
||||
// Test that MutableRepo::edit() can be used on the initial working-copy commit
|
||||
// in a workspace
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let wc_commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let wc_commit = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
|
@ -323,12 +306,11 @@ fn test_edit_initial() {
|
|||
fn test_edit_hidden_commit() {
|
||||
// Test that MutableRepo::edit() edits a hidden commit and updates
|
||||
// the view head ids.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let wc_commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let wc_commit = write_random_commit(tx.repo_mut());
|
||||
|
||||
// Intentionally not doing tx.commit, so the commit id is not tracked
|
||||
// in the view head ids.
|
||||
|
@ -345,14 +327,13 @@ fn test_edit_hidden_commit() {
|
|||
fn test_add_head_success() {
|
||||
// Test that MutableRepo::add_head() adds the head, and that it's still there
|
||||
// after commit. It should also be indexed.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Create a commit outside of the repo by using a temporary transaction. Then
|
||||
// add that as a head.
|
||||
let mut tx = repo.start_transaction();
|
||||
let new_commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let new_commit = write_random_commit(tx.repo_mut());
|
||||
drop(tx);
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
|
@ -371,12 +352,11 @@ fn test_add_head_success() {
|
|||
fn test_add_head_ancestor() {
|
||||
// Test that MutableRepo::add_head() does not add a head if it's an ancestor of
|
||||
// an existing head.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
@ -393,23 +373,22 @@ fn test_add_head_ancestor() {
|
|||
fn test_add_head_not_immediate_child() {
|
||||
// Test that MutableRepo::add_head() can be used for adding a head that is not
|
||||
// an immediate child of a current head.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let initial = write_random_commit(tx.repo_mut(), &settings);
|
||||
let initial = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// 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();
|
||||
let rewritten = create_random_commit(tx.repo_mut(), &settings)
|
||||
let rewritten = create_random_commit(tx.repo_mut())
|
||||
.set_change_id(initial.change_id().clone())
|
||||
.set_predecessors(vec![initial.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let child = create_random_commit(tx.repo_mut(), &settings)
|
||||
let child = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![rewritten.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -433,12 +412,11 @@ fn test_remove_head() {
|
|||
// Test that MutableRepo::remove_head() removes the head, and that it's still
|
||||
// removed after commit. It should remain in the index, since we otherwise would
|
||||
// have to reindex everything.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
@ -470,7 +448,6 @@ fn test_has_changed() {
|
|||
// Test that MutableRepo::has_changed() reports changes iff the view has changed
|
||||
// (e.g. not after setting a bookmark to point to where it was already
|
||||
// pointing).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
let normal_remote_ref = |id: &CommitId| RemoteRef {
|
||||
|
@ -480,8 +457,8 @@ fn test_has_changed() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit1 = write_random_commit(mut_repo, &settings);
|
||||
let commit2 = write_random_commit(mut_repo, &settings);
|
||||
let commit1 = write_random_commit(mut_repo);
|
||||
let commit2 = write_random_commit(mut_repo);
|
||||
mut_repo.remove_head(commit2.id());
|
||||
let ws_id = WorkspaceId::default();
|
||||
mut_repo
|
||||
|
@ -535,12 +512,11 @@ fn test_has_changed() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_simple() {
|
||||
// There are many additional tests of this functionality in `test_rewrite.rs`.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
@ -550,13 +526,13 @@ fn test_rebase_descendants_simple() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(mut_repo);
|
||||
let commit6 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
mut_repo.set_rewritten_commit(commit2.id().clone(), commit6.id().clone());
|
||||
mut_repo.record_abandoned_commit(commit4.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
// Commit 3 got rebased onto commit 2's replacement, i.e. commit 6
|
||||
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit3, &[commit6.id()]);
|
||||
|
@ -567,7 +543,7 @@ fn test_rebase_descendants_simple() {
|
|||
// No more descendants to rebase if we try again.
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 0);
|
||||
}
|
||||
|
@ -577,12 +553,11 @@ fn test_rebase_descendants_divergent_rewrite() {
|
|||
// Test rebasing descendants when one commit was rewritten to several other
|
||||
// commits. There are many additional tests of this functionality in
|
||||
// `test_rewrite.rs`.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let _commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
@ -590,7 +565,7 @@ fn test_rebase_descendants_divergent_rewrite() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(mut_repo);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit5 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
mut_repo.set_divergent_rewrite(
|
||||
|
@ -601,19 +576,18 @@ fn test_rebase_descendants_divergent_rewrite() {
|
|||
// commit 4 or commit 5
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert!(rebase_map.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
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();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let commit = write_random_commit(mut_repo, &settings);
|
||||
let commit = write_random_commit(mut_repo);
|
||||
let remote_ref = RemoteRef {
|
||||
target: RefTarget::normal(commit.id().clone()),
|
||||
state: RemoteRefState::Tracking, // doesn't matter
|
||||
|
@ -631,13 +605,12 @@ fn test_rename_remote() {
|
|||
fn test_remove_wc_commit_previous_not_discardable() {
|
||||
// Test that MutableRepo::remove_wc_commit() does not usually abandon the
|
||||
// previous commit.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = write_random_commit(mut_repo, &settings);
|
||||
let old_wc_commit = write_random_commit(mut_repo);
|
||||
let ws_id = WorkspaceId::default();
|
||||
mut_repo.edit(ws_id.clone(), &old_wc_commit).unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
@ -645,7 +618,7 @@ fn test_remove_wc_commit_previous_not_discardable() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
mut_repo.remove_wc_commit(&ws_id).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -653,7 +626,6 @@ fn test_remove_wc_commit_previous_not_discardable() {
|
|||
fn test_remove_wc_commit_previous_discardable() {
|
||||
// Test that MutableRepo::remove_wc_commit() abandons the previous commit
|
||||
// if it was discardable.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -661,7 +633,6 @@ fn test_remove_wc_commit_previous_discardable() {
|
|||
let mut_repo = tx.repo_mut();
|
||||
let old_wc_commit = mut_repo
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
repo.store().empty_merged_tree_id(),
|
||||
)
|
||||
|
@ -674,7 +645,7 @@ fn test_remove_wc_commit_previous_discardable() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
mut_repo.remove_wc_commit(&ws_id).unwrap();
|
||||
mut_repo.rebase_descendants(&settings).unwrap();
|
||||
mut_repo.rebase_descendants().unwrap();
|
||||
assert!(!mut_repo.view().heads().contains(old_wc_commit.id()));
|
||||
}
|
||||
|
||||
|
@ -682,12 +653,11 @@ fn test_remove_wc_commit_previous_discardable() {
|
|||
fn test_reparent_descendants() {
|
||||
// Test that MutableRepo::reparent_descendants() reparents descendants of
|
||||
// rewritten commits without altering their content.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.initial_commit();
|
||||
let commit_child_a_b = graph_builder.commit_with_parents(&[&commit_a, &commit_b]);
|
||||
|
@ -710,11 +680,11 @@ fn test_reparent_descendants() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
mut_repo
|
||||
.rewrite_commit(&settings, &commit_a)
|
||||
.rewrite_commit(&commit_a)
|
||||
.set_tree_id(create_random_tree(&repo))
|
||||
.write()
|
||||
.unwrap();
|
||||
let reparented = mut_repo.reparent_descendants(&settings).unwrap();
|
||||
let reparented = mut_repo.reparent_descendants().unwrap();
|
||||
// "child_a_b", "grandchild_a_b" and "child_a" (3 commits) must have been
|
||||
// reparented.
|
||||
assert_eq!(reparented, 3);
|
||||
|
|
|
@ -45,7 +45,6 @@ fn list_dir(dir: &Path) -> Vec<String> {
|
|||
#[test]
|
||||
fn test_unpublished_operation() {
|
||||
// Test that the operation doesn't get published until that's requested.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -54,7 +53,7 @@ fn test_unpublished_operation() {
|
|||
assert_eq!(list_dir(&op_heads_dir), vec![repo.op_id().hex()]);
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
write_random_commit(tx1.repo_mut(), &settings);
|
||||
write_random_commit(tx1.repo_mut());
|
||||
let unpublished_op = tx1.write("transaction 1");
|
||||
let op_id1 = unpublished_op.operation().id().clone();
|
||||
assert_ne!(op_id1, op_id0);
|
||||
|
@ -67,7 +66,6 @@ fn test_unpublished_operation() {
|
|||
fn test_consecutive_operations() {
|
||||
// Test that consecutive operations result in a single op-head on disk after
|
||||
// each operation
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -76,7 +74,7 @@ fn test_consecutive_operations() {
|
|||
assert_eq!(list_dir(&op_heads_dir), vec![repo.op_id().hex()]);
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
write_random_commit(tx1.repo_mut(), &settings);
|
||||
write_random_commit(tx1.repo_mut());
|
||||
let op_id1 = tx1
|
||||
.commit("transaction 1")
|
||||
.unwrap()
|
||||
|
@ -86,9 +84,9 @@ fn test_consecutive_operations() {
|
|||
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 repo = repo.reload_at_head().unwrap();
|
||||
let mut tx2 = repo.start_transaction();
|
||||
write_random_commit(tx2.repo_mut(), &settings);
|
||||
write_random_commit(tx2.repo_mut());
|
||||
let op_id2 = tx2
|
||||
.commit("transaction 2")
|
||||
.unwrap()
|
||||
|
@ -101,7 +99,7 @@ fn test_consecutive_operations() {
|
|||
|
||||
// Reloading the repo makes no difference (there are no conflicting operations
|
||||
// to resolve).
|
||||
let _repo = repo.reload_at_head(&settings).unwrap();
|
||||
let _repo = repo.reload_at_head().unwrap();
|
||||
assert_eq!(list_dir(&op_heads_dir), vec![op_id2.hex()]);
|
||||
}
|
||||
|
||||
|
@ -109,7 +107,6 @@ fn test_consecutive_operations() {
|
|||
fn test_concurrent_operations() {
|
||||
// Test that consecutive operations result in multiple op-heads on disk until
|
||||
// the repo has been reloaded (which currently happens right away).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -118,7 +115,7 @@ fn test_concurrent_operations() {
|
|||
assert_eq!(list_dir(&op_heads_dir), vec![repo.op_id().hex()]);
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
write_random_commit(tx1.repo_mut(), &settings);
|
||||
write_random_commit(tx1.repo_mut());
|
||||
let op_id1 = tx1
|
||||
.commit("transaction 1")
|
||||
.unwrap()
|
||||
|
@ -131,7 +128,7 @@ fn test_concurrent_operations() {
|
|||
// 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();
|
||||
write_random_commit(tx2.repo_mut(), &settings);
|
||||
write_random_commit(tx2.repo_mut());
|
||||
let op_id2 = tx2
|
||||
.commit("transaction 2")
|
||||
.unwrap()
|
||||
|
@ -147,7 +144,7 @@ fn test_concurrent_operations() {
|
|||
assert_eq!(actual_heads_on_disk, expected_heads_on_disk);
|
||||
|
||||
// Reloading the repo causes the operations to be merged
|
||||
let repo = repo.reload_at_head(&settings).unwrap();
|
||||
let repo = repo.reload_at_head().unwrap();
|
||||
let merged_op_id = repo.op_id().clone();
|
||||
assert_ne!(merged_op_id, op_id0);
|
||||
assert_ne!(merged_op_id, op_id1);
|
||||
|
@ -163,12 +160,11 @@ fn assert_heads(repo: &dyn Repo, expected: Vec<&CommitId>) {
|
|||
#[test]
|
||||
fn test_isolation() {
|
||||
// Test that two concurrent transactions don't see each other's changes.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let initial = create_random_commit(tx.repo_mut(), &settings)
|
||||
let initial = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![repo.store().root_commit_id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -184,17 +180,17 @@ fn test_isolation() {
|
|||
assert_heads(mut_repo2, vec![initial.id()]);
|
||||
|
||||
let rewrite1 = mut_repo1
|
||||
.rewrite_commit(&settings, &initial)
|
||||
.rewrite_commit(&initial)
|
||||
.set_description("rewrite1")
|
||||
.write()
|
||||
.unwrap();
|
||||
mut_repo1.rebase_descendants(&settings).unwrap();
|
||||
mut_repo1.rebase_descendants().unwrap();
|
||||
let rewrite2 = mut_repo2
|
||||
.rewrite_commit(&settings, &initial)
|
||||
.rewrite_commit(&initial)
|
||||
.set_description("rewrite2")
|
||||
.write()
|
||||
.unwrap();
|
||||
mut_repo2.rebase_descendants(&settings).unwrap();
|
||||
mut_repo2.rebase_descendants().unwrap();
|
||||
|
||||
// Neither transaction has committed yet, so each transaction sees its own
|
||||
// commit.
|
||||
|
@ -211,13 +207,12 @@ fn test_isolation() {
|
|||
tx2.commit("transaction 2").unwrap();
|
||||
assert_heads(repo.as_ref(), vec![initial.id()]);
|
||||
// After reload, the base repo sees both rewrites.
|
||||
let repo = repo.reload_at_head(&settings).unwrap();
|
||||
let repo = repo.reload_at_head().unwrap();
|
||||
assert_heads(repo.as_ref(), vec![rewrite1.id(), rewrite2.id()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reparent_range_linear() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo_0 = test_repo.repo;
|
||||
let loader = repo_0.loader();
|
||||
|
@ -238,7 +233,7 @@ fn test_reparent_range_linear() {
|
|||
// 0 (initial)
|
||||
let random_tx = |repo: &Arc<ReadonlyRepo>| {
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
tx
|
||||
};
|
||||
let repo_a = random_tx(&repo_0).commit("op A").unwrap();
|
||||
|
@ -284,7 +279,6 @@ fn test_reparent_range_linear() {
|
|||
|
||||
#[test]
|
||||
fn test_reparent_range_branchy() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo_0 = test_repo.repo;
|
||||
let loader = repo_0.loader();
|
||||
|
@ -310,7 +304,7 @@ fn test_reparent_range_branchy() {
|
|||
// 0 (initial)
|
||||
let random_tx = |repo: &Arc<ReadonlyRepo>| {
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
tx
|
||||
};
|
||||
let repo_a = random_tx(&repo_0).commit("op A").unwrap();
|
||||
|
@ -319,7 +313,7 @@ fn test_reparent_range_branchy() {
|
|||
let repo_d = random_tx(&repo_c).commit("op D").unwrap();
|
||||
let tx_e = random_tx(&repo_d);
|
||||
let tx_f = random_tx(&repo_c);
|
||||
let repo_g = testutils::commit_transactions(&settings, vec![tx_e, tx_f]);
|
||||
let repo_g = testutils::commit_transactions(vec![tx_e, tx_f]);
|
||||
let [op_e, op_f] = op_parents(repo_g.operation());
|
||||
|
||||
// Reparent D..G (= E|F|G) onto B:
|
||||
|
@ -593,7 +587,7 @@ fn test_resolve_op_parents_children() {
|
|||
// Merge and fork
|
||||
let tx1 = repo.start_transaction();
|
||||
let tx2 = repo.start_transaction();
|
||||
let repo = testutils::commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = testutils::commit_transactions(vec![tx1, tx2]);
|
||||
let op5_id_hex = repo.operation().id().hex();
|
||||
assert_matches!(
|
||||
op_walk::resolve_op_with_repo(&repo, &format!("{op5_id_hex}-")),
|
||||
|
@ -632,7 +626,7 @@ fn test_gc() {
|
|||
let empty_tx = |repo: &Arc<ReadonlyRepo>| repo.start_transaction();
|
||||
let random_tx = |repo: &Arc<ReadonlyRepo>| {
|
||||
let mut tx = repo.start_transaction();
|
||||
write_random_commit(tx.repo_mut(), &settings);
|
||||
write_random_commit(tx.repo_mut());
|
||||
tx
|
||||
};
|
||||
let repo_a = random_tx(&repo_0).commit("op A").unwrap();
|
||||
|
|
|
@ -34,7 +34,7 @@ fn test_merge_ref_targets() {
|
|||
// |/
|
||||
// 1
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -75,7 +75,6 @@ fn test_restore_tree() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_sideways() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -89,7 +88,7 @@ fn test_rebase_descendants_sideways() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -101,7 +100,7 @@ fn test_rebase_descendants_sideways() {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_f.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 3);
|
||||
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_f.id()]);
|
||||
|
@ -120,7 +119,6 @@ fn test_rebase_descendants_sideways() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_forward() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -142,7 +140,7 @@ fn test_rebase_descendants_forward() {
|
|||
// B
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -155,7 +153,7 @@ fn test_rebase_descendants_forward() {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_f.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_d =
|
||||
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[(commit_f.id())]);
|
||||
|
@ -181,7 +179,6 @@ fn test_rebase_descendants_forward() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_reorder() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -197,7 +194,7 @@ fn test_rebase_descendants_reorder() {
|
|||
// B
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -216,7 +213,7 @@ fn test_rebase_descendants_reorder() {
|
|||
.set_rewritten_commit(commit_g.id().clone(), commit_h.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_i = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_i, &[commit_h.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -231,7 +228,6 @@ fn test_rebase_descendants_reorder() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_backward() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -242,7 +238,7 @@ fn test_rebase_descendants_backward() {
|
|||
// B
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -252,7 +248,7 @@ fn test_rebase_descendants_backward() {
|
|||
.set_rewritten_commit(commit_c.id().clone(), commit_b.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_b.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -265,7 +261,6 @@ fn test_rebase_descendants_backward() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_chain_becomes_branchy() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -280,7 +275,7 @@ fn test_rebase_descendants_chain_becomes_branchy() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -294,7 +289,7 @@ fn test_rebase_descendants_chain_becomes_branchy() {
|
|||
.set_rewritten_commit(commit_c.id().clone(), commit_f.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_f = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_f, &[commit_e.id()]);
|
||||
let new_commit_d =
|
||||
|
@ -311,7 +306,6 @@ fn test_rebase_descendants_chain_becomes_branchy() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_internal_merge() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -326,7 +320,7 @@ fn test_rebase_descendants_internal_merge() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -338,7 +332,7 @@ fn test_rebase_descendants_internal_merge() {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_f.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_f.id()]);
|
||||
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_f.id()]);
|
||||
|
@ -358,7 +352,6 @@ fn test_rebase_descendants_internal_merge() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_external_merge() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -374,7 +367,7 @@ fn test_rebase_descendants_external_merge() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -386,7 +379,7 @@ fn test_rebase_descendants_external_merge() {
|
|||
.set_rewritten_commit(commit_c.id().clone(), commit_f.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_e = assert_rebased_onto(
|
||||
tx.repo_mut(),
|
||||
|
@ -404,7 +397,6 @@ fn test_rebase_descendants_external_merge() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_abandon() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -418,7 +410,7 @@ fn test_rebase_descendants_abandon() {
|
|||
// B
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -430,7 +422,7 @@ fn test_rebase_descendants_abandon() {
|
|||
tx.repo_mut().record_abandoned_commit(commit_e.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_a.id()]);
|
||||
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_a.id()]);
|
||||
|
@ -449,7 +441,6 @@ fn test_rebase_descendants_abandon() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_abandon_no_descendants() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -459,7 +450,7 @@ fn test_rebase_descendants_abandon_no_descendants() {
|
|||
// B
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -468,7 +459,7 @@ fn test_rebase_descendants_abandon_no_descendants() {
|
|||
tx.repo_mut().record_abandoned_commit(commit_c.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 0);
|
||||
|
||||
|
@ -482,7 +473,6 @@ fn test_rebase_descendants_abandon_no_descendants() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_abandon_and_replace() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -495,7 +485,7 @@ fn test_rebase_descendants_abandon_and_replace() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -507,7 +497,7 @@ fn test_rebase_descendants_abandon_and_replace() {
|
|||
tx.repo_mut().record_abandoned_commit(commit_c.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_e.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -520,7 +510,6 @@ fn test_rebase_descendants_abandon_and_replace() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_abandon_degenerate_merge_simplify() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -533,7 +522,7 @@ fn test_rebase_descendants_abandon_degenerate_merge_simplify() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -542,13 +531,10 @@ fn test_rebase_descendants_abandon_degenerate_merge_simplify() {
|
|||
tx.repo_mut().record_abandoned_commit(commit_b.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(
|
||||
&settings,
|
||||
RebaseOptions {
|
||||
simplify_ancestor_merge: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.rebase_descendants_with_options_return_map(RebaseOptions {
|
||||
simplify_ancestor_merge: true,
|
||||
..Default::default()
|
||||
})
|
||||
.unwrap();
|
||||
let new_commit_d = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_d, &[commit_c.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -561,7 +547,6 @@ fn test_rebase_descendants_abandon_degenerate_merge_simplify() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_abandon_degenerate_merge_preserve() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -574,7 +559,7 @@ fn test_rebase_descendants_abandon_degenerate_merge_preserve() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -583,13 +568,10 @@ fn test_rebase_descendants_abandon_degenerate_merge_preserve() {
|
|||
tx.repo_mut().record_abandoned_commit(commit_b.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(
|
||||
&settings,
|
||||
RebaseOptions {
|
||||
simplify_ancestor_merge: false,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.rebase_descendants_with_options_return_map(RebaseOptions {
|
||||
simplify_ancestor_merge: false,
|
||||
..Default::default()
|
||||
})
|
||||
.unwrap();
|
||||
let new_commit_d = assert_rebased_onto(
|
||||
tx.repo_mut(),
|
||||
|
@ -607,7 +589,6 @@ fn test_rebase_descendants_abandon_degenerate_merge_preserve() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_abandon_widen_merge() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -622,7 +603,7 @@ fn test_rebase_descendants_abandon_widen_merge() {
|
|||
// \|/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -633,7 +614,7 @@ fn test_rebase_descendants_abandon_widen_merge() {
|
|||
tx.repo_mut().record_abandoned_commit(commit_e.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_f = assert_rebased_onto(
|
||||
tx.repo_mut(),
|
||||
|
@ -651,7 +632,6 @@ fn test_rebase_descendants_abandon_widen_merge() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_multiple_sideways() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -664,7 +644,7 @@ fn test_rebase_descendants_multiple_sideways() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -678,7 +658,7 @@ fn test_rebase_descendants_multiple_sideways() {
|
|||
.set_rewritten_commit(commit_d.id().clone(), commit_f.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_c = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_f.id()]);
|
||||
let new_commit_e = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_e, &[commit_f.id()]);
|
||||
|
@ -696,7 +676,6 @@ fn test_rebase_descendants_multiple_sideways() {
|
|||
#[test]
|
||||
#[should_panic(expected = "cycle")]
|
||||
fn test_rebase_descendants_multiple_swap() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -708,7 +687,7 @@ fn test_rebase_descendants_multiple_swap() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -719,14 +698,12 @@ fn test_rebase_descendants_multiple_swap() {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_d.id().clone());
|
||||
tx.repo_mut()
|
||||
.set_rewritten_commit(commit_d.id().clone(), commit_b.id().clone());
|
||||
let _ = tx.repo_mut().rebase_descendants(&settings); // Panics because of
|
||||
// the cycle
|
||||
let _ = tx.repo_mut().rebase_descendants(); // Panics because of the cycle
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "cycle")]
|
||||
fn test_rebase_descendants_multiple_no_descendants() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -736,7 +713,7 @@ fn test_rebase_descendants_multiple_no_descendants() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -745,13 +722,11 @@ fn test_rebase_descendants_multiple_no_descendants() {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_c.id().clone());
|
||||
tx.repo_mut()
|
||||
.set_rewritten_commit(commit_c.id().clone(), commit_b.id().clone());
|
||||
let _ = tx.repo_mut().rebase_descendants(&settings); // Panics because of
|
||||
// the cycle
|
||||
let _ = tx.repo_mut().rebase_descendants(); // Panics because of the cycle
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rebase_descendants_divergent_rewrite() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -776,7 +751,7 @@ fn test_rebase_descendants_divergent_rewrite() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -800,7 +775,7 @@ fn test_rebase_descendants_divergent_rewrite() {
|
|||
.set_rewritten_commit(commit_f.id().clone(), commit_f2.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let new_commit_c =
|
||||
assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_b2.id()]);
|
||||
|
@ -822,7 +797,6 @@ fn test_rebase_descendants_divergent_rewrite() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_repeated() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -838,20 +812,20 @@ fn test_rebase_descendants_repeated() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_description("b2")
|
||||
.write()
|
||||
.unwrap();
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let commit_c2 = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c, &[commit_b2.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -866,20 +840,20 @@ fn test_rebase_descendants_repeated() {
|
|||
// We made no more changes, so nothing should be rebased.
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 0);
|
||||
|
||||
// Now mark B3 as rewritten from B2 and rebase descendants again.
|
||||
let commit_b3 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b2)
|
||||
.rewrite_commit(&commit_b2)
|
||||
.set_description("b3")
|
||||
.write()
|
||||
.unwrap();
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
let commit_c3 = assert_rebased_onto(tx.repo_mut(), &rebase_map, &commit_c2, &[commit_b3.id()]);
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
|
@ -895,7 +869,6 @@ fn test_rebase_descendants_repeated() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_contents() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -912,32 +885,28 @@ fn test_rebase_descendants_contents() {
|
|||
let tree1 = create_tree(repo, &[(path1, "content")]);
|
||||
let commit_a = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
tree1.id(),
|
||||
)
|
||||
.new_commit(vec![repo.store().root_commit_id().clone()], tree1.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let path2 = RepoPath::from_internal_string("file2");
|
||||
let tree2 = create_tree(repo, &[(path2, "content")]);
|
||||
let commit_b = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree2.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree2.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let path3 = RepoPath::from_internal_string("file3");
|
||||
let tree3 = create_tree(repo, &[(path3, "content")]);
|
||||
let commit_c = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_b.id().clone()], tree3.id())
|
||||
.new_commit(vec![commit_b.id().clone()], tree3.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let path4 = RepoPath::from_internal_string("file4");
|
||||
let tree4 = create_tree(repo, &[(path4, "content")]);
|
||||
let commit_d = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree4.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree4.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
|
||||
|
@ -945,7 +914,7 @@ fn test_rebase_descendants_contents() {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_d.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, Default::default())
|
||||
.rebase_descendants_with_options_return_map(Default::default())
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 1);
|
||||
let new_commit_c = repo
|
||||
|
@ -973,7 +942,6 @@ fn test_rebase_descendants_contents() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_basic_bookmark_update() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -984,7 +952,7 @@ fn test_rebase_descendants_basic_bookmark_update() {
|
|||
// | => |
|
||||
// A A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
tx.repo_mut()
|
||||
|
@ -992,12 +960,8 @@ fn test_rebase_descendants_basic_bookmark_update() {
|
|||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
let commit_b2 = tx.repo_mut().rewrite_commit(&commit_b).write().unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert_eq!(
|
||||
tx.repo_mut().get_local_bookmark("main"),
|
||||
RefTarget::normal(commit_b2.id().clone())
|
||||
|
@ -1011,7 +975,6 @@ fn test_rebase_descendants_basic_bookmark_update() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_bookmark_move_two_steps() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1026,7 +989,7 @@ fn test_rebase_descendants_bookmark_move_two_steps() {
|
|||
// |/ |
|
||||
// A A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -1037,17 +1000,17 @@ fn test_rebase_descendants_bookmark_move_two_steps() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let commit_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_description("different")
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_c)
|
||||
.rewrite_commit(&commit_c)
|
||||
.set_description("more different")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let heads = tx.repo_mut().view().heads();
|
||||
assert_eq!(heads.len(), 1);
|
||||
let c3_id = heads.iter().next().unwrap().clone();
|
||||
|
@ -1062,7 +1025,6 @@ fn test_rebase_descendants_bookmark_move_two_steps() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_basic_bookmark_update_with_non_local_bookmark() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1075,7 +1037,7 @@ fn test_rebase_descendants_basic_bookmark_update_with_non_local_bookmark() {
|
|||
// | => |/
|
||||
// A A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
let commit_b_remote_ref = RemoteRef {
|
||||
|
@ -1091,12 +1053,8 @@ fn test_rebase_descendants_basic_bookmark_update_with_non_local_bookmark() {
|
|||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
let commit_b2 = tx.repo_mut().rewrite_commit(&commit_b).write().unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert_eq!(
|
||||
tx.repo_mut().get_local_bookmark("main"),
|
||||
RefTarget::normal(commit_b2.id().clone())
|
||||
|
@ -1121,7 +1079,6 @@ fn test_rebase_descendants_basic_bookmark_update_with_non_local_bookmark() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_update_bookmark_after_abandon() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1132,7 +1089,7 @@ fn test_rebase_descendants_update_bookmark_after_abandon() {
|
|||
// | => A main
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
tx.repo_mut()
|
||||
|
@ -1141,7 +1098,7 @@ fn test_rebase_descendants_update_bookmark_after_abandon() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut().record_abandoned_commit(commit_b.id().clone());
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert_eq!(
|
||||
tx.repo_mut().get_local_bookmark("main"),
|
||||
RefTarget::normal(commit_a.id().clone())
|
||||
|
@ -1155,7 +1112,6 @@ fn test_rebase_descendants_update_bookmark_after_abandon() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_update_bookmarks_after_divergent_rewrite() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1171,7 +1127,7 @@ fn test_rebase_descendants_update_bookmarks_after_divergent_rewrite() {
|
|||
// | => |/ => |/
|
||||
// A A A
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -1182,22 +1138,18 @@ fn test_rebase_descendants_update_bookmarks_after_divergent_rewrite() {
|
|||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b2 = tx.repo_mut().rewrite_commit(&commit_b).write().unwrap();
|
||||
// Different description so they're not the same commit
|
||||
let commit_b3 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_description("different")
|
||||
.write()
|
||||
.unwrap();
|
||||
// Different description so they're not the same commit
|
||||
let commit_b4 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_description("more different")
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1209,14 +1161,10 @@ fn test_rebase_descendants_update_bookmarks_after_divergent_rewrite() {
|
|||
commit_b4.id().clone(),
|
||||
],
|
||||
);
|
||||
let commit_b41 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b4)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b41 = tx.repo_mut().rewrite_commit(&commit_b4).write().unwrap();
|
||||
let commit_b42 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b4)
|
||||
.rewrite_commit(&commit_b4)
|
||||
.set_description("different")
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1224,7 +1172,7 @@ fn test_rebase_descendants_update_bookmarks_after_divergent_rewrite() {
|
|||
commit_b4.id().clone(),
|
||||
vec![commit_b41.id().clone(), commit_b42.id().clone()],
|
||||
);
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let main_target = tx.repo_mut().get_local_bookmark("main");
|
||||
assert!(main_target.has_conflict());
|
||||
|
@ -1262,7 +1210,6 @@ fn test_rebase_descendants_update_bookmarks_after_divergent_rewrite() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_rewrite_updates_bookmark_conflict() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1270,7 +1217,7 @@ fn test_rebase_descendants_rewrite_updates_bookmark_conflict() {
|
|||
// A gets rewritten as A2 and A3. B gets rewritten as B2 and B2. The bookmark
|
||||
// should become a conflict removing A and B, and adding B2, B3, C.
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.initial_commit();
|
||||
let commit_c = graph_builder.initial_commit();
|
||||
|
@ -1284,27 +1231,19 @@ fn test_rebase_descendants_rewrite_updates_bookmark_conflict() {
|
|||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_a)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_a2 = tx.repo_mut().rewrite_commit(&commit_a).write().unwrap();
|
||||
// Different description so they're not the same commit
|
||||
let commit_a3 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_a)
|
||||
.rewrite_commit(&commit_a)
|
||||
.set_description("different")
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b2 = tx.repo_mut().rewrite_commit(&commit_b).write().unwrap();
|
||||
// Different description so they're not the same commit
|
||||
let commit_b3 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_description("different")
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1316,7 +1255,7 @@ fn test_rebase_descendants_rewrite_updates_bookmark_conflict() {
|
|||
commit_b.id().clone(),
|
||||
vec![commit_b2.id().clone(), commit_b3.id().clone()],
|
||||
);
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let target = tx.repo_mut().get_local_bookmark("main");
|
||||
assert!(target.has_conflict());
|
||||
|
@ -1347,7 +1286,6 @@ fn test_rebase_descendants_rewrite_updates_bookmark_conflict() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_rewrite_resolves_bookmark_conflict() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1359,7 +1297,7 @@ fn test_rebase_descendants_rewrite_resolves_bookmark_conflict() {
|
|||
// is a descendant of A, and B2 is a descendant of C, the conflict gets
|
||||
// resolved to B2.
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -1375,11 +1313,11 @@ fn test_rebase_descendants_rewrite_resolves_bookmark_conflict() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let commit_b2 = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_parents(vec![commit_c.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert_eq!(
|
||||
tx.repo_mut().get_local_bookmark("main"),
|
||||
RefTarget::normal(commit_b2.id().clone())
|
||||
|
@ -1393,7 +1331,6 @@ fn test_rebase_descendants_rewrite_resolves_bookmark_conflict() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_bookmark_delete_modify_abandon() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1403,7 +1340,7 @@ fn test_rebase_descendants_bookmark_delete_modify_abandon() {
|
|||
// result in the bookmark pointing to "-A+A=0", so the bookmark should
|
||||
// be deleted.
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
tx.repo_mut().set_local_bookmark_target(
|
||||
|
@ -1414,7 +1351,7 @@ fn test_rebase_descendants_bookmark_delete_modify_abandon() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut().record_abandoned_commit(commit_b.id().clone());
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
assert_eq!(
|
||||
tx.repo_mut().get_local_bookmark("main"),
|
||||
RefTarget::absent()
|
||||
|
@ -1427,7 +1364,6 @@ fn test_rebase_descendants_bookmark_delete_modify_abandon() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_update_checkout() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1438,8 +1374,8 @@ fn test_rebase_descendants_update_checkout() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_b = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let commit_b = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1460,11 +1396,11 @@ fn test_rebase_descendants_update_checkout() {
|
|||
let mut tx = repo.start_transaction();
|
||||
let commit_c = tx
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_b)
|
||||
.rewrite_commit(&commit_b)
|
||||
.set_description("C")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// Workspaces 1 and 2 had B checked out, so they get updated to C. Workspace 3
|
||||
|
@ -1476,7 +1412,6 @@ fn test_rebase_descendants_update_checkout() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_update_checkout_abandoned() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1487,8 +1422,8 @@ fn test_rebase_descendants_update_checkout_abandoned() {
|
|||
// |
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_b = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let commit_b = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1508,7 +1443,7 @@ fn test_rebase_descendants_update_checkout_abandoned() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut().record_abandoned_commit(commit_b.id().clone());
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
// Workspaces 1 and 2 had B checked out, so they get updated to the same new
|
||||
|
@ -1527,7 +1462,6 @@ fn test_rebase_descendants_update_checkout_abandoned() {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_descendants_update_checkout_abandoned_merge() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1540,16 +1474,16 @@ fn test_rebase_descendants_update_checkout_abandoned_merge() {
|
|||
// |/
|
||||
// A
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_b = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let commit_b = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_c = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_d = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_d = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_b.id().clone(), commit_c.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -1561,7 +1495,7 @@ fn test_rebase_descendants_update_checkout_abandoned_merge() {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
tx.repo_mut().record_abandoned_commit(commit_d.id().clone());
|
||||
tx.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx.repo_mut().rebase_descendants().unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let new_checkout_id = repo.view().get_wc_commit_id(&workspace_id).unwrap();
|
||||
|
@ -1576,7 +1510,6 @@ fn test_rebase_descendants_update_checkout_abandoned_merge() {
|
|||
#[test_case(EmptyBehaviour::AbandonNewlyEmpty; "abandon newly empty commits")]
|
||||
#[test_case(EmptyBehaviour::AbandonAllEmpty ; "abandon all empty commits")]
|
||||
fn test_empty_commit_option(empty_behavior: EmptyBehaviour) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1612,10 +1545,10 @@ fn test_empty_commit_option(empty_behavior: EmptyBehaviour) {
|
|||
let tree_f = create_fixed_tree(&["B", "C", "D"]);
|
||||
let tree_g = create_fixed_tree(&["B", "C", "D", "G"]);
|
||||
|
||||
let commit_a = create_random_commit(mut_repo, &settings).write().unwrap();
|
||||
let commit_a = create_random_commit(mut_repo).write().unwrap();
|
||||
|
||||
let mut create_commit = |parents: &[&Commit], tree: &MergedTree| {
|
||||
create_random_commit(mut_repo, &settings)
|
||||
create_random_commit(mut_repo)
|
||||
.set_parents(
|
||||
parents
|
||||
.iter()
|
||||
|
@ -1639,13 +1572,10 @@ fn test_empty_commit_option(empty_behavior: EmptyBehaviour) {
|
|||
.set_rewritten_commit(commit_b.id().clone(), commit_bd.id().clone());
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(
|
||||
&settings,
|
||||
RebaseOptions {
|
||||
empty: empty_behavior,
|
||||
simplify_ancestor_merge: true,
|
||||
},
|
||||
)
|
||||
.rebase_descendants_with_options_return_map(RebaseOptions {
|
||||
empty: empty_behavior,
|
||||
simplify_ancestor_merge: true,
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let new_head = match empty_behavior {
|
||||
|
@ -1716,7 +1646,6 @@ fn test_empty_commit_option(empty_behavior: EmptyBehaviour) {
|
|||
|
||||
#[test]
|
||||
fn test_rebase_abandoning_empty() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -1736,35 +1665,35 @@ fn test_rebase_abandoning_empty() {
|
|||
// A A
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_b = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let commit_b = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_c = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_b.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_d = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_d = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_c.id().clone()])
|
||||
.set_tree_id(commit_c.tree_id().clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_e = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_e = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_c.id().clone()])
|
||||
.set_tree_id(commit_c.tree_id().clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_b2 = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_b2 = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.set_tree_id(commit_b.tree_id().clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_f = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_f = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_e.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_g = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_g = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_e.id().clone()])
|
||||
.set_tree_id(commit_e.tree_id().clone())
|
||||
.write()
|
||||
|
@ -1780,10 +1709,10 @@ fn test_rebase_abandoning_empty() {
|
|||
simplify_ancestor_merge: true,
|
||||
};
|
||||
let rewriter = CommitRewriter::new(tx.repo_mut(), commit_b, vec![commit_b2.id().clone()]);
|
||||
rebase_commit_with_options(&settings, rewriter, &rebase_options).unwrap();
|
||||
rebase_commit_with_options(rewriter, &rebase_options).unwrap();
|
||||
let rebase_map = tx
|
||||
.repo_mut()
|
||||
.rebase_descendants_with_options_return_map(&settings, rebase_options)
|
||||
.rebase_descendants_with_options_return_map(rebase_options)
|
||||
.unwrap();
|
||||
assert_eq!(rebase_map.len(), 5);
|
||||
let new_commit_c =
|
||||
|
|
|
@ -23,7 +23,6 @@ use testutils::TestRepo;
|
|||
|
||||
#[test]
|
||||
fn test_duplicate_linear_contents() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -43,7 +42,6 @@ fn test_duplicate_linear_contents() {
|
|||
let commit_a = tx
|
||||
.repo_mut()
|
||||
.new_commit(
|
||||
&settings,
|
||||
vec![repo.store().root_commit_id().clone()],
|
||||
empty_tree_id.clone(),
|
||||
)
|
||||
|
@ -51,22 +49,22 @@ fn test_duplicate_linear_contents() {
|
|||
.unwrap();
|
||||
let commit_b = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_a.id().clone()], tree_1.id())
|
||||
.new_commit(vec![commit_a.id().clone()], tree_1.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_c = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_b.id().clone()], tree_1_2.id())
|
||||
.new_commit(vec![commit_b.id().clone()], tree_1_2.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_d = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_c.id().clone()], tree_2.id())
|
||||
.new_commit(vec![commit_c.id().clone()], tree_2.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit_e = tx
|
||||
.repo_mut()
|
||||
.new_commit(&settings, vec![commit_d.id().clone()], tree_2.id())
|
||||
.new_commit(vec![commit_d.id().clone()], tree_2.id())
|
||||
.write()
|
||||
.unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
@ -76,7 +74,6 @@ fn test_duplicate_linear_contents() {
|
|||
parent_commit_ids: &[&CommitId],
|
||||
children_commit_ids: &[&CommitId]| {
|
||||
duplicate_commits(
|
||||
&settings,
|
||||
tx.repo_mut(),
|
||||
&target_commits.iter().copied().cloned().collect_vec(),
|
||||
&parent_commit_ids.iter().copied().cloned().collect_vec(),
|
||||
|
|
|
@ -32,12 +32,11 @@ use testutils::TestRepo;
|
|||
// A
|
||||
#[test]
|
||||
fn test_transform_descendants_sync() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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]);
|
||||
|
@ -48,13 +47,13 @@ fn test_transform_descendants_sync() {
|
|||
|
||||
let mut rebased = HashMap::new();
|
||||
tx.repo_mut()
|
||||
.transform_descendants(&settings, vec![commit_b.id().clone()], |mut rewriter| {
|
||||
.transform_descendants(vec![commit_b.id().clone()], |mut rewriter| {
|
||||
rewriter.replace_parent(commit_a.id(), [commit_g.id()]);
|
||||
if *rewriter.old_commit() == commit_c {
|
||||
rewriter.abandon();
|
||||
} else {
|
||||
let old_commit_id = rewriter.old_commit().id().clone();
|
||||
let new_commit = rewriter.rebase(&settings)?.write()?;
|
||||
let new_commit = rewriter.rebase()?.write()?;
|
||||
rebased.insert(old_commit_id, new_commit);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -90,22 +89,21 @@ fn test_transform_descendants_sync() {
|
|||
// A
|
||||
#[test]
|
||||
fn test_transform_descendants_sync_linearize_merge() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
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, &commit_b]);
|
||||
|
||||
let mut rebased = HashMap::new();
|
||||
tx.repo_mut()
|
||||
.transform_descendants(&settings, vec![commit_c.id().clone()], |mut rewriter| {
|
||||
.transform_descendants(vec![commit_c.id().clone()], |mut rewriter| {
|
||||
rewriter.replace_parent(commit_a.id(), [commit_b.id()]);
|
||||
let old_commit_id = rewriter.old_commit().id().clone();
|
||||
let new_commit = rewriter.rebase(&settings)?.write()?;
|
||||
let new_commit = rewriter.rebase()?.write()?;
|
||||
rebased.insert(old_commit_id, new_commit);
|
||||
Ok(())
|
||||
})
|
||||
|
|
|
@ -62,14 +62,13 @@ fn manual(backend: TestRepoBackend) {
|
|||
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let settings = settings.clone();
|
||||
let repo = repo.clone();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit1 = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit1 = create_random_commit(tx.repo_mut())
|
||||
.set_sign_behavior(SignBehavior::Own)
|
||||
.write()
|
||||
.unwrap();
|
||||
let commit2 = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit2 = create_random_commit(tx.repo_mut())
|
||||
.set_sign_behavior(SignBehavior::Own)
|
||||
.set_author(someone_else())
|
||||
.write()
|
||||
|
@ -92,10 +91,9 @@ fn keep_on_rewrite(backend: TestRepoBackend) {
|
|||
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let settings = settings.clone();
|
||||
let repo = repo.clone();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit = create_random_commit(tx.repo_mut())
|
||||
.set_sign_behavior(SignBehavior::Own)
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -103,7 +101,7 @@ fn keep_on_rewrite(backend: TestRepoBackend) {
|
|||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let rewritten = mut_repo.rewrite_commit(&settings, &commit).write().unwrap();
|
||||
let rewritten = mut_repo.rewrite_commit(&commit).write().unwrap();
|
||||
|
||||
let commit = repo.store().get_commit(rewritten.id()).unwrap();
|
||||
assert_eq!(commit.verification().unwrap(), good_verification());
|
||||
|
@ -118,10 +116,9 @@ fn manual_drop_on_rewrite(backend: TestRepoBackend) {
|
|||
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let settings = settings.clone();
|
||||
let repo = repo.clone();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit = create_random_commit(tx.repo_mut())
|
||||
.set_sign_behavior(SignBehavior::Own)
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -130,7 +127,7 @@ fn manual_drop_on_rewrite(backend: TestRepoBackend) {
|
|||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let rewritten = mut_repo
|
||||
.rewrite_commit(&settings, &commit)
|
||||
.rewrite_commit(&commit)
|
||||
.set_sign_behavior(SignBehavior::Drop)
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -148,10 +145,9 @@ fn forced(backend: TestRepoBackend) {
|
|||
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let settings = settings.clone();
|
||||
let repo = repo.clone();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit = create_random_commit(tx.repo_mut())
|
||||
.set_sign_behavior(SignBehavior::Force)
|
||||
.set_author(someone_else())
|
||||
.write()
|
||||
|
@ -171,10 +167,9 @@ fn configured(backend: TestRepoBackend) {
|
|||
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let settings = settings.clone();
|
||||
let repo = repo.clone();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit = write_random_commit(tx.repo_mut());
|
||||
tx.commit("test").unwrap();
|
||||
|
||||
let commit = repo.store().get_commit(commit.id()).unwrap();
|
||||
|
|
|
@ -42,12 +42,11 @@ fn test_heads_empty() {
|
|||
|
||||
#[test]
|
||||
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();
|
||||
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let initial = graph_builder.initial_commit();
|
||||
let child1 = graph_builder.commit_with_parents(&[&initial]);
|
||||
let child2 = graph_builder.commit_with_parents(&[&initial]);
|
||||
|
@ -64,12 +63,11 @@ fn test_heads_fork() {
|
|||
|
||||
#[test]
|
||||
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();
|
||||
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.repo_mut());
|
||||
let mut graph_builder = CommitGraphBuilder::new(tx.repo_mut());
|
||||
let initial = graph_builder.initial_commit();
|
||||
let child1 = graph_builder.commit_with_parents(&[&initial]);
|
||||
let child2 = graph_builder.commit_with_parents(&[&initial]);
|
||||
|
@ -82,26 +80,25 @@ fn test_heads_merge() {
|
|||
#[test]
|
||||
fn test_merge_views_heads() {
|
||||
// Tests merging of the view's heads (by performing divergent operations).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let head_unchanged = write_random_commit(mut_repo, &settings);
|
||||
let head_remove_tx1 = write_random_commit(mut_repo, &settings);
|
||||
let head_remove_tx2 = write_random_commit(mut_repo, &settings);
|
||||
let head_unchanged = write_random_commit(mut_repo);
|
||||
let head_remove_tx1 = write_random_commit(mut_repo);
|
||||
let head_remove_tx2 = write_random_commit(mut_repo);
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
tx1.repo_mut().remove_head(head_remove_tx1.id());
|
||||
let head_add_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let head_add_tx1 = write_random_commit(tx1.repo_mut());
|
||||
|
||||
let mut tx2 = repo.start_transaction();
|
||||
tx2.repo_mut().remove_head(head_remove_tx2.id());
|
||||
let head_add_tx2 = write_random_commit(tx2.repo_mut(), &settings);
|
||||
let head_add_tx2 = write_random_commit(tx2.repo_mut());
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
|
||||
let expected_heads = hashset! {
|
||||
head_unchanged.id().clone(),
|
||||
|
@ -114,7 +111,6 @@ fn test_merge_views_heads() {
|
|||
#[test]
|
||||
fn test_merge_views_checkout() {
|
||||
// Tests merging of the view's checkout (by performing divergent operations).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
|
@ -126,9 +122,9 @@ fn test_merge_views_checkout() {
|
|||
// Workspace 6 gets added in tx1.
|
||||
// Workspace 7 gets added in tx2.
|
||||
let mut initial_tx = repo.start_transaction();
|
||||
let commit1 = write_random_commit(initial_tx.repo_mut(), &settings);
|
||||
let commit2 = write_random_commit(initial_tx.repo_mut(), &settings);
|
||||
let commit3 = write_random_commit(initial_tx.repo_mut(), &settings);
|
||||
let commit1 = write_random_commit(initial_tx.repo_mut());
|
||||
let commit2 = write_random_commit(initial_tx.repo_mut());
|
||||
let commit3 = write_random_commit(initial_tx.repo_mut());
|
||||
let ws1_id = WorkspaceId::new("ws1".to_string());
|
||||
let ws2_id = WorkspaceId::new("ws2".to_string());
|
||||
let ws3_id = WorkspaceId::new("ws3".to_string());
|
||||
|
@ -188,7 +184,7 @@ fn test_merge_views_checkout() {
|
|||
.set_wc_commit(ws7_id.clone(), commit3.id().clone())
|
||||
.unwrap();
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
|
||||
// We currently arbitrarily pick the first transaction's working-copy commit
|
||||
// (first by transaction end time).
|
||||
|
@ -205,15 +201,14 @@ fn test_merge_views_checkout() {
|
|||
fn test_merge_views_bookmarks() {
|
||||
// Tests merging of bookmarks (by performing concurrent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let main_bookmark_local_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let main_bookmark_origin_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let main_bookmark_alternate_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let main_bookmark_local_tx0 = write_random_commit(mut_repo);
|
||||
let main_bookmark_origin_tx0 = write_random_commit(mut_repo);
|
||||
let main_bookmark_alternate_tx0 = write_random_commit(mut_repo);
|
||||
let main_bookmark_origin_tx0_remote_ref = RemoteRef {
|
||||
target: RefTarget::normal(main_bookmark_origin_tx0.id().clone()),
|
||||
state: RemoteRefState::New,
|
||||
|
@ -232,7 +227,7 @@ fn test_merge_views_bookmarks() {
|
|||
"alternate",
|
||||
main_bookmark_alternate_tx0_remote_ref.clone(),
|
||||
);
|
||||
let feature_bookmark_local_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let feature_bookmark_local_tx0 = write_random_commit(mut_repo);
|
||||
mut_repo.set_local_bookmark_target(
|
||||
"feature",
|
||||
RefTarget::normal(feature_bookmark_local_tx0.id().clone()),
|
||||
|
@ -240,20 +235,20 @@ fn test_merge_views_bookmarks() {
|
|||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let main_bookmark_local_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let main_bookmark_local_tx1 = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut().set_local_bookmark_target(
|
||||
"main",
|
||||
RefTarget::normal(main_bookmark_local_tx1.id().clone()),
|
||||
);
|
||||
let feature_bookmark_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let feature_bookmark_tx1 = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut().set_local_bookmark_target(
|
||||
"feature",
|
||||
RefTarget::normal(feature_bookmark_tx1.id().clone()),
|
||||
);
|
||||
|
||||
let mut tx2 = repo.start_transaction();
|
||||
let main_bookmark_local_tx2 = write_random_commit(tx2.repo_mut(), &settings);
|
||||
let main_bookmark_origin_tx2 = write_random_commit(tx2.repo_mut(), &settings);
|
||||
let main_bookmark_local_tx2 = write_random_commit(tx2.repo_mut());
|
||||
let main_bookmark_origin_tx2 = write_random_commit(tx2.repo_mut());
|
||||
let main_bookmark_origin_tx2_remote_ref = RemoteRef {
|
||||
target: RefTarget::normal(main_bookmark_origin_tx2.id().clone()),
|
||||
state: RemoteRefState::Tracking,
|
||||
|
@ -268,7 +263,7 @@ fn test_merge_views_bookmarks() {
|
|||
main_bookmark_origin_tx2_remote_ref.clone(),
|
||||
);
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
let expected_main_bookmark = BookmarkTarget {
|
||||
local_target: &RefTarget::from_legacy_form(
|
||||
[main_bookmark_local_tx0.id().clone()],
|
||||
|
@ -300,32 +295,31 @@ fn test_merge_views_bookmarks() {
|
|||
fn test_merge_views_tags() {
|
||||
// Tests merging of tags (by performing divergent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let v1_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let v1_tx0 = write_random_commit(mut_repo);
|
||||
mut_repo.set_tag_target("v1.0", RefTarget::normal(v1_tx0.id().clone()));
|
||||
let v2_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let v2_tx0 = write_random_commit(mut_repo);
|
||||
mut_repo.set_tag_target("v2.0", RefTarget::normal(v2_tx0.id().clone()));
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let v1_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let v1_tx1 = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut()
|
||||
.set_tag_target("v1.0", RefTarget::normal(v1_tx1.id().clone()));
|
||||
let v2_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let v2_tx1 = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut()
|
||||
.set_tag_target("v2.0", RefTarget::normal(v2_tx1.id().clone()));
|
||||
|
||||
let mut tx2 = repo.start_transaction();
|
||||
let v1_tx2 = write_random_commit(tx2.repo_mut(), &settings);
|
||||
let v1_tx2 = write_random_commit(tx2.repo_mut());
|
||||
tx2.repo_mut()
|
||||
.set_tag_target("v1.0", RefTarget::normal(v1_tx2.id().clone()));
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
let expected_v1 = RefTarget::from_legacy_form(
|
||||
[v1_tx0.id().clone()],
|
||||
[v1_tx1.id().clone(), v1_tx2.id().clone()],
|
||||
|
@ -344,18 +338,17 @@ fn test_merge_views_tags() {
|
|||
fn test_merge_views_git_refs() {
|
||||
// Tests merging of git refs (by performing divergent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction();
|
||||
let mut_repo = tx.repo_mut();
|
||||
let main_bookmark_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let main_bookmark_tx0 = write_random_commit(mut_repo);
|
||||
mut_repo.set_git_ref_target(
|
||||
"refs/heads/main",
|
||||
RefTarget::normal(main_bookmark_tx0.id().clone()),
|
||||
);
|
||||
let feature_bookmark_tx0 = write_random_commit(mut_repo, &settings);
|
||||
let feature_bookmark_tx0 = write_random_commit(mut_repo);
|
||||
mut_repo.set_git_ref_target(
|
||||
"refs/heads/feature",
|
||||
RefTarget::normal(feature_bookmark_tx0.id().clone()),
|
||||
|
@ -363,25 +356,25 @@ fn test_merge_views_git_refs() {
|
|||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let main_bookmark_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let main_bookmark_tx1 = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut().set_git_ref_target(
|
||||
"refs/heads/main",
|
||||
RefTarget::normal(main_bookmark_tx1.id().clone()),
|
||||
);
|
||||
let feature_bookmark_tx1 = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let feature_bookmark_tx1 = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut().set_git_ref_target(
|
||||
"refs/heads/feature",
|
||||
RefTarget::normal(feature_bookmark_tx1.id().clone()),
|
||||
);
|
||||
|
||||
let mut tx2 = repo.start_transaction();
|
||||
let main_bookmark_tx2 = write_random_commit(tx2.repo_mut(), &settings);
|
||||
let main_bookmark_tx2 = write_random_commit(tx2.repo_mut());
|
||||
tx2.repo_mut().set_git_ref_target(
|
||||
"refs/heads/main",
|
||||
RefTarget::normal(main_bookmark_tx2.id().clone()),
|
||||
);
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
let expected_main_bookmark = RefTarget::from_legacy_form(
|
||||
[main_bookmark_tx0.id().clone()],
|
||||
[
|
||||
|
@ -403,27 +396,26 @@ fn test_merge_views_git_refs() {
|
|||
fn test_merge_views_git_heads() {
|
||||
// Tests merging of git heads (by performing divergent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx0 = repo.start_transaction();
|
||||
let tx0_head = write_random_commit(tx0.repo_mut(), &settings);
|
||||
let tx0_head = write_random_commit(tx0.repo_mut());
|
||||
tx0.repo_mut()
|
||||
.set_git_head_target(RefTarget::normal(tx0_head.id().clone()));
|
||||
let repo = tx0.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let tx1_head = write_random_commit(tx1.repo_mut(), &settings);
|
||||
let tx1_head = write_random_commit(tx1.repo_mut());
|
||||
tx1.repo_mut()
|
||||
.set_git_head_target(RefTarget::normal(tx1_head.id().clone()));
|
||||
|
||||
let mut tx2 = repo.start_transaction();
|
||||
let tx2_head = write_random_commit(tx2.repo_mut(), &settings);
|
||||
let tx2_head = write_random_commit(tx2.repo_mut());
|
||||
tx2.repo_mut()
|
||||
.set_git_head_target(RefTarget::normal(tx2_head.id().clone()));
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
let expected_git_head = RefTarget::from_legacy_form(
|
||||
[tx0_head.id().clone()],
|
||||
[tx1_head.id().clone(), tx2_head.id().clone()],
|
||||
|
@ -435,32 +427,31 @@ fn test_merge_views_git_heads() {
|
|||
fn test_merge_views_divergent() {
|
||||
// We start with just commit A. Operation 1 rewrites it as A2. Operation 2
|
||||
// rewrites it as A3.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let commit_a2 = tx1
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_a)
|
||||
.rewrite_commit(&commit_a)
|
||||
.set_description("A2")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx1.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx1.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let mut tx2 = repo.start_transaction();
|
||||
let commit_a3 = tx2
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_a)
|
||||
.rewrite_commit(&commit_a)
|
||||
.set_description("A3")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx2.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx2.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let repo = commit_transactions(&settings, vec![tx1, tx2]);
|
||||
let repo = commit_transactions(vec![tx1, tx2]);
|
||||
|
||||
// A2 and A3 should be heads.
|
||||
assert_eq!(
|
||||
|
@ -474,15 +465,14 @@ fn test_merge_views_divergent() {
|
|||
fn test_merge_views_child_on_rewritten(child_first: bool) {
|
||||
// We start with just commit A. Operation 1 adds commit B on top. Operation 2
|
||||
// rewrites A as A2.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let commit_b = create_random_commit(tx1.repo_mut(), &settings)
|
||||
let commit_b = create_random_commit(tx1.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -490,16 +480,16 @@ fn test_merge_views_child_on_rewritten(child_first: bool) {
|
|||
let mut tx2 = repo.start_transaction();
|
||||
let commit_a2 = tx2
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_a)
|
||||
.rewrite_commit(&commit_a)
|
||||
.set_description("A2")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx2.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx2.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let repo = if child_first {
|
||||
commit_transactions(&settings, vec![tx1, tx2])
|
||||
commit_transactions(vec![tx1, tx2])
|
||||
} else {
|
||||
commit_transactions(&settings, vec![tx2, tx1])
|
||||
commit_transactions(vec![tx2, tx1])
|
||||
};
|
||||
|
||||
// A new B2 commit (B rebased onto A2) should be the only head.
|
||||
|
@ -520,12 +510,11 @@ fn test_merge_views_child_on_rewritten_divergent(on_rewritten: bool, child_first
|
|||
// of A2 or A3. Operation 2 rewrites A2 as A4. The result should be that B
|
||||
// gets rebased onto A4 if it was based on A2 before, but if it was based on
|
||||
// A3, it should remain there.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction();
|
||||
let commit_a2 = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_a3 = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_a2 = write_random_commit(tx.repo_mut());
|
||||
let commit_a3 = create_random_commit(tx.repo_mut())
|
||||
.set_change_id(commit_a2.change_id().clone())
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -533,7 +522,7 @@ fn test_merge_views_child_on_rewritten_divergent(on_rewritten: bool, child_first
|
|||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let parent = if on_rewritten { &commit_a2 } else { &commit_a3 };
|
||||
let commit_b = create_random_commit(tx1.repo_mut(), &settings)
|
||||
let commit_b = create_random_commit(tx1.repo_mut())
|
||||
.set_parents(vec![parent.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -541,16 +530,16 @@ fn test_merge_views_child_on_rewritten_divergent(on_rewritten: bool, child_first
|
|||
let mut tx2 = repo.start_transaction();
|
||||
let commit_a4 = tx2
|
||||
.repo_mut()
|
||||
.rewrite_commit(&settings, &commit_a2)
|
||||
.rewrite_commit(&commit_a2)
|
||||
.set_description("A4")
|
||||
.write()
|
||||
.unwrap();
|
||||
tx2.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx2.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let repo = if child_first {
|
||||
commit_transactions(&settings, vec![tx1, tx2])
|
||||
commit_transactions(vec![tx1, tx2])
|
||||
} else {
|
||||
commit_transactions(&settings, vec![tx2, tx1])
|
||||
commit_transactions(vec![tx2, tx1])
|
||||
};
|
||||
|
||||
if on_rewritten {
|
||||
|
@ -576,19 +565,18 @@ fn test_merge_views_child_on_rewritten_divergent(on_rewritten: bool, child_first
|
|||
fn test_merge_views_child_on_abandoned(child_first: bool) {
|
||||
// We start with commit B on top of commit A. Operation 1 adds commit C on top.
|
||||
// Operation 2 abandons B.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction();
|
||||
let commit_a = write_random_commit(tx.repo_mut(), &settings);
|
||||
let commit_b = create_random_commit(tx.repo_mut(), &settings)
|
||||
let commit_a = write_random_commit(tx.repo_mut());
|
||||
let commit_b = create_random_commit(tx.repo_mut())
|
||||
.set_parents(vec![commit_a.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
let repo = tx.commit("test").unwrap();
|
||||
|
||||
let mut tx1 = repo.start_transaction();
|
||||
let commit_c = create_random_commit(tx1.repo_mut(), &settings)
|
||||
let commit_c = create_random_commit(tx1.repo_mut())
|
||||
.set_parents(vec![commit_b.id().clone()])
|
||||
.write()
|
||||
.unwrap();
|
||||
|
@ -596,12 +584,12 @@ fn test_merge_views_child_on_abandoned(child_first: bool) {
|
|||
let mut tx2 = repo.start_transaction();
|
||||
tx2.repo_mut()
|
||||
.record_abandoned_commit(commit_b.id().clone());
|
||||
tx2.repo_mut().rebase_descendants(&settings).unwrap();
|
||||
tx2.repo_mut().rebase_descendants().unwrap();
|
||||
|
||||
let repo = if child_first {
|
||||
commit_transactions(&settings, vec![tx1, tx2])
|
||||
commit_transactions(vec![tx1, tx2])
|
||||
} else {
|
||||
commit_transactions(&settings, vec![tx2, tx1])
|
||||
commit_transactions(vec![tx2, tx1])
|
||||
};
|
||||
|
||||
// A new C2 commit (C rebased onto A) should be the only head.
|
||||
|
|
|
@ -52,7 +52,6 @@ fn test_init_additional_workspace() {
|
|||
let ws2_root = test_workspace.root_dir().join("ws2_root");
|
||||
std::fs::create_dir(&ws2_root).unwrap();
|
||||
let (ws2, repo) = Workspace::init_workspace_with_existing_repo(
|
||||
&settings,
|
||||
&ws2_root,
|
||||
test_workspace.repo_path(),
|
||||
&test_workspace.repo,
|
||||
|
|
|
@ -166,7 +166,7 @@ impl TestEnvironment {
|
|||
) -> Arc<ReadonlyRepo> {
|
||||
RepoLoader::init_from_file_system(settings, repo_path, &self.default_store_factories())
|
||||
.unwrap()
|
||||
.load_at_head(settings)
|
||||
.load_at_head()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -318,14 +318,14 @@ impl TestWorkspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn commit_transactions(settings: &UserSettings, txs: Vec<Transaction>) -> Arc<ReadonlyRepo> {
|
||||
pub fn commit_transactions(txs: Vec<Transaction>) -> Arc<ReadonlyRepo> {
|
||||
let repo_loader = txs[0].base_repo().loader().clone();
|
||||
let mut op_ids = vec![];
|
||||
for tx in txs {
|
||||
op_ids.push(tx.commit("test").unwrap().op_id().clone());
|
||||
std::thread::sleep(std::time::Duration::from_millis(1));
|
||||
}
|
||||
let repo = repo_loader.load_at_head(settings).unwrap();
|
||||
let repo = repo_loader.load_at_head().unwrap();
|
||||
// Test the setup. The assumption here is that the parent order matches the
|
||||
// order in which they were merged (which currently matches the transaction
|
||||
// commit order), so we want to know make sure they appear in a certain
|
||||
|
@ -406,18 +406,11 @@ pub fn create_random_tree(repo: &Arc<ReadonlyRepo>) -> MergedTreeId {
|
|||
create_tree(repo, &[(&path, "contents")]).id()
|
||||
}
|
||||
|
||||
pub fn create_random_commit<'repo>(
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
settings: &UserSettings,
|
||||
) -> CommitBuilder<'repo> {
|
||||
pub fn create_random_commit(mut_repo: &mut MutableRepo) -> CommitBuilder<'_> {
|
||||
let tree_id = create_random_tree(mut_repo.base_repo());
|
||||
let number = rand::random::<u32>();
|
||||
mut_repo
|
||||
.new_commit(
|
||||
settings,
|
||||
vec![mut_repo.store().root_commit_id().clone()],
|
||||
tree_id,
|
||||
)
|
||||
.new_commit(vec![mut_repo.store().root_commit_id().clone()], tree_id)
|
||||
.set_description(format!("random commit {number}"))
|
||||
}
|
||||
|
||||
|
@ -478,8 +471,8 @@ pub fn dump_tree(store: &Arc<Store>, tree_id: &MergedTreeId) -> String {
|
|||
buf
|
||||
}
|
||||
|
||||
pub fn write_random_commit(mut_repo: &mut MutableRepo, settings: &UserSettings) -> Commit {
|
||||
create_random_commit(mut_repo, settings).write().unwrap()
|
||||
pub fn write_random_commit(mut_repo: &mut MutableRepo) -> Commit {
|
||||
create_random_commit(mut_repo).write().unwrap()
|
||||
}
|
||||
|
||||
pub fn write_working_copy_file(workspace_root: &Path, path: &RepoPath, contents: &str) {
|
||||
|
@ -496,21 +489,17 @@ pub fn write_working_copy_file(workspace_root: &Path, path: &RepoPath, contents:
|
|||
file.write_all(contents.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
pub struct CommitGraphBuilder<'settings, 'repo> {
|
||||
settings: &'settings UserSettings,
|
||||
pub struct CommitGraphBuilder<'repo> {
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
}
|
||||
|
||||
impl<'settings, 'repo> CommitGraphBuilder<'settings, 'repo> {
|
||||
pub fn new(
|
||||
settings: &'settings UserSettings,
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
) -> CommitGraphBuilder<'settings, 'repo> {
|
||||
CommitGraphBuilder { settings, mut_repo }
|
||||
impl<'repo> CommitGraphBuilder<'repo> {
|
||||
pub fn new(mut_repo: &'repo mut MutableRepo) -> Self {
|
||||
CommitGraphBuilder { mut_repo }
|
||||
}
|
||||
|
||||
pub fn initial_commit(&mut self) -> Commit {
|
||||
write_random_commit(self.mut_repo, self.settings)
|
||||
write_random_commit(self.mut_repo)
|
||||
}
|
||||
|
||||
pub fn commit_with_parents(&mut self, parents: &[&Commit]) -> Commit {
|
||||
|
@ -518,7 +507,7 @@ impl<'settings, 'repo> CommitGraphBuilder<'settings, 'repo> {
|
|||
.iter()
|
||||
.map(|commit| commit.id().clone())
|
||||
.collect_vec();
|
||||
create_random_commit(self.mut_repo, self.settings)
|
||||
create_random_commit(self.mut_repo)
|
||||
.set_parents(parent_ids)
|
||||
.write()
|
||||
.unwrap()
|
||||
|
|
Loading…
Reference in a new issue