Skip to content

Commit

Permalink
creating new wc commit when @ becomes immuable
Browse files Browse the repository at this point in the history
  • Loading branch information
tdaron committed Apr 30, 2024
1 parent e54e83b commit 0c1c5e5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use jj_lib::revset::{
RevsetAliasesMap, RevsetExpression, RevsetExtensions, RevsetFilterPredicate, RevsetIteratorExt,
RevsetModifier, RevsetParseContext, RevsetWorkspaceContext, SymbolResolverExtension,
};
use jj_lib::rewrite::restore_tree;
use jj_lib::rewrite::{merge_commit_trees, restore_tree};
use jj_lib::settings::{ConfigResultExt as _, UserSettings};
use jj_lib::signing::SignInitError;
use jj_lib::str_util::StringPattern;
Expand Down Expand Up @@ -1280,7 +1280,6 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin
if num_rebased > 0 {
writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?;
}

let old_repo = tx.base_repo().clone();

let maybe_old_wc_commit = old_repo
Expand All @@ -1304,10 +1303,23 @@ See https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#stale-workin
}
self.user_repo = ReadonlyUserRepo::new(tx.commit(description));
self.report_repo_changes(ui, &old_repo)?;

if self.may_update_working_copy {
if let Some(new_commit) = &maybe_new_wc_commit {
self.update_working_copy(ui, maybe_old_wc_commit.as_ref(), new_commit)?;
self.update_working_copy(ui, maybe_old_wc_commit.as_ref(), &new_commit)?;
println!("{:?}", new_commit.id());
if self.check_rewritable([new_commit.id()]).is_err() {
let settings = self.settings.clone();
let mut tx = self.start_transaction();
let _top_commit = tx
.mut_repo()
.new_commit(
&settings,
vec![new_commit.id().clone()],
new_commit.tree_id().clone(),
)
.write()?;
tx.finish(ui, "added mutable commit to avoid @ immutable.")?;
}
} else {
// It seems the workspace was deleted, so we shouldn't try to
// update it.
Expand Down

0 comments on commit 0c1c5e5

Please sign in to comment.