~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Pool
  • Date: 2010-07-17 16:46:44 UTC
  • mto: (5050.3.10 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: mbp@canonical.com-20100717164644-uu4uhamdunf3mxzc
One more UI test needs updates for spinner being at the front

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    revisiontree,
62
62
    trace,
63
63
    transform,
 
64
    transport,
64
65
    ui,
65
66
    views,
66
67
    xml5,
67
68
    xml7,
68
69
    )
69
 
import bzrlib.branch
70
 
from bzrlib.transport import get_transport
71
70
from bzrlib.workingtree_4 import (
72
71
    WorkingTreeFormat4,
73
72
    WorkingTreeFormat5,
77
76
 
78
77
from bzrlib import symbol_versioning
79
78
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
79
from bzrlib.lock import LogicalLockResult
80
80
from bzrlib.lockable_files import LockableFiles
81
81
from bzrlib.lockdir import LockDir
82
82
import bzrlib.mutabletree
176
176
 
177
177
    It is possible for a `WorkingTree` to have a filename which is
178
178
    not listed in the Inventory and vice versa.
 
179
 
 
180
    :ivar basedir: The root of the tree on disk. This is a unicode path object
 
181
        (as opposed to a URL).
179
182
    """
180
183
 
181
184
    # override this to set the strategy for storing views
368
371
                return True, None
369
372
            else:
370
373
                return True, tree
371
 
        transport = get_transport(location)
372
 
        iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,
 
374
        t = transport.get_transport(location)
 
375
        iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
373
376
                                              list_current=list_current)
374
 
        return [t for t in iterator if t is not None]
 
377
        return [tr for tr in iterator if tr is not None]
375
378
 
376
379
    # should be deprecated - this is slow and in any case treating them as a
377
380
    # container is (we now know) bad style -- mbp 20070302
462
465
        return (file_obj, stat_value)
463
466
 
464
467
    def get_file_text(self, file_id, path=None, filtered=True):
465
 
        return self.get_file(file_id, path=path, filtered=filtered).read()
 
468
        my_file = self.get_file(file_id, path=path, filtered=filtered)
 
469
        try:
 
470
            return my_file.read()
 
471
        finally:
 
472
            my_file.close()
466
473
 
467
474
    def get_file_byname(self, filename, filtered=True):
468
475
        path = self.abspath(filename)
522
529
 
523
530
        # Now we have the parents of this content
524
531
        annotator = self.branch.repository.texts.get_annotator()
525
 
        text = self.get_file(file_id).read()
 
532
        text = self.get_file_text(file_id)
526
533
        this_key =(file_id, default_revision)
527
534
        annotator.add_special_text(this_key, file_parent_keys, text)
528
535
        annotations = [(key[-1], line)
1802
1809
 
1803
1810
        This also locks the branch, and can be unlocked via self.unlock().
1804
1811
 
1805
 
        :return: An object with an unlock method which will release the lock
1806
 
            obtained.
 
1812
        :return: A bzrlib.lock.LogicalLockResult.
1807
1813
        """
1808
1814
        if not self.is_locked():
1809
1815
            self._reset_data()
1810
1816
        self.branch.lock_read()
1811
1817
        try:
1812
1818
            self._control_files.lock_read()
1813
 
            return self
 
1819
            return LogicalLockResult(self.unlock)
1814
1820
        except:
1815
1821
            self.branch.unlock()
1816
1822
            raise
1818
1824
    def lock_tree_write(self):
1819
1825
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
1826
 
1821
 
        :return: An object with an unlock method which will release the lock
1822
 
            obtained.
 
1827
        :return: A bzrlib.lock.LogicalLockResult.
1823
1828
        """
1824
1829
        if not self.is_locked():
1825
1830
            self._reset_data()
1826
1831
        self.branch.lock_read()
1827
1832
        try:
1828
1833
            self._control_files.lock_write()
1829
 
            return self
 
1834
            return LogicalLockResult(self.unlock)
1830
1835
        except:
1831
1836
            self.branch.unlock()
1832
1837
            raise
1834
1839
    def lock_write(self):
1835
1840
        """See MutableTree.lock_write, and WorkingTree.unlock.
1836
1841
 
1837
 
        :return: An object with an unlock method which will release the lock
1838
 
            obtained.
 
1842
        :return: A bzrlib.lock.LogicalLockResult.
1839
1843
        """
1840
1844
        if not self.is_locked():
1841
1845
            self._reset_data()
1842
1846
        self.branch.lock_write()
1843
1847
        try:
1844
1848
            self._control_files.lock_write()
1845
 
            return self
 
1849
            return LogicalLockResult(self.unlock)
1846
1850
        except:
1847
1851
            self.branch.unlock()
1848
1852
            raise
1973
1977
        def recurse_directory_to_add_files(directory):
1974
1978
            # Recurse directory and add all files
1975
1979
            # so we can check if they have changed.
1976
 
            for parent_info, file_infos in\
1977
 
                self.walkdirs(directory):
 
1980
            for parent_info, file_infos in self.walkdirs(directory):
1978
1981
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1979
1982
                    # Is it versioned or ignored?
1980
1983
                    if self.path2id(relpath) or self.is_ignored(relpath):
2015
2018
                            # ... but not ignored
2016
2019
                            has_changed_files = True
2017
2020
                            break
2018
 
                    elif content_change and (kind[1] is not None):
2019
 
                        # Versioned and changed, but not deleted
 
2021
                    elif (content_change and (kind[1] is not None) and
 
2022
                            osutils.is_inside_any(files, path[1])):
 
2023
                        # Versioned and changed, but not deleted, and still
 
2024
                        # in one of the dirs to be deleted.
2020
2025
                        has_changed_files = True
2021
2026
                        break
2022
2027