~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

Rearrange log opening helper function and fix a couple of bugs

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)
32
38
 
33
39
from cStringIO import StringIO
34
40
import os
95
101
from bzrlib.filters import filtered_input_file
96
102
from bzrlib.trace import mutter, note
97
103
from bzrlib.transport.local import LocalTransport
 
104
from bzrlib.progress import ProgressPhase
98
105
from bzrlib.revision import CURRENT_REVISION
99
106
from bzrlib.rio import RioReader, rio_file, Stanza
100
107
from bzrlib.symbol_versioning import (
167
174
        return ''
168
175
 
169
176
 
170
 
class WorkingTree(bzrlib.mutabletree.MutableTree,
171
 
    bzrdir.ControlComponent):
 
177
class WorkingTree(bzrlib.mutabletree.MutableTree):
172
178
    """Working copy tree.
173
179
 
174
180
    The inventory is held in the `Branch` working-inventory, and the
247
253
        self._rules_searcher = None
248
254
        self.views = self._make_views()
249
255
 
250
 
    @property
251
 
    def user_transport(self):
252
 
        return self.bzrdir.user_transport
253
 
 
254
 
    @property
255
 
    def control_transport(self):
256
 
        return self._transport
257
 
 
258
256
    def _detect_case_handling(self):
259
257
        wt_trans = self.bzrdir.get_workingtree_transport(None)
260
258
        try:
1141
1139
        This does not include files that have been deleted in this
1142
1140
        tree. Skips the control directory.
1143
1141
 
1144
 
        :param include_root: if True, return an entry for the root
 
1142
        :param include_root: if True, do not return an entry for the root
1145
1143
        :param from_dir: start from this directory or None for the root
1146
1144
        :param recursive: whether to recurse into subdirectories or not
1147
1145
        """
1798
1796
            raise errors.ObjectNotLocked(self)
1799
1797
 
1800
1798
    def lock_read(self):
1801
 
        """Lock the tree for reading.
1802
 
 
1803
 
        This also locks the branch, and can be unlocked via self.unlock().
1804
 
 
1805
 
        :return: An object with an unlock method which will release the lock
1806
 
            obtained.
1807
 
        """
 
1799
        """See Branch.lock_read, and WorkingTree.unlock."""
1808
1800
        if not self.is_locked():
1809
1801
            self._reset_data()
1810
1802
        self.branch.lock_read()
1811
1803
        try:
1812
 
            self._control_files.lock_read()
1813
 
            return self
 
1804
            return self._control_files.lock_read()
1814
1805
        except:
1815
1806
            self.branch.unlock()
1816
1807
            raise
1817
1808
 
1818
1809
    def lock_tree_write(self):
1819
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
 
 
1821
 
        :return: An object with an unlock method which will release the lock
1822
 
            obtained.
1823
 
        """
 
1810
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
1824
1811
        if not self.is_locked():
1825
1812
            self._reset_data()
1826
1813
        self.branch.lock_read()
1827
1814
        try:
1828
 
            self._control_files.lock_write()
1829
 
            return self
 
1815
            return self._control_files.lock_write()
1830
1816
        except:
1831
1817
            self.branch.unlock()
1832
1818
            raise
1833
1819
 
1834
1820
    def lock_write(self):
1835
 
        """See MutableTree.lock_write, and WorkingTree.unlock.
1836
 
 
1837
 
        :return: An object with an unlock method which will release the lock
1838
 
            obtained.
1839
 
        """
 
1821
        """See MutableTree.lock_write, and WorkingTree.unlock."""
1840
1822
        if not self.is_locked():
1841
1823
            self._reset_data()
1842
1824
        self.branch.lock_write()
1843
1825
        try:
1844
 
            self._control_files.lock_write()
1845
 
            return self
 
1826
            return self._control_files.lock_write()
1846
1827
        except:
1847
1828
            self.branch.unlock()
1848
1829
            raise
2277
2258
            last_rev = _mod_revision.NULL_REVISION
2278
2259
        if revision is None:
2279
2260
            revision = self.branch.last_revision()
 
2261
        else:
 
2262
            if revision not in self.branch.revision_history():
 
2263
                raise errors.NoSuchRevision(self.branch, revision)
2280
2264
 
2281
2265
        old_tip = old_tip or _mod_revision.NULL_REVISION
2282
2266
 
2653
2637
 
2654
2638
        In Format2 WorkingTrees we have a single lock for the branch and tree
2655
2639
        so lock_tree_write() degrades to lock_write().
2656
 
 
2657
 
        :return: An object with an unlock method which will release the lock
2658
 
            obtained.
2659
2640
        """
2660
2641
        self.branch.lock_write()
2661
2642
        try:
2662
 
            self._control_files.lock_write()
2663
 
            return self
 
2643
            return self._control_files.lock_write()
2664
2644
        except:
2665
2645
            self.branch.unlock()
2666
2646
            raise