/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

Merge cleanup into texinfo

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
95
95
from bzrlib.filters import filtered_input_file
96
96
from bzrlib.trace import mutter, note
97
97
from bzrlib.transport.local import LocalTransport
98
 
from bzrlib.progress import ProgressPhase
99
98
from bzrlib.revision import CURRENT_REVISION
100
99
from bzrlib.rio import RioReader, rio_file, Stanza
101
100
from bzrlib.symbol_versioning import (
369
368
                return True, None
370
369
            else:
371
370
                return True, tree
372
 
        transport = get_transport(location)
373
 
        iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,
 
371
        t = transport.get_transport(location)
 
372
        iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
374
373
                                              list_current=list_current)
375
 
        return [t for t in iterator if t is not None]
 
374
        return [tr for tr in iterator if tr is not None]
376
375
 
377
376
    # should be deprecated - this is slow and in any case treating them as a
378
377
    # container is (we now know) bad style -- mbp 20070302
463
462
        return (file_obj, stat_value)
464
463
 
465
464
    def get_file_text(self, file_id, path=None, filtered=True):
466
 
        return self.get_file(file_id, path=path, filtered=filtered).read()
 
465
        my_file = self.get_file(file_id, path=path, filtered=filtered)
 
466
        try:
 
467
            return my_file.read()
 
468
        finally:
 
469
            my_file.close()
467
470
 
468
471
    def get_file_byname(self, filename, filtered=True):
469
472
        path = self.abspath(filename)
523
526
 
524
527
        # Now we have the parents of this content
525
528
        annotator = self.branch.repository.texts.get_annotator()
526
 
        text = self.get_file(file_id).read()
 
529
        text = self.get_file_text(file_id)
527
530
        this_key =(file_id, default_revision)
528
531
        annotator.add_special_text(this_key, file_parent_keys, text)
529
532
        annotations = [(key[-1], line)
1799
1802
            raise errors.ObjectNotLocked(self)
1800
1803
 
1801
1804
    def lock_read(self):
1802
 
        """See Branch.lock_read, and WorkingTree.unlock."""
 
1805
        """Lock the tree for reading.
 
1806
 
 
1807
        This also locks the branch, and can be unlocked via self.unlock().
 
1808
 
 
1809
        :return: A bzrlib.lock.LogicalLockResult.
 
1810
        """
1803
1811
        if not self.is_locked():
1804
1812
            self._reset_data()
1805
1813
        self.branch.lock_read()
1806
1814
        try:
1807
 
            return self._control_files.lock_read()
 
1815
            self._control_files.lock_read()
 
1816
            return LogicalLockResult(self.unlock)
1808
1817
        except:
1809
1818
            self.branch.unlock()
1810
1819
            raise
1811
1820
 
1812
1821
    def lock_tree_write(self):
1813
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
 
1822
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
 
1823
 
 
1824
        :return: A bzrlib.lock.LogicalLockResult.
 
1825
        """
1814
1826
        if not self.is_locked():
1815
1827
            self._reset_data()
1816
1828
        self.branch.lock_read()
1817
1829
        try:
1818
 
            return self._control_files.lock_write()
 
1830
            self._control_files.lock_write()
 
1831
            return LogicalLockResult(self.unlock)
1819
1832
        except:
1820
1833
            self.branch.unlock()
1821
1834
            raise
1822
1835
 
1823
1836
    def lock_write(self):
1824
 
        """See MutableTree.lock_write, and WorkingTree.unlock."""
 
1837
        """See MutableTree.lock_write, and WorkingTree.unlock.
 
1838
 
 
1839
        :return: A bzrlib.lock.LogicalLockResult.
 
1840
        """
1825
1841
        if not self.is_locked():
1826
1842
            self._reset_data()
1827
1843
        self.branch.lock_write()
1828
1844
        try:
1829
 
            return self._control_files.lock_write()
 
1845
            self._control_files.lock_write()
 
1846
            return LogicalLockResult(self.unlock)
1830
1847
        except:
1831
1848
            self.branch.unlock()
1832
1849
            raise
1957
1974
        def recurse_directory_to_add_files(directory):
1958
1975
            # Recurse directory and add all files
1959
1976
            # so we can check if they have changed.
1960
 
            for parent_info, file_infos in\
1961
 
                self.walkdirs(directory):
 
1977
            for parent_info, file_infos in self.walkdirs(directory):
1962
1978
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1963
1979
                    # Is it versioned or ignored?
1964
1980
                    if self.path2id(relpath) or self.is_ignored(relpath):
1999
2015
                            # ... but not ignored
2000
2016
                            has_changed_files = True
2001
2017
                            break
2002
 
                    elif content_change and (kind[1] is not None):
2003
 
                        # Versioned and changed, but not deleted
 
2018
                    elif (content_change and (kind[1] is not None) and
 
2019
                            osutils.is_inside_any(files, path[1])):
 
2020
                        # Versioned and changed, but not deleted, and still
 
2021
                        # in one of the dirs to be deleted.
2004
2022
                        has_changed_files = True
2005
2023
                        break
2006
2024
 
2637
2655
 
2638
2656
        In Format2 WorkingTrees we have a single lock for the branch and tree
2639
2657
        so lock_tree_write() degrades to lock_write().
 
2658
 
 
2659
        :return: An object with an unlock method which will release the lock
 
2660
            obtained.
2640
2661
        """
2641
2662
        self.branch.lock_write()
2642
2663
        try:
2643
 
            return self._control_files.lock_write()
 
2664
            self._control_files.lock_write()
 
2665
            return self
2644
2666
        except:
2645
2667
            self.branch.unlock()
2646
2668
            raise