mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-31 16:33:10 +00:00
commit: migrate remaining uses of Commit::tree_id()
and delete it
This commit is contained in:
parent
7bfd439bd1
commit
dc06bbc7d1
5 changed files with 13 additions and 12 deletions
|
@ -3108,7 +3108,7 @@ don't make any changes, then the operation will be aborted.
|
||||||
.mut_repo()
|
.mut_repo()
|
||||||
.rewrite_commit(command.settings(), &commit)
|
.rewrite_commit(command.settings(), &commit)
|
||||||
.set_parents(vec![first_commit.id().clone()])
|
.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()
|
.generate_new_change_id()
|
||||||
.set_description(second_description)
|
.set_description(second_description)
|
||||||
.write()?;
|
.write()?;
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::hash::{Hash, Hasher};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::backend;
|
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::merged_tree::MergedTree;
|
||||||
use crate::repo_path::RepoPath;
|
use crate::repo_path::RepoPath;
|
||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
|
@ -113,12 +113,6 @@ impl Commit {
|
||||||
self.store.get_root_tree(&self.data.root_tree)
|
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 {
|
pub fn merged_tree_id(&self) -> &MergedTreeId {
|
||||||
&self.data.root_tree
|
&self.data.root_tree
|
||||||
}
|
}
|
||||||
|
@ -148,7 +142,7 @@ impl Commit {
|
||||||
pub fn is_discardable(&self) -> bool {
|
pub fn is_discardable(&self) -> bool {
|
||||||
if self.description().is_empty() {
|
if self.description().is_empty() {
|
||||||
if let [parent_commit] = &*self.parents() {
|
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
|
false
|
||||||
|
|
|
@ -884,7 +884,7 @@ fn has_diff_from_parent(
|
||||||
let parents = commit.parents();
|
let parents = commit.parents();
|
||||||
if let [parent] = parents.as_slice() {
|
if let [parent] = parents.as_slice() {
|
||||||
// Fast path: no need to load the root tree
|
// 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 {
|
if matcher.visit(&RepoPath::root()) == Visit::AllRecursively {
|
||||||
return !unchanged;
|
return !unchanged;
|
||||||
} else if unchanged {
|
} else if unchanged {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use jj_lib::backend::MergedTreeId;
|
||||||
use jj_lib::git_backend::GitBackend;
|
use jj_lib::git_backend::GitBackend;
|
||||||
use jj_lib::op_store::WorkspaceId;
|
use jj_lib::op_store::WorkspaceId;
|
||||||
use jj_lib::repo::Repo;
|
use jj_lib::repo::Repo;
|
||||||
|
@ -123,7 +124,10 @@ fn test_init_checkout(use_git: bool) {
|
||||||
.get_wc_commit_id(&WorkspaceId::default())
|
.get_wc_commit_id(&WorkspaceId::default())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let wc_commit = repo.store().get_commit(wc_commit_id).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!(
|
assert_eq!(
|
||||||
wc_commit.store_commit().parents,
|
wc_commit.store_commit().parents,
|
||||||
vec![repo.store().root_commit_id().clone()]
|
vec![repo.store().root_commit_id().clone()]
|
||||||
|
|
|
@ -58,7 +58,10 @@ fn test_checkout(use_git: bool) {
|
||||||
.mut_repo()
|
.mut_repo()
|
||||||
.check_out(ws_id.clone(), &settings, &wc_commit_parent)
|
.check_out(ws_id.clone(), &settings, &wc_commit_parent)
|
||||||
.unwrap();
|
.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().len(), 1);
|
||||||
assert_eq!(wc_commit.parents()[0].id(), wc_commit_parent.id());
|
assert_eq!(wc_commit.parents()[0].id(), wc_commit_parent.id());
|
||||||
let repo = tx.commit();
|
let repo = tx.commit();
|
||||||
|
|
Loading…
Reference in a new issue