~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

(lifeless) Generalise probing for executables used in selftest. (Martin von
 Gagern)

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
462
463
        return (file_obj, stat_value)
463
464
 
464
465
    def get_file_text(self, file_id, path=None, filtered=True):
465
 
        return self.get_file(file_id, path=path, filtered=filtered).read()
 
466
        my_file = self.get_file(file_id, path=path, filtered=filtered)
 
467
        try:
 
468
            return my_file.read()
 
469
        finally:
 
470
            my_file.close()
466
471
 
467
472
    def get_file_byname(self, filename, filtered=True):
468
473
        path = self.abspath(filename)
1802
1807
 
1803
1808
        This also locks the branch, and can be unlocked via self.unlock().
1804
1809
 
1805
 
        :return: An object with an unlock method which will release the lock
1806
 
            obtained.
 
1810
        :return: A bzrlib.lock.LogicalLockResult.
1807
1811
        """
1808
1812
        if not self.is_locked():
1809
1813
            self._reset_data()
1810
1814
        self.branch.lock_read()
1811
1815
        try:
1812
1816
            self._control_files.lock_read()
1813
 
            return self
 
1817
            return LogicalLockResult(self.unlock)
1814
1818
        except:
1815
1819
            self.branch.unlock()
1816
1820
            raise
1818
1822
    def lock_tree_write(self):
1819
1823
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
1824
 
1821
 
        :return: An object with an unlock method which will release the lock
1822
 
            obtained.
 
1825
        :return: A bzrlib.lock.LogicalLockResult.
1823
1826
        """
1824
1827
        if not self.is_locked():
1825
1828
            self._reset_data()
1826
1829
        self.branch.lock_read()
1827
1830
        try:
1828
1831
            self._control_files.lock_write()
1829
 
            return self
 
1832
            return LogicalLockResult(self.unlock)
1830
1833
        except:
1831
1834
            self.branch.unlock()
1832
1835
            raise
1834
1837
    def lock_write(self):
1835
1838
        """See MutableTree.lock_write, and WorkingTree.unlock.
1836
1839
 
1837
 
        :return: An object with an unlock method which will release the lock
1838
 
            obtained.
 
1840
        :return: A bzrlib.lock.LogicalLockResult.
1839
1841
        """
1840
1842
        if not self.is_locked():
1841
1843
            self._reset_data()
1842
1844
        self.branch.lock_write()
1843
1845
        try:
1844
1846
            self._control_files.lock_write()
1845
 
            return self
 
1847
            return LogicalLockResult(self.unlock)
1846
1848
        except:
1847
1849
            self.branch.unlock()
1848
1850
            raise
1973
1975
        def recurse_directory_to_add_files(directory):
1974
1976
            # Recurse directory and add all files
1975
1977
            # so we can check if they have changed.
1976
 
            for parent_info, file_infos in\
1977
 
                self.walkdirs(directory):
 
1978
            for parent_info, file_infos in self.walkdirs(directory):
1978
1979
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1979
1980
                    # Is it versioned or ignored?
1980
1981
                    if self.path2id(relpath) or self.is_ignored(relpath):
2015
2016
                            # ... but not ignored
2016
2017
                            has_changed_files = True
2017
2018
                            break
2018
 
                    elif content_change and (kind[1] is not None):
2019
 
                        # Versioned and changed, but not deleted
 
2019
                    elif (content_change and (kind[1] is not None) and
 
2020
                            osutils.is_inside_any(files, path[1])):
 
2021
                        # Versioned and changed, but not deleted, and still
 
2022
                        # in one of the dirs to be deleted.
2020
2023
                        has_changed_files = True
2021
2024
                        break
2022
2025