tests: remove last uses of Commit:tree() and delete it

This commit is contained in:
Martin von Zweigbergk 2023-08-27 16:18:46 -07:00 committed by Martin von Zweigbergk
parent 55c6e90555
commit 6e3590f5cd
3 changed files with 18 additions and 36 deletions

View file

@ -22,9 +22,7 @@ use std::sync::Arc;
use crate::backend;
use crate::backend::{BackendError, ChangeId, CommitId, MergedTreeId, Signature};
use crate::merged_tree::MergedTree;
use crate::repo_path::RepoPath;
use crate::store::Store;
use crate::tree::Tree;
#[derive(Clone)]
pub struct Commit {
@ -102,13 +100,6 @@ impl Commit {
.collect()
}
// TODO(#1624): Delete when all callers use `merged_tree()`
pub fn tree(&self) -> Tree {
self.store
.get_tree(&RepoPath::root(), self.data.root_tree.as_legacy_tree_id())
.unwrap()
}
pub fn merged_tree(&self) -> Result<MergedTree, BackendError> {
self.store.get_root_tree(&self.data.root_tree)
}

View file

@ -12,9 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use assert_matches::assert_matches;
use itertools::Itertools;
use jj_lib::backend::TreeValue;
use jj_lib::backend::{MergedTreeId, TreeValue};
use jj_lib::repo::Repo;
use jj_lib::repo_path::{RepoPath, RepoPathComponent};
use jj_lib::rewrite::rebase_commit;
@ -606,21 +605,17 @@ fn test_simplify_conflict_after_resolving_parent(use_git: bool) {
rebase_commit(&settings, tx.mut_repo(), &commit_c, &[commit_b2.clone()]).unwrap();
// Test the setup: Both B and C should have conflicts.
assert_matches!(
commit_b2.tree().path_value(&path),
Some(TreeValue::Conflict(_))
);
assert_matches!(
commit_c2.tree().path_value(&path),
Some(TreeValue::Conflict(_))
);
let tree_b2 = commit_b2.merged_tree().unwrap();
let tree_c2 = commit_b2.merged_tree().unwrap();
assert!(!tree_b2.path_value(&path).is_resolved());
assert!(!tree_c2.path_value(&path).is_resolved());
// Create the resolved B and rebase C on top.
let tree_b3 = testutils::create_tree(repo, &[(&path, "AbC\ndef\nghi\n")]);
let commit_b3 = tx
.mut_repo()
.rewrite_commit(&settings, &commit_b2)
.set_tree(tree_b3.id().clone())
.set_tree_id(MergedTreeId::Legacy(tree_b3.id().clone()))
.write()
.unwrap();
let commit_c3 = rebase_commit(&settings, tx.mut_repo(), &commit_c2, &[commit_b3]).unwrap();
@ -628,12 +623,13 @@ fn test_simplify_conflict_after_resolving_parent(use_git: bool) {
let repo = tx.commit();
// The conflict should now be resolved.
let resolved_value = commit_c3.tree().path_value(&path);
match resolved_value {
Some(TreeValue::File {
let tree_c2 = commit_c3.merged_tree().unwrap();
let resolved_value = tree_c2.path_value(&path);
match resolved_value.into_resolved() {
Ok(Some(TreeValue::File {
id,
executable: false,
}) => {
})) => {
assert_eq!(
testutils::read_file(repo.store(), &path, &id),
b"AbC\ndef\nGhi\n"

View file

@ -904,18 +904,13 @@ fn test_rebase_descendants_contents(use_git: bool) {
.get_commit(rebased.get(commit_c.id()).unwrap())
.unwrap();
assert_eq!(
new_commit_c.tree().path_value(&path3),
commit_c.tree().path_value(&path3)
);
assert_eq!(
new_commit_c.tree().path_value(&path4),
commit_d.tree().path_value(&path4)
);
assert_ne!(
new_commit_c.tree().path_value(&path2),
commit_b.tree().path_value(&path2)
);
let tree_b = commit_b.merged_tree().unwrap();
let tree_c = commit_c.merged_tree().unwrap();
let tree_d = commit_d.merged_tree().unwrap();
let new_tree_c = new_commit_c.merged_tree().unwrap();
assert_eq!(new_tree_c.path_value(&path3), tree_c.path_value(&path3));
assert_eq!(new_tree_c.path_value(&path4), tree_d.path_value(&path4));
assert_ne!(new_tree_c.path_value(&path2), tree_b.path_value(&path2));
}
#[test]