/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-06-25 20:34:05 UTC
  • mto: This revision was merged to the branch mainline in revision 5324.
  • Revision ID: robertc@robertcollins.net-20100625203405-c74lxd3enklhaqf9
``bzrlib.osutils.get_terminal_encoding`` will now only mutter its
selection when explicitly requested; this avoids many duplicate calls
being logged when helpers, wrappers and older code that manually calls
it are executed it is now logged deliberately by the ui setup code.
(Robert Collins)

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)
522
527
 
523
528
        # Now we have the parents of this content
524
529
        annotator = self.branch.repository.texts.get_annotator()
525
 
        text = self.get_file(file_id).read()
 
530
        text = self.get_file_text(file_id)
526
531
        this_key =(file_id, default_revision)
527
532
        annotator.add_special_text(this_key, file_parent_keys, text)
528
533
        annotations = [(key[-1], line)
1798
1803
            raise errors.ObjectNotLocked(self)
1799
1804
 
1800
1805
    def lock_read(self):
1801
 
        """See Branch.lock_read, and WorkingTree.unlock."""
 
1806
        """Lock the tree for reading.
 
1807
 
 
1808
        This also locks the branch, and can be unlocked via self.unlock().
 
1809
 
 
1810
        :return: A bzrlib.lock.LogicalLockResult.
 
1811
        """
1802
1812
        if not self.is_locked():
1803
1813
            self._reset_data()
1804
1814
        self.branch.lock_read()
1805
1815
        try:
1806
 
            return self._control_files.lock_read()
 
1816
            self._control_files.lock_read()
 
1817
            return LogicalLockResult(self.unlock)
1807
1818
        except:
1808
1819
            self.branch.unlock()
1809
1820
            raise
1810
1821
 
1811
1822
    def lock_tree_write(self):
1812
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
 
1823
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
 
1824
 
 
1825
        :return: A bzrlib.lock.LogicalLockResult.
 
1826
        """
1813
1827
        if not self.is_locked():
1814
1828
            self._reset_data()
1815
1829
        self.branch.lock_read()
1816
1830
        try:
1817
 
            return self._control_files.lock_write()
 
1831
            self._control_files.lock_write()
 
1832
            return LogicalLockResult(self.unlock)
1818
1833
        except:
1819
1834
            self.branch.unlock()
1820
1835
            raise
1821
1836
 
1822
1837
    def lock_write(self):
1823
 
        """See MutableTree.lock_write, and WorkingTree.unlock."""
 
1838
        """See MutableTree.lock_write, and WorkingTree.unlock.
 
1839
 
 
1840
        :return: A bzrlib.lock.LogicalLockResult.
 
1841
        """
1824
1842
        if not self.is_locked():
1825
1843
            self._reset_data()
1826
1844
        self.branch.lock_write()
1827
1845
        try:
1828
 
            return self._control_files.lock_write()
 
1846
            self._control_files.lock_write()
 
1847
            return LogicalLockResult(self.unlock)
1829
1848
        except:
1830
1849
            self.branch.unlock()
1831
1850
            raise
1956
1975
        def recurse_directory_to_add_files(directory):
1957
1976
            # Recurse directory and add all files
1958
1977
            # so we can check if they have changed.
1959
 
            for parent_info, file_infos in\
1960
 
                self.walkdirs(directory):
 
1978
            for parent_info, file_infos in self.walkdirs(directory):
1961
1979
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1962
1980
                    # Is it versioned or ignored?
1963
1981
                    if self.path2id(relpath) or self.is_ignored(relpath):
1998
2016
                            # ... but not ignored
1999
2017
                            has_changed_files = True
2000
2018
                            break
2001
 
                    elif content_change and (kind[1] is not None):
2002
 
                        # 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.
2003
2023
                        has_changed_files = True
2004
2024
                        break
2005
2025
 
2636
2656
 
2637
2657
        In Format2 WorkingTrees we have a single lock for the branch and tree
2638
2658
        so lock_tree_write() degrades to lock_write().
 
2659
 
 
2660
        :return: An object with an unlock method which will release the lock
 
2661
            obtained.
2639
2662
        """
2640
2663
        self.branch.lock_write()
2641
2664
        try:
2642
 
            return self._control_files.lock_write()
 
2665
            self._control_files.lock_write()
 
2666
            return self
2643
2667
        except:
2644
2668
            self.branch.unlock()
2645
2669
            raise