/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 bzrlib/workingtree_4.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

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
57
56
from bzrlib.mutabletree import needs_tree_write_lock
58
57
from bzrlib.osutils import (
59
58
    file_kind,
570
569
    def lock_read(self):
571
570
        """See Branch.lock_read, and WorkingTree.unlock.
572
571
 
573
 
        :return: A bzrlib.lock.LogicalLockResult.
 
572
        :return: An object with an unlock method which will release the lock
 
573
            obtained.
574
574
        """
575
575
        self.branch.lock_read()
576
576
        try:
590
590
        except:
591
591
            self.branch.unlock()
592
592
            raise
593
 
        return LogicalLockResult(self.unlock)
 
593
        return self
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 LogicalLockResult(self.unlock)
 
614
        return self
615
615
 
616
616
    def lock_tree_write(self):
617
617
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
618
618
 
619
 
        :return: A bzrlib.lock.LogicalLockResult.
 
619
        :return: An object with an unlock method which will release the lock
 
620
            obtained.
620
621
        """
621
622
        self.branch.lock_read()
622
623
        return self._lock_self_write()
624
625
    def lock_write(self):
625
626
        """See MutableTree.lock_write, and WorkingTree.unlock.
626
627
 
627
 
        :return: A bzrlib.lock.LogicalLockResult.
 
628
        :return: An object with an unlock method which will release the lock
 
629
            obtained.
628
630
        """
629
631
        self.branch.lock_write()
630
632
        return self._lock_self_write()
1894
1896
    def lock_read(self):
1895
1897
        """Lock the tree for a set of operations.
1896
1898
 
1897
 
        :return: A bzrlib.lock.LogicalLockResult.
 
1899
        :return: An object with an unlock method which will release the lock
 
1900
            obtained.
1898
1901
        """
1899
1902
        if not self._locked:
1900
1903
            self._repository.lock_read()
1902
1905
                self._dirstate.lock_read()
1903
1906
                self._dirstate_locked = True
1904
1907
        self._locked += 1
1905
 
        return LogicalLockResult(self.unlock)
 
1908
        return self
1906
1909
 
1907
1910
    def _must_be_locked(self):
1908
1911
        if not self._locked: