/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-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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
81
80
from bzrlib.lockable_files import LockableFiles
82
81
from bzrlib.lockdir import LockDir
83
82
import bzrlib.mutabletree
1799
1798
            raise errors.ObjectNotLocked(self)
1800
1799
 
1801
1800
    def lock_read(self):
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
 
        """
 
1801
        """See Branch.lock_read, and WorkingTree.unlock."""
1808
1802
        if not self.is_locked():
1809
1803
            self._reset_data()
1810
1804
        self.branch.lock_read()
1811
1805
        try:
1812
 
            self._control_files.lock_read()
1813
 
            return LogicalLockResult(self.unlock)
 
1806
            return self._control_files.lock_read()
1814
1807
        except:
1815
1808
            self.branch.unlock()
1816
1809
            raise
1817
1810
 
1818
1811
    def lock_tree_write(self):
1819
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
 
 
1821
 
        :return: A bzrlib.lock.LogicalLockResult.
1822
 
        """
 
1812
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
1823
1813
        if not self.is_locked():
1824
1814
            self._reset_data()
1825
1815
        self.branch.lock_read()
1826
1816
        try:
1827
 
            self._control_files.lock_write()
1828
 
            return LogicalLockResult(self.unlock)
 
1817
            return self._control_files.lock_write()
1829
1818
        except:
1830
1819
            self.branch.unlock()
1831
1820
            raise
1832
1821
 
1833
1822
    def lock_write(self):
1834
 
        """See MutableTree.lock_write, and WorkingTree.unlock.
1835
 
 
1836
 
        :return: A bzrlib.lock.LogicalLockResult.
1837
 
        """
 
1823
        """See MutableTree.lock_write, and WorkingTree.unlock."""
1838
1824
        if not self.is_locked():
1839
1825
            self._reset_data()
1840
1826
        self.branch.lock_write()
1841
1827
        try:
1842
 
            self._control_files.lock_write()
1843
 
            return LogicalLockResult(self.unlock)
 
1828
            return self._control_files.lock_write()
1844
1829
        except:
1845
1830
            self.branch.unlock()
1846
1831
            raise
1971
1956
        def recurse_directory_to_add_files(directory):
1972
1957
            # Recurse directory and add all files
1973
1958
            # so we can check if they have changed.
1974
 
            for parent_info, file_infos in self.walkdirs(directory):
 
1959
            for parent_info, file_infos in\
 
1960
                self.walkdirs(directory):
1975
1961
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1976
1962
                    # Is it versioned or ignored?
1977
1963
                    if self.path2id(relpath) or self.is_ignored(relpath):
2012
1998
                            # ... but not ignored
2013
1999
                            has_changed_files = True
2014
2000
                            break
2015
 
                    elif (content_change and (kind[1] is not None) and
2016
 
                            osutils.is_inside_any(files, path[1])):
2017
 
                        # Versioned and changed, but not deleted, and still
2018
 
                        # in one of the dirs to be deleted.
 
2001
                    elif content_change and (kind[1] is not None):
 
2002
                        # Versioned and changed, but not deleted
2019
2003
                        has_changed_files = True
2020
2004
                        break
2021
2005
 
2652
2636
 
2653
2637
        In Format2 WorkingTrees we have a single lock for the branch and tree
2654
2638
        so lock_tree_write() degrades to lock_write().
2655
 
 
2656
 
        :return: An object with an unlock method which will release the lock
2657
 
            obtained.
2658
2639
        """
2659
2640
        self.branch.lock_write()
2660
2641
        try:
2661
 
            self._control_files.lock_write()
2662
 
            return self
 
2642
            return self._control_files.lock_write()
2663
2643
        except:
2664
2644
            self.branch.unlock()
2665
2645
            raise