/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 breezy/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
from breezy import (
45
45
    conflicts as _mod_conflicts,
46
 
    controldir,
47
46
    errors,
48
47
    filters as _mod_filters,
49
48
    merge,
57
56
    )
58
57
""")
59
58
 
 
59
from .controldir import (
 
60
    ControlComponent,
 
61
    ControlComponentFormatRegistry,
 
62
    ControlComponentFormat,
 
63
    ControlDir,
 
64
    ControlDirFormat,
 
65
    )
60
66
from . import (
61
67
    osutils,
62
68
    )
78
84
    _fmt = "This format does not support shelving changes."
79
85
 
80
86
 
81
 
class WorkingTree(mutabletree.MutableTree, controldir.ControlComponent):
 
87
class WorkingTree(mutabletree.MutableTree, ControlComponent):
82
88
    """Working copy tree.
83
89
 
84
90
    :ivar basedir: The root of the tree on disk. This is a unicode path object
198
204
        """
199
205
        if path is None:
200
206
            path = osutils.getcwd()
201
 
        control = controldir.ControlDir.open(path, _unsupported=_unsupported)
 
207
        control = ControlDir.open(path, _unsupported=_unsupported)
202
208
        return control.open_workingtree(unsupported=_unsupported)
203
209
 
204
210
    @staticmethod
216
222
        """
217
223
        if path is None:
218
224
            path = osutils.getcwd()
219
 
        control, relpath = controldir.ControlDir.open_containing(path)
 
225
        control, relpath = ControlDir.open_containing(path)
220
226
        return control.open_workingtree(), relpath
221
227
 
222
228
    @staticmethod
294
300
        """
295
301
        return WorkingTree.open(path, _unsupported=True)
296
302
 
297
 
    @staticmethod
298
 
    def find_trees(location):
299
 
        def list_current(transport):
300
 
            return [d for d in transport.list_dir('')
301
 
                    if not controldir.is_control_filename(d)]
302
 
 
303
 
        def evaluate(controldir):
304
 
            try:
305
 
                tree = controldir.open_workingtree()
306
 
            except errors.NoWorkingTree:
307
 
                return True, None
308
 
            else:
309
 
                return True, tree
310
 
        t = transport.get_transport(location)
311
 
        iterator = controldir.ControlDir.find_controldirs(t, evaluate=evaluate,
312
 
                                                          list_current=list_current)
313
 
        return [tr for tr in iterator if tr is not None]
314
 
 
315
303
    def __repr__(self):
316
304
        return "<%s of %s>" % (self.__class__.__name__,
317
305
                               getattr(self, 'basedir', None))
729
717
    def subsume(self, other_tree):
730
718
        raise NotImplementedError(self.subsume)
731
719
 
732
 
    def _setup_directory_is_tree_reference(self):
733
 
        if self._branch.repository._format.supports_tree_reference:
734
 
            self._directory_is_tree_reference = \
735
 
                self._directory_may_be_tree_reference
736
 
        else:
737
 
            self._directory_is_tree_reference = \
738
 
                self._directory_is_never_tree_reference
739
 
 
740
 
    def _directory_is_never_tree_reference(self, relpath):
741
 
        return False
742
 
 
743
 
    def _directory_may_be_tree_reference(self, relpath):
744
 
        # as a special case, if a directory contains control files then
745
 
        # it's a tree reference, except that the root of the tree is not
746
 
        return relpath and osutils.isdir(self.abspath(relpath) + u"/.bzr")
747
 
        # TODO: We could ask all the control formats whether they
748
 
        # recognize this directory, but at the moment there's no cheap api
749
 
        # to do that.  Since we probably can only nest bzr checkouts and
750
 
        # they always use this name it's ok for now.  -- mbp 20060306
751
 
        #
752
 
        # FIXME: There is an unhandled case here of a subdirectory
753
 
        # containing .bzr but not a branch; that will probably blow up
754
 
        # when you try to commit it.  It might happen if there is a
755
 
        # checkout in a subdirectory.  This can be avoided by not adding
756
 
        # it.  mbp 20070306
 
720
    def _directory_is_tree_reference(self, relpath):
 
721
        raise NotImplementedError(self._directory_is_tree_reference)
757
722
 
758
723
    def extract(self, path, format=None):
759
724
        """Extract a subtree from this tree.
1373
1338
            return next(self.get_canonical_paths([path]))
1374
1339
 
1375
1340
 
1376
 
class WorkingTreeFormatRegistry(controldir.ControlComponentFormatRegistry):
 
1341
class WorkingTreeFormatRegistry(ControlComponentFormatRegistry):
1377
1342
    """Registry for working tree formats."""
1378
1343
 
1379
1344
    def __init__(self, other_registry=None):
1402
1367
format_registry = WorkingTreeFormatRegistry()
1403
1368
 
1404
1369
 
1405
 
class WorkingTreeFormat(controldir.ControlComponentFormat):
 
1370
class WorkingTreeFormat(ControlComponentFormat):
1406
1371
    """An encapsulation of the initialization and open routines for a format.
1407
1372
 
1408
1373
    Formats provide three things: