~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Pool
  • Date: 2010-07-18 14:52:26 UTC
  • mto: (5414.1.1 deprecation)
  • mto: This revision was merged to the branch mainline in revision 5363.
  • Revision ID: mbp@canonical.com-20100718145226-921tgdv8n7o3ynp6
Delete deprecated inventory methods and classes

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)
1257
1264
                stack.pop()
1258
1265
 
1259
1266
    @needs_tree_write_lock
1260
 
    def move(self, from_paths, to_dir=None, after=False, **kwargs):
 
1267
    def move(self, from_paths, to_dir=None, after=False):
1261
1268
        """Rename files.
1262
1269
 
1263
1270
        to_dir must exist in the inventory.
1297
1304
 
1298
1305
        # check for deprecated use of signature
1299
1306
        if to_dir is None:
1300
 
            to_dir = kwargs.get('to_name', None)
1301
 
            if to_dir is None:
1302
 
                raise TypeError('You must supply a target directory')
1303
 
            else:
1304
 
                symbol_versioning.warn('The parameter to_name was deprecated'
1305
 
                                       ' in version 0.13. Use to_dir instead',
1306
 
                                       DeprecationWarning)
1307
 
 
 
1307
            raise TypeError('You must supply a target directory')
1308
1308
        # check destination directory
1309
1309
        if isinstance(from_paths, basestring):
1310
1310
            raise ValueError()
1802
1802
 
1803
1803
        This also locks the branch, and can be unlocked via self.unlock().
1804
1804
 
1805
 
        :return: An object with an unlock method which will release the lock
1806
 
            obtained.
 
1805
        :return: A bzrlib.lock.LogicalLockResult.
1807
1806
        """
1808
1807
        if not self.is_locked():
1809
1808
            self._reset_data()
1810
1809
        self.branch.lock_read()
1811
1810
        try:
1812
1811
            self._control_files.lock_read()
1813
 
            return self
 
1812
            return LogicalLockResult(self.unlock)
1814
1813
        except:
1815
1814
            self.branch.unlock()
1816
1815
            raise
1818
1817
    def lock_tree_write(self):
1819
1818
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
1819
 
1821
 
        :return: An object with an unlock method which will release the lock
1822
 
            obtained.
 
1820
        :return: A bzrlib.lock.LogicalLockResult.
1823
1821
        """
1824
1822
        if not self.is_locked():
1825
1823
            self._reset_data()
1826
1824
        self.branch.lock_read()
1827
1825
        try:
1828
1826
            self._control_files.lock_write()
1829
 
            return self
 
1827
            return LogicalLockResult(self.unlock)
1830
1828
        except:
1831
1829
            self.branch.unlock()
1832
1830
            raise
1834
1832
    def lock_write(self):
1835
1833
        """See MutableTree.lock_write, and WorkingTree.unlock.
1836
1834
 
1837
 
        :return: An object with an unlock method which will release the lock
1838
 
            obtained.
 
1835
        :return: A bzrlib.lock.LogicalLockResult.
1839
1836
        """
1840
1837
        if not self.is_locked():
1841
1838
            self._reset_data()
1842
1839
        self.branch.lock_write()
1843
1840
        try:
1844
1841
            self._control_files.lock_write()
1845
 
            return self
 
1842
            return LogicalLockResult(self.unlock)
1846
1843
        except:
1847
1844
            self.branch.unlock()
1848
1845
            raise
1973
1970
        def recurse_directory_to_add_files(directory):
1974
1971
            # Recurse directory and add all files
1975
1972
            # so we can check if they have changed.
1976
 
            for parent_info, file_infos in\
1977
 
                self.walkdirs(directory):
 
1973
            for parent_info, file_infos in self.walkdirs(directory):
1978
1974
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1979
1975
                    # Is it versioned or ignored?
1980
1976
                    if self.path2id(relpath) or self.is_ignored(relpath):
2015
2011
                            # ... but not ignored
2016
2012
                            has_changed_files = True
2017
2013
                            break
2018
 
                    elif content_change and (kind[1] is not None):
2019
 
                        # Versioned and changed, but not deleted
 
2014
                    elif (content_change and (kind[1] is not None) and
 
2015
                            osutils.is_inside_any(files, path[1])):
 
2016
                        # Versioned and changed, but not deleted, and still
 
2017
                        # in one of the dirs to be deleted.
2020
2018
                        has_changed_files = True
2021
2019
                        break
2022
2020