/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
import stat
42
42
 
43
43
from breezy import (
 
44
    cleanup,
44
45
    conflicts as _mod_conflicts,
45
46
    errors,
46
47
    filters as _mod_filters,
398
399
                parents.append(revision_id)
399
400
        return parents
400
401
 
401
 
    def get_root_id(self):
402
 
        """Return the id of this trees root"""
403
 
        raise NotImplementedError(self.get_root_id)
404
 
 
405
402
    def clone(self, to_controldir, revision_id=None):
406
403
        """Duplicate this working tree into to_bzr, including all state.
407
404
 
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)
430
427
            else:
841
838
                        this_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
1006
1004
            else:
1007
1005
                basis_tree = None
1008
 
            try:
1009
 
                conflicts = transform.revert(self, old_tree, filenames, backups, pb,
1010
 
                                             report_changes)
1011
 
                if filenames is None and len(self.get_parent_ids()) > 1:
1012
 
                    parent_trees = []
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)
1020
 
                    resolve(self)
1021
 
                else:
1022
 
                    resolve(self, filenames, ignore_misses=True, recursive=True)
1023
 
            finally:
1024
 
                if basis_tree is not None:
1025
 
                    basis_tree.unlock()
 
1006
            conflicts = transform.revert(self, old_tree, filenames, backups, pb,
 
1007
                                         report_changes)
 
1008
            if filenames is None and len(self.get_parent_ids()) > 1:
 
1009
                parent_trees = []
 
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)
 
1017
                resolve(self)
 
1018
            else:
 
1019
                resolve(self, filenames, ignore_misses=True, recursive=True)
1026
1020
            return conflicts
1027
1021
 
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('')
1174
1168
 
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)
1179
1173
                        self.flush()
1180
1174