555
555
def copy_content_into(self, tree, revision_id=None):
556
556
"""Copy the current content and user files of this tree into tree."""
557
tree.set_root_id(self.get_root_id())
557
558
if revision_id is None:
558
559
merge.transform_tree(tree, self)
1641
1645
def update(self):
1642
1646
"""Update a working tree along its branch.
1644
This will update the branch if its bound too, which means we have multiple trees involved:
1645
The new basis tree of the master.
1646
The old basis tree of the branch.
1647
The old basis tree of the working tree.
1648
The current working tree state.
1649
pathologically all three may be different, and non ancestors of each other.
1650
Conceptually we want to:
1651
Preserve the wt.basis->wt.state changes
1652
Transform the wt.basis to the new master basis.
1653
Apply a merge of the old branch basis to get any 'local' changes from it into the tree.
1654
Restore the wt.basis->wt.state changes.
1648
This will update the branch if its bound too, which means we have
1649
multiple trees involved:
1651
- The new basis tree of the master.
1652
- The old basis tree of the branch.
1653
- The old basis tree of the working tree.
1654
- The current working tree state.
1656
Pathologically, all three may be different, and non-ancestors of each
1657
other. Conceptually we want to:
1659
- Preserve the wt.basis->wt.state changes
1660
- Transform the wt.basis to the new master basis.
1661
- Apply a merge of the old branch basis to get any 'local' changes from
1663
- Restore the wt.basis->wt.state changes.
1656
1665
There isn't a single operation at the moment to do that, so we:
1657
Merge current state -> basis tree of the master w.r.t. the old tree basis.
1658
Do a 'normal' merge of the old branch basis if it is relevant.
1666
- Merge current state -> basis tree of the master w.r.t. the old tree
1668
- Do a 'normal' merge of the old branch basis if it is relevant.
1660
1670
old_tip = self.branch.update()
1661
1672
# here if old_tip is not None, it is the old tip of the branch before
1662
1673
# it was updated from the master branch. This should become a pending
1663
1674
# merge in the working tree to preserve the user existing work. we
1677
1688
# merge tree state up to new branch tip.
1678
1689
basis = self.basis_tree()
1679
1690
to_tree = self.branch.basis_tree()
1691
if basis.inventory.root is None:
1692
self.set_root_id(to_tree.inventory.root.file_id)
1680
1693
result += merge.merge_inner(
2014
2027
_internal=True,
2016
2029
_bzrdir=a_bzrdir)
2017
wt.set_root_id(inv.root.file_id)
2018
2030
basis_tree = branch.repository.revision_tree(revision)
2031
if basis_tree.inventory.root is not None:
2032
wt.set_root_id(basis_tree.inventory.root.file_id)
2033
# set the parent list and cache the basis tree.
2019
2034
wt.set_parent_trees([(revision, basis_tree)])
2020
2035
transform.build_tree(basis_tree, wt)
2085
2100
branch = a_bzrdir.open_branch()
2086
2101
if revision_id is None:
2087
2102
revision_id = branch.last_revision()
2103
inv = Inventory(root_id=gen_root_id())
2089
2104
wt = WorkingTree3(a_bzrdir.root_transport.local_abspath('.'),
2095
2110
_control_files=control_files)
2096
2111
wt.lock_tree_write()
2098
wt.set_root_id(inv.root.file_id)
2099
2113
basis_tree = branch.repository.revision_tree(revision_id)
2114
# only set an explicit root id if there is one to set.
2115
if basis_tree.inventory.root is not None:
2116
wt.set_root_id(basis_tree.inventory.root.file_id)
2100
2117
if revision_id == NULL_REVISION:
2101
2118
wt.set_parent_trees([])