forked from mirrors/jj
Make a minor simplification to CommitBuilder::write
There's no need to have a block of code at the beginning of the function to cache the rewrite source id. We can simply check the necessary condition before calling record_rewritten_commit. This tweak makes the function a little easier to read since we don't check the condition until we're ready to do the work.
This commit is contained in:
parent
276276ea01
commit
b8aa9a1a2b
1 changed files with 5 additions and 10 deletions
|
@ -178,13 +178,6 @@ impl CommitBuilder<'_> {
|
|||
}
|
||||
|
||||
pub fn write(mut self) -> BackendResult<Commit> {
|
||||
let mut rewrite_source_id = None;
|
||||
if let Some(rewrite_source) = self.rewrite_source {
|
||||
if *rewrite_source.change_id() == self.commit.change_id {
|
||||
rewrite_source_id.replace(rewrite_source.id().clone());
|
||||
}
|
||||
}
|
||||
|
||||
let sign_settings = &self.sign_settings;
|
||||
let store = self.mut_repo.store();
|
||||
|
||||
|
@ -202,9 +195,11 @@ impl CommitBuilder<'_> {
|
|||
let commit = self
|
||||
.mut_repo
|
||||
.write_commit(self.commit, signing_fn.as_deref_mut())?;
|
||||
if let Some(rewrite_source_id) = rewrite_source_id {
|
||||
self.mut_repo
|
||||
.record_rewritten_commit(rewrite_source_id, commit.id().clone())
|
||||
if let Some(rewrite_source) = self.rewrite_source {
|
||||
if rewrite_source.change_id() == commit.change_id() {
|
||||
self.mut_repo
|
||||
.record_rewritten_commit(rewrite_source.id().clone(), commit.id().clone());
|
||||
}
|
||||
}
|
||||
Ok(commit)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue