/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

  • Committer: Jelmer Vernooij
  • Date: 2010-04-10 01:22:00 UTC
  • mto: This revision was merged to the branch mainline in revision 5143.
  • Revision ID: jelmer@samba.org-20100410012200-y089oi8jwvx9khyh
Add test for Repository.get_known_graph_ancestry().

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
77
83
 
78
84
from bzrlib import symbol_versioning
79
85
from bzrlib.decorators import needs_read_lock, needs_write_lock
80
 
from bzrlib.lock import LogicalLockResult
81
86
from bzrlib.lockable_files import LockableFiles
82
87
from bzrlib.lockdir import LockDir
83
88
import bzrlib.mutabletree
96
101
from bzrlib.filters import filtered_input_file
97
102
from bzrlib.trace import mutter, note
98
103
from bzrlib.transport.local import LocalTransport
 
104
from bzrlib.progress import ProgressPhase
99
105
from bzrlib.revision import CURRENT_REVISION
100
106
from bzrlib.rio import RioReader, rio_file, Stanza
101
107
from bzrlib.symbol_versioning import (
168
174
        return ''
169
175
 
170
176
 
171
 
class WorkingTree(bzrlib.mutabletree.MutableTree,
172
 
    bzrdir.ControlComponent):
 
177
class WorkingTree(bzrlib.mutabletree.MutableTree):
173
178
    """Working copy tree.
174
179
 
175
180
    The inventory is held in the `Branch` working-inventory, and the
248
253
        self._rules_searcher = None
249
254
        self.views = self._make_views()
250
255
 
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
 
 
259
256
    def _detect_case_handling(self):
260
257
        wt_trans = self.bzrdir.get_workingtree_transport(None)
261
258
        try:
1142
1139
        This does not include files that have been deleted in this
1143
1140
        tree. Skips the control directory.
1144
1141
 
1145
 
        :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
1146
1143
        :param from_dir: start from this directory or None for the root
1147
1144
        :param recursive: whether to recurse into subdirectories or not
1148
1145
        """
1799
1796
            raise errors.ObjectNotLocked(self)
1800
1797
 
1801
1798
    def lock_read(self):
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
 
        """
 
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 LogicalLockResult(self.unlock)
 
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: A bzrlib.lock.LogicalLockResult.
1822
 
        """
 
1810
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
1823
1811
        if not self.is_locked():
1824
1812
            self._reset_data()
1825
1813
        self.branch.lock_read()
1826
1814
        try:
1827
 
            self._control_files.lock_write()
1828
 
            return LogicalLockResult(self.unlock)
 
1815
            return self._control_files.lock_write()
1829
1816
        except:
1830
1817
            self.branch.unlock()
1831
1818
            raise
1832
1819
 
1833
1820
    def lock_write(self):
1834
 
        """See MutableTree.lock_write, and WorkingTree.unlock.
1835
 
 
1836
 
        :return: A bzrlib.lock.LogicalLockResult.
1837
 
        """
 
1821
        """See MutableTree.lock_write, and WorkingTree.unlock."""
1838
1822
        if not self.is_locked():
1839
1823
            self._reset_data()
1840
1824
        self.branch.lock_write()
1841
1825
        try:
1842
 
            self._control_files.lock_write()
1843
 
            return LogicalLockResult(self.unlock)
 
1826
            return self._control_files.lock_write()
1844
1827
        except:
1845
1828
            self.branch.unlock()
1846
1829
            raise
1971
1954
        def recurse_directory_to_add_files(directory):
1972
1955
            # Recurse directory and add all files
1973
1956
            # so we can check if they have changed.
1974
 
            for parent_info, file_infos in self.walkdirs(directory):
 
1957
            for parent_info, file_infos in\
 
1958
                self.walkdirs(directory):
1975
1959
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1976
1960
                    # Is it versioned or ignored?
1977
1961
                    if self.path2id(relpath) or self.is_ignored(relpath):
2012
1996
                            # ... but not ignored
2013
1997
                            has_changed_files = True
2014
1998
                            break
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.
 
1999
                    elif content_change and (kind[1] is not None):
 
2000
                        # Versioned and changed, but not deleted
2019
2001
                        has_changed_files = True
2020
2002
                        break
2021
2003
 
2276
2258
            last_rev = _mod_revision.NULL_REVISION
2277
2259
        if revision is None:
2278
2260
            revision = self.branch.last_revision()
 
2261
        else:
 
2262
            if revision not in self.branch.revision_history():
 
2263
                raise errors.NoSuchRevision(self.branch, revision)
2279
2264
 
2280
2265
        old_tip = old_tip or _mod_revision.NULL_REVISION
2281
2266
 
2652
2637
 
2653
2638
        In Format2 WorkingTrees we have a single lock for the branch and tree
2654
2639
        so lock_tree_write() degrades to lock_write().
2655
 
 
2656
 
        :return: An object with an unlock method which will release the lock
2657
 
            obtained.
2658
2640
        """
2659
2641
        self.branch.lock_write()
2660
2642
        try:
2661
 
            self._control_files.lock_write()
2662
 
            return self
 
2643
            return self._control_files.lock_write()
2663
2644
        except:
2664
2645
            self.branch.unlock()
2665
2646
            raise