~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin
  • Date: 2010-05-16 15:18:43 UTC
  • mfrom: (5235 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5239.
  • Revision ID: gzlist@googlemail.com-20100516151843-lu53u7caehm3ie3i
Merge bzr.dev to resolve conflicts in NEWS and _chk_map_pyx

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
WorkingTree.open(dir).
30
30
"""
31
31
 
32
 
# TODO: Give the workingtree sole responsibility for the working inventory;
33
 
# remove the variable and references to it from the branch.  This may require
34
 
# updating the commit code so as to update the inventory within the working
35
 
# copy, and making sure there's only one WorkingTree for any directory on disk.
36
 
# At the moment they may alias the inventory and have old copies of it in
37
 
# memory.  (Now done? -- mbp 20060309)
38
32
 
39
33
from cStringIO import StringIO
40
34
import os
83
77
 
84
78
from bzrlib import symbol_versioning
85
79
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
80
from bzrlib.lock import LogicalLockResult
86
81
from bzrlib.lockable_files import LockableFiles
87
82
from bzrlib.lockdir import LockDir
88
83
import bzrlib.mutabletree
101
96
from bzrlib.filters import filtered_input_file
102
97
from bzrlib.trace import mutter, note
103
98
from bzrlib.transport.local import LocalTransport
104
 
from bzrlib.progress import ProgressPhase
105
99
from bzrlib.revision import CURRENT_REVISION
106
100
from bzrlib.rio import RioReader, rio_file, Stanza
107
101
from bzrlib.symbol_versioning import (
174
168
        return ''
175
169
 
176
170
 
177
 
class WorkingTree(bzrlib.mutabletree.MutableTree):
 
171
class WorkingTree(bzrlib.mutabletree.MutableTree,
 
172
    bzrdir.ControlComponent):
178
173
    """Working copy tree.
179
174
 
180
175
    The inventory is held in the `Branch` working-inventory, and the
253
248
        self._rules_searcher = None
254
249
        self.views = self._make_views()
255
250
 
 
251
    @property
 
252
    def user_transport(self):
 
253
        return self.bzrdir.user_transport
 
254
 
 
255
    @property
 
256
    def control_transport(self):
 
257
        return self._transport
 
258
 
256
259
    def _detect_case_handling(self):
257
260
        wt_trans = self.bzrdir.get_workingtree_transport(None)
258
261
        try:
1796
1799
            raise errors.ObjectNotLocked(self)
1797
1800
 
1798
1801
    def lock_read(self):
1799
 
        """See Branch.lock_read, and WorkingTree.unlock."""
 
1802
        """Lock the tree for reading.
 
1803
 
 
1804
        This also locks the branch, and can be unlocked via self.unlock().
 
1805
 
 
1806
        :return: A bzrlib.lock.LogicalLockResult.
 
1807
        """
1800
1808
        if not self.is_locked():
1801
1809
            self._reset_data()
1802
1810
        self.branch.lock_read()
1803
1811
        try:
1804
 
            return self._control_files.lock_read()
 
1812
            self._control_files.lock_read()
 
1813
            return LogicalLockResult(self.unlock)
1805
1814
        except:
1806
1815
            self.branch.unlock()
1807
1816
            raise
1808
1817
 
1809
1818
    def lock_tree_write(self):
1810
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
 
1819
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
 
1820
 
 
1821
        :return: A bzrlib.lock.LogicalLockResult.
 
1822
        """
1811
1823
        if not self.is_locked():
1812
1824
            self._reset_data()
1813
1825
        self.branch.lock_read()
1814
1826
        try:
1815
 
            return self._control_files.lock_write()
 
1827
            self._control_files.lock_write()
 
1828
            return LogicalLockResult(self.unlock)
1816
1829
        except:
1817
1830
            self.branch.unlock()
1818
1831
            raise
1819
1832
 
1820
1833
    def lock_write(self):
1821
 
        """See MutableTree.lock_write, and WorkingTree.unlock."""
 
1834
        """See MutableTree.lock_write, and WorkingTree.unlock.
 
1835
 
 
1836
        :return: A bzrlib.lock.LogicalLockResult.
 
1837
        """
1822
1838
        if not self.is_locked():
1823
1839
            self._reset_data()
1824
1840
        self.branch.lock_write()
1825
1841
        try:
1826
 
            return self._control_files.lock_write()
 
1842
            self._control_files.lock_write()
 
1843
            return LogicalLockResult(self.unlock)
1827
1844
        except:
1828
1845
            self.branch.unlock()
1829
1846
            raise
1954
1971
        def recurse_directory_to_add_files(directory):
1955
1972
            # Recurse directory and add all files
1956
1973
            # so we can check if they have changed.
1957
 
            for parent_info, file_infos in\
1958
 
                self.walkdirs(directory):
 
1974
            for parent_info, file_infos in self.walkdirs(directory):
1959
1975
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1960
1976
                    # Is it versioned or ignored?
1961
1977
                    if self.path2id(relpath) or self.is_ignored(relpath):
1996
2012
                            # ... but not ignored
1997
2013
                            has_changed_files = True
1998
2014
                            break
1999
 
                    elif content_change and (kind[1] is not None):
2000
 
                        # Versioned and changed, but not deleted
 
2015
                    elif (content_change and (kind[1] is not None) and
 
2016
                            osutils.is_inside_any(files, path[1])):
 
2017
                        # Versioned and changed, but not deleted, and still
 
2018
                        # in one of the dirs to be deleted.
2001
2019
                        has_changed_files = True
2002
2020
                        break
2003
2021
 
2634
2652
 
2635
2653
        In Format2 WorkingTrees we have a single lock for the branch and tree
2636
2654
        so lock_tree_write() degrades to lock_write().
 
2655
 
 
2656
        :return: An object with an unlock method which will release the lock
 
2657
            obtained.
2637
2658
        """
2638
2659
        self.branch.lock_write()
2639
2660
        try:
2640
 
            return self._control_files.lock_write()
 
2661
            self._control_files.lock_write()
 
2662
            return self
2641
2663
        except:
2642
2664
            self.branch.unlock()
2643
2665
            raise