/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.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
1798
1799
            raise errors.ObjectNotLocked(self)
1799
1800
 
1800
1801
    def lock_read(self):
1801
 
        """See Branch.lock_read, and WorkingTree.unlock."""
 
1802
        """Lock the tree for reading.
 
1803
 
 
1804
        This also locks the branch, and can be unlocked via self.unlock().
 
1805
 
 
1806
        :return: A bzrlib.lock.LogicalLockResult.
 
1807
        """
1802
1808
        if not self.is_locked():
1803
1809
            self._reset_data()
1804
1810
        self.branch.lock_read()
1805
1811
        try:
1806
 
            return self._control_files.lock_read()
 
1812
            self._control_files.lock_read()
 
1813
            return LogicalLockResult(self.unlock)
1807
1814
        except:
1808
1815
            self.branch.unlock()
1809
1816
            raise
1810
1817
 
1811
1818
    def lock_tree_write(self):
1812
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
 
1819
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
 
1820
 
 
1821
        :return: A bzrlib.lock.LogicalLockResult.
 
1822
        """
1813
1823
        if not self.is_locked():
1814
1824
            self._reset_data()
1815
1825
        self.branch.lock_read()
1816
1826
        try:
1817
 
            return self._control_files.lock_write()
 
1827
            self._control_files.lock_write()
 
1828
            return LogicalLockResult(self.unlock)
1818
1829
        except:
1819
1830
            self.branch.unlock()
1820
1831
            raise
1821
1832
 
1822
1833
    def lock_write(self):
1823
 
        """See MutableTree.lock_write, and WorkingTree.unlock."""
 
1834
        """See MutableTree.lock_write, and WorkingTree.unlock.
 
1835
 
 
1836
        :return: A bzrlib.lock.LogicalLockResult.
 
1837
        """
1824
1838
        if not self.is_locked():
1825
1839
            self._reset_data()
1826
1840
        self.branch.lock_write()
1827
1841
        try:
1828
 
            return self._control_files.lock_write()
 
1842
            self._control_files.lock_write()
 
1843
            return LogicalLockResult(self.unlock)
1829
1844
        except:
1830
1845
            self.branch.unlock()
1831
1846
            raise
2636
2651
 
2637
2652
        In Format2 WorkingTrees we have a single lock for the branch and tree
2638
2653
        so lock_tree_write() degrades to lock_write().
 
2654
 
 
2655
        :return: An object with an unlock method which will release the lock
 
2656
            obtained.
2639
2657
        """
2640
2658
        self.branch.lock_write()
2641
2659
        try:
2642
 
            return self._control_files.lock_write()
 
2660
            self._control_files.lock_write()
 
2661
            return self
2643
2662
        except:
2644
2663
            self.branch.unlock()
2645
2664
            raise