~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2010-05-11 08:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511083616-b8fjb19zomwupid0
Make all lock methods return Result objects, rather than lock_read returning self, as per John's review.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
 
78
78
from bzrlib import symbol_versioning
79
79
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
80
from bzrlib.lock import LogicalLockResult
80
81
from bzrlib.lockable_files import LockableFiles
81
82
from bzrlib.lockdir import LockDir
82
83
import bzrlib.mutabletree
1802
1803
 
1803
1804
        This also locks the branch, and can be unlocked via self.unlock().
1804
1805
 
1805
 
        :return: An object with an unlock method which will release the lock
1806
 
            obtained.
 
1806
        :return: A bzrlib.lock.LogicalLockResult.
1807
1807
        """
1808
1808
        if not self.is_locked():
1809
1809
            self._reset_data()
1810
1810
        self.branch.lock_read()
1811
1811
        try:
1812
1812
            self._control_files.lock_read()
1813
 
            return self
 
1813
            return LogicalLockResult(self.unlock)
1814
1814
        except:
1815
1815
            self.branch.unlock()
1816
1816
            raise
1818
1818
    def lock_tree_write(self):
1819
1819
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
1820
 
1821
 
        :return: An object with an unlock method which will release the lock
1822
 
            obtained.
 
1821
        :return: A bzrlib.lock.LogicalLockResult.
1823
1822
        """
1824
1823
        if not self.is_locked():
1825
1824
            self._reset_data()
1826
1825
        self.branch.lock_read()
1827
1826
        try:
1828
1827
            self._control_files.lock_write()
1829
 
            return self
 
1828
            return LogicalLockResult(self.unlock)
1830
1829
        except:
1831
1830
            self.branch.unlock()
1832
1831
            raise
1834
1833
    def lock_write(self):
1835
1834
        """See MutableTree.lock_write, and WorkingTree.unlock.
1836
1835
 
1837
 
        :return: An object with an unlock method which will release the lock
1838
 
            obtained.
 
1836
        :return: A bzrlib.lock.LogicalLockResult.
1839
1837
        """
1840
1838
        if not self.is_locked():
1841
1839
            self._reset_data()
1842
1840
        self.branch.lock_write()
1843
1841
        try:
1844
1842
            self._control_files.lock_write()
1845
 
            return self
 
1843
            return LogicalLockResult(self.unlock)
1846
1844
        except:
1847
1845
            self.branch.unlock()
1848
1846
            raise