~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:54:05 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506235405-wii4elupfhzl3jvy
Add __str__ to the new helper classes.

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