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

backend: remove last few instances of MergedTreeId::as_legacy_tree_id()

This commit is contained in:
Martin von Zweigbergk 2023-08-28 13:34:30 -07:00 committed by Martin von Zweigbergk
parent 962da1947e
commit 7e6930b56f
3 changed files with 11 additions and 17 deletions

View file

@ -184,16 +184,6 @@ impl MergedTreeId {
MergedTreeId::Merge(tree_ids) => tree_ids.clone(),
}
}
/// If this is a legacy tree, gets its tree id
// TODO(#1624): delete when all callers have been updated to support tree-level
// conflicts
pub fn as_legacy_tree_id(&self) -> &TreeId {
match &self {
MergedTreeId::Legacy(tree_id) => tree_id,
MergedTreeId::Merge(_) => panic!(),
}
}
}
content_hash! {

View file

@ -318,7 +318,10 @@ fn deserialize_extras(commit: &mut Commit, bytes: &[u8]) {
// uses_tree_conflict_format was set but there was no root_tree override in the
// proto, which means we should just promote the tree id from the
// git commit to be a known-conflict-free tree
commit.root_tree = MergedTreeId::resolved(commit.root_tree.as_legacy_tree_id().clone());
let MergedTreeId::Legacy(legacy_tree_id) = &commit.root_tree else {
panic!("root tree should have been initialized to a legacy id");
};
commit.root_tree = MergedTreeId::resolved(legacy_tree_id.clone());
}
}
for predecessor in &proto.predecessors {
@ -917,8 +920,8 @@ mod tests {
assert_eq!(commit.parents, vec![CommitId::from_bytes(&[0; 20])]);
assert_eq!(commit.predecessors, vec![]);
assert_eq!(
commit.root_tree.as_legacy_tree_id().as_bytes(),
root_tree_id.as_bytes()
commit.root_tree,
MergedTreeId::Legacy(TreeId::from_bytes(root_tree_id.as_bytes()))
);
assert_eq!(commit.description, "git commit message");
assert_eq!(commit.author.name, "git author");

View file

@ -56,8 +56,8 @@ fn test_root(use_git: bool) {
let wc_commit = repo.store().get_commit(wc_commit_id).unwrap();
assert_eq!(new_tree.id(), *wc_commit.tree_id());
assert_eq!(
new_tree.id().as_legacy_tree_id(),
repo.store().empty_tree_id()
new_tree.id(),
MergedTreeId::Legacy(repo.store().empty_tree_id().clone())
);
}
@ -730,7 +730,8 @@ fn test_dotgit_ignored(use_git: bool) {
"contents",
);
let new_tree = test_workspace.snapshot().unwrap();
assert_eq!(new_tree.id().as_legacy_tree_id(), store.empty_tree_id());
let empty_tree_id = MergedTreeId::Legacy(store.empty_tree_id().clone());
assert_eq!(new_tree.id(), empty_tree_id);
std::fs::remove_dir_all(&dotgit_path).unwrap();
// Test with a .git file
@ -740,7 +741,7 @@ fn test_dotgit_ignored(use_git: bool) {
"contents",
);
let new_tree = test_workspace.snapshot().unwrap();
assert_eq!(new_tree.id().as_legacy_tree_id(), store.empty_tree_id());
assert_eq!(new_tree.id(), empty_tree_id);
}
#[test]