forked from mirrors/jj
cleanup: avoid some unnecessary uses of mutable repo reference
This commit is contained in:
parent
5bae3eaa74
commit
5fbc819fc1
7 changed files with 16 additions and 20 deletions
|
@ -698,7 +698,7 @@ impl WorkspaceCommandHelper {
|
|||
let command = self.command.clone();
|
||||
let mut tx = self.start_transaction();
|
||||
git::import_head(tx.mut_repo())?;
|
||||
if !tx.mut_repo().has_changes() {
|
||||
if !tx.repo().has_changes() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -714,10 +714,10 @@ impl WorkspaceCommandHelper {
|
|||
|
||||
let mut tx = tx.into_inner();
|
||||
let old_git_head = self.repo().view().git_head().clone();
|
||||
let new_git_head = tx.mut_repo().view().git_head().clone();
|
||||
let new_git_head = tx.repo().view().git_head().clone();
|
||||
if let Some(new_git_head_id) = new_git_head.as_normal() {
|
||||
let workspace_id = self.workspace_id().to_owned();
|
||||
let new_git_head_commit = tx.mut_repo().store().get_commit(new_git_head_id)?;
|
||||
let new_git_head_commit = tx.repo().store().get_commit(new_git_head_id)?;
|
||||
tx.mut_repo()
|
||||
.check_out(workspace_id, command.settings(), &new_git_head_commit)?;
|
||||
let mut locked_ws = self.workspace.start_working_copy_mutation()?;
|
||||
|
@ -759,7 +759,7 @@ impl WorkspaceCommandHelper {
|
|||
let stats = git::import_some_refs(tx.mut_repo(), &git_settings, |ref_name| {
|
||||
!git::is_reserved_git_remote_ref(ref_name)
|
||||
})?;
|
||||
if !tx.mut_repo().has_changes() {
|
||||
if !tx.repo().has_changes() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -1463,7 +1463,7 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
mut tx: Transaction,
|
||||
description: impl Into<String>,
|
||||
) -> Result<(), CommandError> {
|
||||
if !tx.mut_repo().has_changes() {
|
||||
if !tx.repo().has_changes() {
|
||||
writeln!(ui.status(), "Nothing changed.")?;
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -1472,8 +1472,7 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \
|
|||
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?;
|
||||
}
|
||||
|
||||
for (workspace_id, wc_commit_id) in
|
||||
tx.mut_repo().view().wc_commit_ids().clone().iter().sorted()
|
||||
for (workspace_id, wc_commit_id) in tx.repo().view().wc_commit_ids().clone().iter().sorted()
|
||||
//sorting otherwise non deterministic order (bad for tests)
|
||||
{
|
||||
if self
|
||||
|
|
|
@ -65,7 +65,7 @@ pub(crate) fn cmd_backout(
|
|||
to_back_out.len() - 1
|
||||
)
|
||||
};
|
||||
let mut new_base_tree = merge_commit_trees(tx.mut_repo(), &parents)?;
|
||||
let mut new_base_tree = merge_commit_trees(tx.repo(), &parents)?;
|
||||
for commit_to_back_out in to_back_out {
|
||||
let commit_to_back_out_subject = commit_to_back_out
|
||||
.description()
|
||||
|
@ -77,7 +77,7 @@ pub(crate) fn cmd_backout(
|
|||
commit_to_back_out_subject,
|
||||
&commit_to_back_out.id().hex()
|
||||
);
|
||||
let old_base_tree = commit_to_back_out.parent_tree(tx.mut_repo())?;
|
||||
let old_base_tree = commit_to_back_out.parent_tree(tx.repo())?;
|
||||
let old_tree = commit_to_back_out.tree()?;
|
||||
let new_tree = new_base_tree.merge(&old_tree, &old_base_tree)?;
|
||||
let new_parent_ids = parents.iter().map(|commit| commit.id().clone()).collect();
|
||||
|
|
|
@ -120,10 +120,7 @@ new working-copy commit.
|
|||
commit_builder.set_description(description);
|
||||
let new_commit = commit_builder.write(tx.mut_repo())?;
|
||||
|
||||
let workspace_ids = tx
|
||||
.mut_repo()
|
||||
.view()
|
||||
.workspaces_for_wc_commit_id(commit.id());
|
||||
let workspace_ids = tx.repo().view().workspaces_for_wc_commit_id(commit.id());
|
||||
if !workspace_ids.is_empty() {
|
||||
let new_wc_commit = tx
|
||||
.mut_repo()
|
||||
|
|
|
@ -175,11 +175,11 @@ pub fn do_init(
|
|||
if !workspace_command.working_copy_shared_with_git() {
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
jj_lib::git::import_head(tx.mut_repo())?;
|
||||
if let Some(git_head_id) = tx.mut_repo().view().git_head().as_normal().cloned() {
|
||||
let git_head_commit = tx.mut_repo().store().get_commit(&git_head_id)?;
|
||||
if let Some(git_head_id) = tx.repo().view().git_head().as_normal().cloned() {
|
||||
let git_head_commit = tx.repo().store().get_commit(&git_head_id)?;
|
||||
tx.check_out(&git_head_commit)?;
|
||||
}
|
||||
if tx.mut_repo().has_changes() {
|
||||
if tx.repo().has_changes() {
|
||||
tx.finish(ui, "import git head")?;
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ fn init_git_refs(
|
|||
// Initial import shouldn't fail because of reserved remote name.
|
||||
|ref_name| !git::is_reserved_git_remote_ref(ref_name),
|
||||
)?;
|
||||
if !tx.mut_repo().has_changes() {
|
||||
if !tx.repo().has_changes() {
|
||||
return Ok(repo);
|
||||
}
|
||||
print_git_import_stats(ui, tx.repo(), &stats, false)?;
|
||||
|
|
|
@ -37,7 +37,7 @@ pub fn cmd_git_remote_remove(
|
|||
let git_repo = get_git_repo(repo.store())?;
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
git::remove_remote(tx.mut_repo(), &git_repo, &args.remote)?;
|
||||
if tx.mut_repo().has_changes() {
|
||||
if tx.repo().has_changes() {
|
||||
tx.finish(ui, format!("remove git remote {}", &args.remote))
|
||||
} else {
|
||||
Ok(()) // Do not print "Nothing changed."
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn cmd_git_remote_rename(
|
|||
let git_repo = get_git_repo(repo.store())?;
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
git::rename_remote(tx.mut_repo(), &git_repo, &args.old, &args.new)?;
|
||||
if tx.mut_repo().has_changes() {
|
||||
if tx.repo().has_changes() {
|
||||
tx.finish(
|
||||
ui,
|
||||
format!("rename git remote {} to {}", &args.old, &args.new),
|
||||
|
|
|
@ -292,7 +292,7 @@ from the source will be moved into the destination.
|
|||
// changes will disappear.
|
||||
let rebase_map = tx.mut_repo().rebase_descendants_return_map(settings)?;
|
||||
let rebased_destination_id = rebase_map.get(destination.id()).unwrap().clone();
|
||||
rewritten_destination = tx.mut_repo().store().get_commit(&rebased_destination_id)?;
|
||||
rewritten_destination = tx.repo().store().get_commit(&rebased_destination_id)?;
|
||||
}
|
||||
// Apply the selected changes onto the destination
|
||||
let mut destination_tree = rewritten_destination.tree()?;
|
||||
|
|
Loading…
Reference in a new issue