539
539
def copy_content_into(self, tree, revision_id=None):
540
540
"""Copy the current content and user files of this tree into tree."""
541
tree.set_root_id(self.get_root_id())
541
542
if revision_id is None:
542
543
merge.transform_tree(tree, self)
1588
1592
def update(self):
1589
1593
"""Update a working tree along its branch.
1591
This will update the branch if its bound too, which means we have multiple trees involved:
1592
The new basis tree of the master.
1593
The old basis tree of the branch.
1594
The old basis tree of the working tree.
1595
The current working tree state.
1596
pathologically all three may be different, and non ancestors of each other.
1597
Conceptually we want to:
1598
Preserve the wt.basis->wt.state changes
1599
Transform the wt.basis to the new master basis.
1600
Apply a merge of the old branch basis to get any 'local' changes from it into the tree.
1601
Restore the wt.basis->wt.state changes.
1595
This will update the branch if its bound too, which means we have
1596
multiple trees involved:
1598
- The new basis tree of the master.
1599
- The old basis tree of the branch.
1600
- The old basis tree of the working tree.
1601
- The current working tree state.
1603
Pathologically, all three may be different, and non-ancestors of each
1604
other. Conceptually we want to:
1606
- Preserve the wt.basis->wt.state changes
1607
- Transform the wt.basis to the new master basis.
1608
- Apply a merge of the old branch basis to get any 'local' changes from
1610
- Restore the wt.basis->wt.state changes.
1603
1612
There isn't a single operation at the moment to do that, so we:
1604
Merge current state -> basis tree of the master w.r.t. the old tree basis.
1605
Do a 'normal' merge of the old branch basis if it is relevant.
1613
- Merge current state -> basis tree of the master w.r.t. the old tree
1615
- Do a 'normal' merge of the old branch basis if it is relevant.
1607
1617
old_tip = self.branch.update()
1608
1619
# here if old_tip is not None, it is the old tip of the branch before
1609
1620
# it was updated from the master branch. This should become a pending
1610
1621
# merge in the working tree to preserve the user existing work. we
1624
1635
# merge tree state up to new branch tip.
1625
1636
basis = self.basis_tree()
1626
1637
to_tree = self.branch.basis_tree()
1638
if basis.inventory.root is None:
1639
self.set_root_id(to_tree.inventory.root.file_id)
1627
1640
result += merge.merge_inner(
1957
1970
_internal=True,
1959
1972
_bzrdir=a_bzrdir)
1973
wt.set_last_revision(revision)
1974
basis_tree = wt.basis_tree()
1975
if basis_tree.inventory.root is not None:
1976
inv.root.file_id = basis_tree.inventory.root.file_id
1960
1977
wt._write_inventory(inv)
1961
wt.set_root_id(inv.root.file_id)
1962
basis_tree = branch.repository.revision_tree(revision)
1963
1978
wt.set_parent_trees([(revision, basis_tree)])
1964
1979
transform.build_tree(basis_tree, wt)
2029
2044
branch = a_bzrdir.open_branch()
2030
2045
if revision_id is None:
2031
2046
revision_id = branch.last_revision()
2047
inv = Inventory(root_id=gen_root_id())
2033
2048
wt = WorkingTree3(a_bzrdir.root_transport.local_abspath('.'),
2039
2054
_control_files=control_files)
2040
2055
wt.lock_tree_write()
2057
wt.set_last_revision(revision_id)
2058
basis_tree = wt.basis_tree()
2042
2059
wt._write_inventory(inv)
2043
wt.set_root_id(inv.root.file_id)
2044
basis_tree = branch.repository.revision_tree(revision_id)
2045
if revision_id == NULL_REVISION:
2060
wt.set_pending_merges([])
2061
if revision_id == bzrlib.revision.NULL_REVISION:
2046
2062
wt.set_parent_trees([])
2048
2064
wt.set_parent_trees([(revision_id, basis_tree)])