ok/jj
1
0
Fork 0
forked from mirrors/jj

MutableView: don't require whole Commit when CommitId is enough

This commit is contained in:
Martin von Zweigbergk 2021-03-15 15:29:34 -07:00
parent b4b1de3ddc
commit 2c92fca75a
2 changed files with 13 additions and 14 deletions

View file

@ -634,7 +634,7 @@ impl<'r> MutableRepo<'r> {
.all(|parent_id| current_heads.contains(parent_id))
{
self.index.add_commit(head);
self.view.add_head(head);
self.view.add_head(head.id());
self.enforce_view_invariants();
if let Some(evolution) = self.evolution_mut() {
evolution.add_commit(head)
@ -654,20 +654,20 @@ impl<'r> MutableRepo<'r> {
for missing_commit in missing_commits.iter().rev() {
self.index.add_commit(missing_commit);
}
self.view.add_head(head);
self.view.add_head(head.id());
self.enforce_view_invariants();
self.invalidate_evolution();
}
}
pub fn remove_head(&mut self, head: &Commit) {
self.view.remove_head(head);
self.view.remove_head(head.id());
self.enforce_view_invariants();
self.invalidate_evolution();
}
pub fn add_public_head(&mut self, head: &Commit) {
self.view.add_public_head(head);
self.view.add_public_head(head.id());
self.enforce_view_invariants();
if let Some(evolution) = self.evolution_mut() {
evolution.add_commit(head)
@ -675,7 +675,7 @@ impl<'r> MutableRepo<'r> {
}
pub fn remove_public_head(&mut self, head: &Commit) {
self.view.remove_public_head(head);
self.view.remove_public_head(head.id());
self.invalidate_evolution();
}

View file

@ -15,7 +15,6 @@
use std::cmp::min;
use std::collections::{BTreeMap, HashSet};
use crate::commit::Commit;
use crate::op_store;
use crate::store::CommitId;
use crate::store_wrapper::StoreWrapper;
@ -226,20 +225,20 @@ impl MutableView {
self.data.checkout = id;
}
pub fn add_head(&mut self, head: &Commit) {
self.data.head_ids.insert(head.id().clone());
pub fn add_head(&mut self, head_id: &CommitId) {
self.data.head_ids.insert(head_id.clone());
}
pub fn remove_head(&mut self, head: &Commit) {
self.data.head_ids.remove(head.id());
pub fn remove_head(&mut self, head_id: &CommitId) {
self.data.head_ids.remove(head_id);
}
pub fn add_public_head(&mut self, head: &Commit) {
self.data.public_head_ids.insert(head.id().clone());
pub fn add_public_head(&mut self, head_id: &CommitId) {
self.data.public_head_ids.insert(head_id.clone());
}
pub fn remove_public_head(&mut self, head: &Commit) {
self.data.public_head_ids.remove(head.id());
pub fn remove_public_head(&mut self, head_id: &CommitId) {
self.data.public_head_ids.remove(head_id);
}
pub fn insert_git_ref(&mut self, name: String, commit_id: CommitId) {