~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-07-19 14:26:11 UTC
  • mfrom: (5346.4.6 cleanup)
  • Revision ID: pqm@pqm.ubuntu.com-20100719142611-fbhst4ivcngc32d5
(mbp) tree_files and internal_tree files moved to WorkingTree (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
from bzrlib.decorators import needs_read_lock, needs_write_lock
54
54
from bzrlib.filters import filtered_input_file, internal_size_sha_file_byname
55
55
from bzrlib.inventory import Inventory, ROOT_ID, entry_factory
 
56
from bzrlib.lock import LogicalLockResult
56
57
from bzrlib.mutabletree import needs_tree_write_lock
57
58
from bzrlib.osutils import (
58
59
    file_kind,
569
570
    def lock_read(self):
570
571
        """See Branch.lock_read, and WorkingTree.unlock.
571
572
 
572
 
        :return: An object with an unlock method which will release the lock
573
 
            obtained.
 
573
        :return: A bzrlib.lock.LogicalLockResult.
574
574
        """
575
575
        self.branch.lock_read()
576
576
        try:
590
590
        except:
591
591
            self.branch.unlock()
592
592
            raise
593
 
        return self
 
593
        return LogicalLockResult(self.unlock)
594
594
 
595
595
    def _lock_self_write(self):
596
596
        """This should be called after the branch is locked."""
611
611
        except:
612
612
            self.branch.unlock()
613
613
            raise
614
 
        return self
 
614
        return LogicalLockResult(self.unlock)
615
615
 
616
616
    def lock_tree_write(self):
617
617
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
618
618
 
619
 
        :return: An object with an unlock method which will release the lock
620
 
            obtained.
 
619
        :return: A bzrlib.lock.LogicalLockResult.
621
620
        """
622
621
        self.branch.lock_read()
623
622
        return self._lock_self_write()
625
624
    def lock_write(self):
626
625
        """See MutableTree.lock_write, and WorkingTree.unlock.
627
626
 
628
 
        :return: An object with an unlock method which will release the lock
629
 
            obtained.
 
627
        :return: A bzrlib.lock.LogicalLockResult.
630
628
        """
631
629
        self.branch.lock_write()
632
630
        return self._lock_self_write()
1249
1247
        # have to change the legacy inventory too.
1250
1248
        if self._inventory is not None:
1251
1249
            for file_id in file_ids:
1252
 
                self._inventory.remove_recursive_id(file_id)
 
1250
                if self._inventory.has_id(file_id):
 
1251
                    self._inventory.remove_recursive_id(file_id)
1253
1252
 
1254
1253
    @needs_tree_write_lock
1255
1254
    def rename_one(self, from_rel, to_rel, after=False):
1331
1330
    def _file_content_summary(self, path, stat_result):
1332
1331
        # This is to support the somewhat obsolete path_content_summary method
1333
1332
        # with content filtering: see
1334
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/415508>.
 
1333
        # <https://bugs.launchpad.net/bzr/+bug/415508>.
1335
1334
        #
1336
1335
        # If the dirstate cache is up to date and knows the hash and size,
1337
1336
        # return that.
1896
1895
    def lock_read(self):
1897
1896
        """Lock the tree for a set of operations.
1898
1897
 
1899
 
        :return: An object with an unlock method which will release the lock
1900
 
            obtained.
 
1898
        :return: A bzrlib.lock.LogicalLockResult.
1901
1899
        """
1902
1900
        if not self._locked:
1903
1901
            self._repository.lock_read()
1905
1903
                self._dirstate.lock_read()
1906
1904
                self._dirstate_locked = True
1907
1905
        self._locked += 1
1908
 
        return self
 
1906
        return LogicalLockResult(self.unlock)
1909
1907
 
1910
1908
    def _must_be_locked(self):
1911
1909
        if not self._locked: