mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-16 09:11:55 +00:00
rewrite: return MergedTree
from merge_commit_trees_without_repo()
This commit is contained in:
parent
90e78a1424
commit
7bfd439bd1
2 changed files with 9 additions and 13 deletions
|
@ -892,7 +892,7 @@ fn has_diff_from_parent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let from_tree = rewrite::merge_commit_trees_without_repo(store, &index, &parents).unwrap();
|
let from_tree = rewrite::merge_commit_trees_without_repo(store, &index, &parents).unwrap();
|
||||||
let to_tree = commit.tree();
|
let to_tree = commit.merged_tree().unwrap();
|
||||||
from_tree.diff(&to_tree, matcher).next().is_some()
|
from_tree.diff(&to_tree, matcher).next().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,18 +20,17 @@ use std::sync::Arc;
|
||||||
use itertools::{process_results, Itertools};
|
use itertools::{process_results, Itertools};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::backend::{BackendError, CommitId, ObjectId};
|
use crate::backend::{BackendError, CommitId, MergedTreeId, ObjectId};
|
||||||
use crate::commit::Commit;
|
use crate::commit::Commit;
|
||||||
use crate::dag_walk;
|
use crate::dag_walk;
|
||||||
use crate::index::Index;
|
use crate::index::Index;
|
||||||
use crate::merged_tree::MergedTree;
|
use crate::merged_tree::MergedTree;
|
||||||
use crate::op_store::RefTarget;
|
use crate::op_store::RefTarget;
|
||||||
use crate::repo::{MutableRepo, Repo};
|
use crate::repo::{MutableRepo, Repo};
|
||||||
use crate::repo_path::RepoPath;
|
|
||||||
use crate::revset::{RevsetExpression, RevsetIteratorExt};
|
use crate::revset::{RevsetExpression, RevsetIteratorExt};
|
||||||
use crate::settings::UserSettings;
|
use crate::settings::UserSettings;
|
||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
use crate::tree::{merge_trees, Tree, TreeMergeError};
|
use crate::tree::TreeMergeError;
|
||||||
use crate::view::RefName;
|
use crate::view::RefName;
|
||||||
|
|
||||||
#[instrument(skip(repo))]
|
#[instrument(skip(repo))]
|
||||||
|
@ -39,11 +38,7 @@ pub fn merge_commit_trees(
|
||||||
repo: &dyn Repo,
|
repo: &dyn Repo,
|
||||||
commits: &[Commit],
|
commits: &[Commit],
|
||||||
) -> Result<MergedTree, TreeMergeError> {
|
) -> Result<MergedTree, TreeMergeError> {
|
||||||
Ok(MergedTree::legacy(merge_commit_trees_without_repo(
|
merge_commit_trees_without_repo(repo.store(), repo.index(), commits)
|
||||||
repo.store(),
|
|
||||||
repo.index(),
|
|
||||||
commits,
|
|
||||||
)?))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(index))]
|
#[instrument(skip(index))]
|
||||||
|
@ -51,11 +46,11 @@ pub fn merge_commit_trees_without_repo(
|
||||||
store: &Arc<Store>,
|
store: &Arc<Store>,
|
||||||
index: &dyn Index,
|
index: &dyn Index,
|
||||||
commits: &[Commit],
|
commits: &[Commit],
|
||||||
) -> Result<Tree, TreeMergeError> {
|
) -> Result<MergedTree, TreeMergeError> {
|
||||||
if commits.is_empty() {
|
if commits.is_empty() {
|
||||||
Ok(store.get_tree(&RepoPath::root(), store.empty_tree_id())?)
|
Ok(store.get_root_tree(&MergedTreeId::Legacy(store.empty_tree_id().clone()))?)
|
||||||
} else {
|
} else {
|
||||||
let mut new_tree = commits[0].tree();
|
let mut new_tree = commits[0].merged_tree()?;
|
||||||
let commit_ids = commits
|
let commit_ids = commits
|
||||||
.iter()
|
.iter()
|
||||||
.map(|commit| commit.id().clone())
|
.map(|commit| commit.id().clone())
|
||||||
|
@ -67,7 +62,8 @@ pub fn merge_commit_trees_without_repo(
|
||||||
.map(|id| store.get_commit(id))
|
.map(|id| store.get_commit(id))
|
||||||
.try_collect()?;
|
.try_collect()?;
|
||||||
let ancestor_tree = merge_commit_trees_without_repo(store, index, &ancestors)?;
|
let ancestor_tree = merge_commit_trees_without_repo(store, index, &ancestors)?;
|
||||||
new_tree = merge_trees(&new_tree, &ancestor_tree, &other_commit.tree())?;
|
let other_tree = other_commit.merged_tree()?;
|
||||||
|
new_tree = new_tree.merge(&ancestor_tree, &other_tree)?;
|
||||||
}
|
}
|
||||||
Ok(new_tree)
|
Ok(new_tree)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue