/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_4.py

  • Committer: Jelmer Vernooij
  • Date: 2009-02-25 14:36:59 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4049.
  • Revision ID: jelmer@samba.org-20090225143659-vx6cbqtmyicuzfyf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    trace,
59
59
    transform,
60
60
    urlutils,
 
61
    views,
61
62
    xml5,
62
63
    xml6,
63
64
    )
129
130
        self._setup_directory_is_tree_reference()
130
131
        self._detect_case_handling()
131
132
        self._rules_searcher = None
 
133
        self.views = self._make_views()
132
134
        #--- allow tests to select the dirstate iter_changes implementation
133
135
        self._iter_changes = dirstate._process_entry
134
136
 
164
166
    @needs_tree_write_lock
165
167
    def add_reference(self, sub_tree):
166
168
        # use standard implementation, which calls back to self._add
167
 
        # 
 
169
        #
168
170
        # So we don't store the reference_revision in the working dirstate,
169
 
        # it's just recorded at the moment of commit. 
 
171
        # it's just recorded at the moment of commit.
170
172
        self._add_reference(sub_tree)
171
173
 
172
174
    def break_lock(self):
285
287
 
286
288
    def _generate_inventory(self):
287
289
        """Create and set self.inventory from the dirstate object.
288
 
        
 
290
 
289
291
        This is relatively expensive: we have to walk the entire dirstate.
290
292
        Ideally we would not, and can deprecate this function.
291
293
        """
361
363
        If either file_id or path is supplied, it is used as the key to lookup.
362
364
        If both are supplied, the fastest lookup is used, and an error is
363
365
        raised if they do not both point at the same row.
364
 
        
 
366
 
365
367
        :param file_id: An optional unicode file_id to be looked up.
366
368
        :param path: An optional unicode path to be looked up.
367
369
        :return: The dirstate row tuple for path/file_id, or (None, None)
423
425
    @needs_read_lock
424
426
    def get_parent_ids(self):
425
427
        """See Tree.get_parent_ids.
426
 
        
 
428
 
427
429
        This implementation requests the ids list from the dirstate file.
428
430
        """
429
431
        return self.current_dirstate().get_parent_ids()
951
953
                raise errors.PathsNotVersionedError(paths)
952
954
        # -- remove redundancy in supplied paths to prevent over-scanning --
953
955
        search_paths = osutils.minimum_path_selection(paths)
954
 
        # sketch: 
 
956
        # sketch:
955
957
        # for all search_indexs in each path at or under each element of
956
958
        # search_paths, if the detail is relocated: add the id, and add the
957
959
        # relocated path as one to search if its not searched already. If the
1013
1015
 
1014
1016
    def read_working_inventory(self):
1015
1017
        """Read the working inventory.
1016
 
        
 
1018
 
1017
1019
        This is a meaningless operation for dirstate, but we obey it anyhow.
1018
1020
        """
1019
1021
        return self.inventory
1050
1052
    @needs_tree_write_lock
1051
1053
    def set_parent_ids(self, revision_ids, allow_leftmost_as_ghost=False):
1052
1054
        """Set the parent ids to revision_ids.
1053
 
        
 
1055
 
1054
1056
        See also set_parent_trees. This api will try to retrieve the tree data
1055
1057
        for each element of revision_ids from the trees repository. If you have
1056
1058
        tree data already available, it is more efficient to use
1287
1289
    This differs from WorkingTree3 by:
1288
1290
     - Having a consolidated internal dirstate, stored in a
1289
1291
       randomly-accessible sorted file on disk.
1290
 
     - Not having a regular inventory attribute.  One can be synthesized 
 
1292
     - Not having a regular inventory attribute.  One can be synthesized
1291
1293
       on demand but this is expensive and should be avoided.
1292
1294
 
1293
1295
    This is new in bzr 0.15.
1305
1307
    This is new in bzr 1.11.
1306
1308
    """
1307
1309
 
 
1310
    def _make_views(self):
 
1311
        return views.PathBasedViews(self)
 
1312
 
1308
1313
 
1309
1314
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1310
1315
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1396
1401
 
1397
1402
    def _init_custom_control_files(self, wt):
1398
1403
        """Subclasses with custom control files should override this method.
1399
 
        
 
1404
 
1400
1405
        The working tree and control files are locked for writing when this
1401
1406
        method is called.
1402
 
        
 
1407
 
1403
1408
        :param wt: the WorkingTree object
1404
1409
        """
1405
1410
 
1551
1556
        If either file_id or path is supplied, it is used as the key to lookup.
1552
1557
        If both are supplied, the fastest lookup is used, and an error is
1553
1558
        raised if they do not both point at the same row.
1554
 
        
 
1559
 
1555
1560
        :param file_id: An optional unicode file_id to be looked up.
1556
1561
        :param path: An optional unicode path to be looked up.
1557
1562
        :return: The dirstate row tuple for path/file_id, or (None, None)
1803
1808
 
1804
1809
    def walkdirs(self, prefix=""):
1805
1810
        # TODO: jam 20070215 This is the lazy way by using the RevisionTree
1806
 
        # implementation based on an inventory.  
 
1811
        # implementation based on an inventory.
1807
1812
        # This should be cleaned up to use the much faster Dirstate code
1808
1813
        # So for now, we just build up the parent inventory, and extract
1809
1814
        # it the same way RevisionTree does.
1838
1843
 
1839
1844
class InterDirStateTree(InterTree):
1840
1845
    """Fast path optimiser for changes_from with dirstate trees.
1841
 
    
1842
 
    This is used only when both trees are in the dirstate working file, and 
1843
 
    the source is any parent within the dirstate, and the destination is 
 
1846
 
 
1847
    This is used only when both trees are in the dirstate working file, and
 
1848
    the source is any parent within the dirstate, and the destination is
1844
1849
    the current working tree of the same dirstate.
1845
1850
    """
1846
1851
    # this could be generalized to allow comparisons between any trees in the
1999
2004
        # the source revid must be in the target dirstate
2000
2005
        if not (source._revision_id == NULL_REVISION or
2001
2006
            source._revision_id in target.get_parent_ids()):
2002
 
            # TODO: what about ghosts? it may well need to 
 
2007
            # TODO: what about ghosts? it may well need to
2003
2008
            # check for them explicitly.
2004
2009
            return False
2005
2010
        return True
2015
2020
 
2016
2021
    def convert(self, tree):
2017
2022
        # lock the control files not the tree, so that we dont get tree
2018
 
        # on-unlock behaviours, and so that noone else diddles with the 
 
2023
        # on-unlock behaviours, and so that noone else diddles with the
2019
2024
        # tree during upgrade.
2020
2025
        tree._control_files.lock_write()
2021
2026
        try:
2060
2065
 
2061
2066
    def convert(self, tree):
2062
2067
        # lock the control files not the tree, so that we don't get tree
2063
 
        # on-unlock behaviours, and so that no-one else diddles with the 
 
2068
        # on-unlock behaviours, and so that no-one else diddles with the
2064
2069
        # tree during upgrade.
2065
2070
        tree._control_files.lock_write()
2066
2071
        try: