Struct jj_lib::merged_tree::MergedTreeBuilder
source · pub struct MergedTreeBuilder { /* private fields */ }
Expand description
Helps with writing trees with conflicts. You start by creating an instance of this type with one or more base trees. You then add overrides on top. The overrides may be conflicts. Then you can write the result as a legacy tree (allowing path-level conflicts) or as multiple conflict-free trees.
Implementations§
source§impl MergedTreeBuilder
impl MergedTreeBuilder
sourcepub fn new(base_tree_id: MergedTreeId) -> Self
pub fn new(base_tree_id: MergedTreeId) -> Self
Create a new builder with the given trees as base.
sourcepub fn set_or_remove(&mut self, path: RepoPath, values: MergedTreeValue)
pub fn set_or_remove(&mut self, path: RepoPath, values: MergedTreeValue)
Set an override compared to the base tree. The values
merge must
either be resolved (i.e. have 1 side) or have the same number of
sides as the base_tree_ids
used to construct this builder. Use
Merge::absent()
to remove a value from the tree. When the base tree is
a legacy tree, conflicts can be written either as a multi-way Merge
value or as a resolved Merge
value using TreeValue::Conflict
.
sourcepub fn write_tree(self, store: &Arc<Store>) -> BackendResult<MergedTreeId>
pub fn write_tree(self, store: &Arc<Store>) -> BackendResult<MergedTreeId>
Create new tree(s) from the base tree(s) and overrides.
When the base tree was a legacy tree and the
format.tree-level-conflicts
config is disabled, then the result will
be another legacy tree. Overrides with conflicts will result in
conflict objects being written to the store. If
format.tree-tree-level-conflicts
is enabled, then a legacy tree will
still be written and immediately converted and returned as a merged
tree.