398
399
parents.append(revision_id)
401
def get_root_id(self):
402
"""Return the id of this trees root"""
403
raise NotImplementedError(self.get_root_id)
405
402
def clone(self, to_controldir, revision_id=None):
406
403
"""Duplicate this working tree into to_bzr, including all state.
424
421
def copy_content_into(self, tree, revision_id=None):
425
422
"""Copy the current content and user files of this tree into tree."""
426
423
with self.lock_read():
427
tree.set_root_id(self.get_root_id())
424
tree.set_root_id(self.path2id(''))
428
425
if revision_id is None:
429
426
merge.transform_tree(tree, self)
842
839
change_reporter=change_reporter,
843
840
show_base=show_base)
844
basis_root_id = basis_tree.get_root_id()
845
new_root_id = new_basis_tree.get_root_id()
841
basis_root_id = basis_tree.path2id('')
842
new_root_id = new_basis_tree.path2id('')
846
843
if new_root_id is not None and basis_root_id != new_root_id:
847
844
self.set_root_id(new_root_id)
848
845
# TODO - dedup parents list with things merged by pull ?
998
995
def revert(self, filenames=None, old_tree=None, backups=True,
999
996
pb=None, report_changes=False):
1000
997
from .conflicts import resolve
1001
with self.lock_tree_write():
998
with cleanup.ExitStack() as exit_stack:
999
exit_stack.enter_context(self.lock_tree_write())
1002
1000
if old_tree is None:
1003
1001
basis_tree = self.basis_tree()
1004
basis_tree.lock_read()
1002
exit_stack.enter_context(basis_tree.lock_read())
1005
1003
old_tree = basis_tree
1007
1005
basis_tree = None
1009
conflicts = transform.revert(self, old_tree, filenames, backups, pb,
1011
if filenames is None and len(self.get_parent_ids()) > 1:
1013
last_revision = self.last_revision()
1014
if last_revision != _mod_revision.NULL_REVISION:
1015
if basis_tree is None:
1016
basis_tree = self.basis_tree()
1017
basis_tree.lock_read()
1018
parent_trees.append((last_revision, basis_tree))
1019
self.set_parent_trees(parent_trees)
1022
resolve(self, filenames, ignore_misses=True, recursive=True)
1024
if basis_tree is not None:
1006
conflicts = transform.revert(self, old_tree, filenames, backups, pb,
1008
if filenames is None and len(self.get_parent_ids()) > 1:
1010
last_revision = self.last_revision()
1011
if last_revision != _mod_revision.NULL_REVISION:
1012
if basis_tree is None:
1013
basis_tree = self.basis_tree()
1014
exit_stack.enter_context(basis_tree.lock_read())
1015
parent_trees.append((last_revision, basis_tree))
1016
self.set_parent_trees(parent_trees)
1019
resolve(self, filenames, ignore_misses=True, recursive=True)
1026
1020
return conflicts
1028
1022
def store_uncommitted(self):
1170
1164
# the working tree is up to date with the branch
1171
1165
# we can merge the specified revision from master
1172
1166
to_tree = self.branch.repository.revision_tree(revision)
1173
to_root_id = to_tree.get_root_id()
1167
to_root_id = to_tree.path2id('')
1175
1169
basis = self.basis_tree()
1176
1170
with basis.lock_read():
1177
if (basis.get_root_id() is None or basis.get_root_id() != to_root_id):
1171
if (basis.path2id('') is None or basis.path2id('') != to_root_id):
1178
1172
self.set_root_id(to_root_id)