~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
        else:
282
282
            self.case_sensitive = False
283
283
 
 
284
        self._setup_directory_is_tree_reference()
 
285
 
284
286
    branch = property(
285
287
        fget=lambda self: self._branch,
286
288
        doc="""The branch this WorkingTree is connected to.
357
359
        """
358
360
        return WorkingTree.open(path, _unsupported=True)
359
361
 
 
362
    @staticmethod
 
363
    def find_trees(location):
 
364
        def list_current(transport):
 
365
            return [d for d in transport.list_dir('') if d != '.bzr']
 
366
        def evaluate(bzrdir):
 
367
            try:
 
368
                tree = bzrdir.open_workingtree()
 
369
            except errors.NoWorkingTree:
 
370
                return True, None
 
371
            else:
 
372
                return True, tree
 
373
        transport = get_transport(location)
 
374
        iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,
 
375
                                              list_current=list_current)
 
376
        return [t for t in iterator if t is not None]
 
377
 
360
378
    # should be deprecated - this is slow and in any case treating them as a
361
379
    # container is (we now know) bad style -- mbp 20070302
362
380
    ## @deprecated_method(zero_fifteen)
990
1008
            other_tree.unlock()
991
1009
        other_tree.bzrdir.retire_bzrdir()
992
1010
 
993
 
    def _directory_is_tree_reference(self, relpath):
 
1011
    def _setup_directory_is_tree_reference(self):
 
1012
        if self._branch.repository._format.supports_tree_reference:
 
1013
            self._directory_is_tree_reference = \
 
1014
                self._directory_may_be_tree_reference
 
1015
        else:
 
1016
            self._directory_is_tree_reference = \
 
1017
                self._directory_is_never_tree_reference
 
1018
 
 
1019
    def _directory_is_never_tree_reference(self, relpath):
 
1020
        return False
 
1021
 
 
1022
    def _directory_may_be_tree_reference(self, relpath):
994
1023
        # as a special case, if a directory contains control files then 
995
1024
        # it's a tree reference, except that the root of the tree is not
996
1025
        return relpath and osutils.isdir(self.abspath(relpath) + u"/.bzr")
2733
2762
        control_files.put_bytes('pending-merges', '')
2734
2763
        
2735
2764
 
2736
 
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
 
2765
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
 
2766
                   accelerator_tree=None):
2737
2767
        """See WorkingTreeFormat.initialize()."""
2738
2768
        if not isinstance(a_bzrdir.transport, LocalTransport):
2739
2769
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2825
2855
        return LockableFiles(transport, self._lock_file_name, 
2826
2856
                             self._lock_class)
2827
2857
 
2828
 
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
 
2858
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
 
2859
                   accelerator_tree=None):
2829
2860
        """See WorkingTreeFormat.initialize().
2830
2861
        
2831
 
        revision_id allows creating a working tree at a different
2832
 
        revision than the branch is at.
 
2862
        :param revision_id: if supplied, create a working tree at a different
 
2863
            revision than the branch is at.
 
2864
        :param accelerator_tree: A tree which can be used for retrieving file
 
2865
            contents more quickly than the revision tree, i.e. a workingtree.
 
2866
            The revision tree will be used for cases where accelerator_tree's
 
2867
            content is different.
2833
2868
        """
2834
2869
        if not isinstance(a_bzrdir.transport, LocalTransport):
2835
2870
            raise errors.NotLocalUrl(a_bzrdir.transport.base)