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

commit: migrate remaining uses of Commit::tree_id() and delete it

This commit is contained in:
Martin von Zweigbergk 2023-08-27 09:49:10 -07:00 committed by Martin von Zweigbergk
parent 7bfd439bd1
commit dc06bbc7d1
5 changed files with 13 additions and 12 deletions

View file

@ -3108,7 +3108,7 @@ don't make any changes, then the operation will be aborted.
.mut_repo()
.rewrite_commit(command.settings(), &commit)
.set_parents(vec![first_commit.id().clone()])
.set_tree(commit.tree_id().clone())
.set_tree_id(commit.merged_tree_id().clone())
.generate_new_change_id()
.set_description(second_description)
.write()?;

View file

@ -20,7 +20,7 @@ use std::hash::{Hash, Hasher};
use std::sync::Arc;
use crate::backend;
use crate::backend::{BackendError, ChangeId, CommitId, MergedTreeId, Signature, TreeId};
use crate::backend::{BackendError, ChangeId, CommitId, MergedTreeId, Signature};
use crate::merged_tree::MergedTree;
use crate::repo_path::RepoPath;
use crate::store::Store;
@ -113,12 +113,6 @@ impl Commit {
self.store.get_root_tree(&self.data.root_tree)
}
// TODO(#1624): delete when all callers have been updated to support tree-level
// conflicts
pub fn tree_id(&self) -> &TreeId {
self.data.root_tree.as_legacy_tree_id()
}
pub fn merged_tree_id(&self) -> &MergedTreeId {
&self.data.root_tree
}
@ -148,7 +142,7 @@ impl Commit {
pub fn is_discardable(&self) -> bool {
if self.description().is_empty() {
if let [parent_commit] = &*self.parents() {
return self.tree_id() == parent_commit.tree_id();
return self.merged_tree_id() == parent_commit.merged_tree_id();
}
}
false

View file

@ -884,7 +884,7 @@ fn has_diff_from_parent(
let parents = commit.parents();
if let [parent] = parents.as_slice() {
// Fast path: no need to load the root tree
let unchanged = commit.tree_id() == parent.tree_id();
let unchanged = commit.merged_tree_id() == parent.merged_tree_id();
if matcher.visit(&RepoPath::root()) == Visit::AllRecursively {
return !unchanged;
} else if unchanged {

View file

@ -14,6 +14,7 @@
use std::path::{Path, PathBuf};
use jj_lib::backend::MergedTreeId;
use jj_lib::git_backend::GitBackend;
use jj_lib::op_store::WorkspaceId;
use jj_lib::repo::Repo;
@ -123,7 +124,10 @@ fn test_init_checkout(use_git: bool) {
.get_wc_commit_id(&WorkspaceId::default())
.unwrap();
let wc_commit = repo.store().get_commit(wc_commit_id).unwrap();
assert_eq!(wc_commit.tree_id(), repo.store().empty_tree_id());
assert_eq!(
*wc_commit.merged_tree_id(),
MergedTreeId::Legacy(repo.store().empty_tree_id().clone())
);
assert_eq!(
wc_commit.store_commit().parents,
vec![repo.store().root_commit_id().clone()]

View file

@ -58,7 +58,10 @@ fn test_checkout(use_git: bool) {
.mut_repo()
.check_out(ws_id.clone(), &settings, &wc_commit_parent)
.unwrap();
assert_eq!(wc_commit.tree_id(), wc_commit_parent.tree_id());
assert_eq!(
wc_commit.merged_tree_id(),
wc_commit_parent.merged_tree_id()
);
assert_eq!(wc_commit.parents().len(), 1);
assert_eq!(wc_commit.parents()[0].id(), wc_commit_parent.id());
let repo = tx.commit();